aboutsummaryrefslogtreecommitdiff
path: root/sim/mips/sky-vu0.c
blob: a685713e4cc19e141173bb2f8f816696ca3aedb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*  Copyright (C) 1998, Cygnus Solutions

    */

#include "sim-main.h"

#include "sky-device.h"
#include "sky-vu.h"
#include "sky-vu0.h"

VectorUnitState vu0_state;

/* these are aligned versions of zalloc() pointers - do not zfree()! */
static char* vu0_mem0_buffer = 0;
static char* vu0_mem1_buffer = 0;


void 
vu0_issue(void) 
{
}

static int
vu0_io_read_buffer(device *me,
                      void *dest,
                      int space,
                      address_word addr,
                      unsigned nr_bytes,
                      sim_cpu *processor,
                      sim_cia cia)
{
  if (addr < VU0_REGISTER_WINDOW_START)
    return 0;

  addr -= VU0_REGISTER_WINDOW_START;

  /* Adjust nr_bytes if too big */
  if ((addr + nr_bytes) > VU_REG_END)
    nr_bytes -= addr + nr_bytes - VU_REG_END;

  return read_vu_registers (&vu0_state, addr, nr_bytes, dest);
}

static int
vu0_io_write_buffer(device *me,
                    const void *source,
                    int space,
                    address_word addr,
                    unsigned nr_bytes,
                    sim_cpu *processor,
                    sim_cia cia)
{
  if (addr < VU0_REGISTER_WINDOW_START)
    return 0;

  addr -= VU0_REGISTER_WINDOW_START;

  /* Adjust nr_bytes if too big */
  if ((addr + nr_bytes) > VU_REG_END)
    nr_bytes -= addr + nr_bytes - VU_REG_END;

  return write_vu_registers (&vu0_state, addr, nr_bytes, source);
}

device vu0_device = 
  { 
    "vu0", 
    &vu0_io_read_buffer,
    &vu0_io_write_buffer 
  };

void 
vu0_attach(SIM_DESC sd) 
{
  sim_core_attach (sd,
		   NULL,
                   0 /*level*/,
                   access_read_write,
                   0 /*space ???*/,
                   VU0_REGISTER_WINDOW_START,
                   VU_REG_END /*nr_bytes*/,
                   0 /*modulo*/,
                   &vu0_device,
                   NULL /*buffer*/);

  vu0_mem0_buffer = zalloc(VU0_MEM0_SIZE);
  vu0_mem0_buffer = (void*) ALIGN_16((unsigned)vu0_mem0_buffer);
  sim_core_attach (sd,
		   NULL,
                   0 /*level*/,
                   access_read_write,
                   0 /*space ???*/,
                   VU0_MEM0_WINDOW_START,
                   VU0_MEM0_SIZE /*nr_bytes*/,
                   0 /*modulo*/,
                   0 /*device*/,
                   vu0_mem0_buffer /*buffer*/);

  vu0_mem1_buffer = zalloc(VU0_MEM1_SIZE);
  vu0_mem1_buffer = (void*) ALIGN_16((unsigned)vu0_mem1_buffer);
  sim_core_attach (sd,
		   NULL,
                   0 /*level*/,
                   access_read_write,
                   0 /*space ???*/,
                   VU0_MEM1_WINDOW_START,
                   VU0_MEM1_SIZE /*nr_bytes*/,
                   0 /*modulo*/,
                   0 /*device*/,
                   vu0_mem1_buffer /*buffer*/);
}