filename | test/lib.h |
changeset | 976:e57a25d9eb7d |
prev | 815:866c103d72cd |
author | nkeynes |
date | Fri Dec 02 18:14:27 2011 +1000 (12 years ago) |
permissions | -rw-r--r-- |
last change | Handle calls to sh4_disasm_instruction when the memory isn't mapped (as can happen if we try to print a translated block that's been unmapped) |
view | annotate | diff | log | raw |
1 #ifndef dc_lib_H
2 #define dc_lib_H
4 #include <stdio.h>
6 typedef unsigned char uint8_t;
7 typedef unsigned short uint16_t;
8 typedef unsigned int uint32_t;
9 typedef volatile unsigned int vuint32_t;
10 typedef volatile unsigned short vuint16_t;
12 #define ASIC_STATUS0 0xA05F6900
13 #define ASIC_STATUS1 0xA05F6904
14 #define ASIC_STATUS2 0xA05F6908
15 #define ASIC_IRQB0 0xA05F6920
16 #define ASIC_IRQC2 0xA05f6938
17 #define IRQB0_MASK 0x0007B000
19 #define AICA_RESET 0xA0702C00
21 #define float_read(A) (*((volatile float*)(A)))
22 #define float_write(A, V) ( (*((volatile float*)(A))) = (V) )
23 #define long_read(A) (*((volatile unsigned long*)(A)))
24 #define long_write(A, V) ( (*((volatile unsigned long*)(A))) = (V) )
25 #define word_read(A) (*((volatile unsigned short*)(A)))
26 #define word_write(A, V) ( (*((volatile unsigned short*)(A))) = (V) )
27 #define byte_read(A) (unsigned int)(*((volatile unsigned char*)(A)))
28 #define byte_write(A, V) ( (*((volatile unsigned char*)(A))) = (V) )
30 int asic_wait(int event);
31 void asic_clear(void);
32 void asic_dump(FILE *f);
34 void fwrite_dump(FILE *f, char *buf, int length);
35 void fwrite_diff(FILE *f, char *expect, int exp_length, char *buf, int length);
36 void fwrite_diff32(FILE *f, char *expect, int exp_length, char *buf, int length);
38 void *align32(char *buf );
39 void write_asic_status(void);
40 void reset_asic_status(void);
42 #define aica_enable() long_write( AICA_RESET, (long_read(AICA_RESET) & 0xFFFFFFFE) )
43 #define aica_disable() long_write( AICA_RESET, (long_read(AICA_RESET) | 1) )
45 struct spudma_struct {
46 uint32_t g2_addr;
47 uint32_t sh4_addr;
48 uint32_t count;
49 uint32_t direction;
50 uint32_t mode;
51 uint32_t enable;
52 uint32_t status;
53 uint32_t blah;
54 };
55 extern struct spudma_struct *spudma;
57 #define get_asic_status() (long_read(ASIC_STATUS0)&EVENT_MAPLE_MASK)
59 int is_start_pressed();
61 #define CHECK_IEQUALS( a, b ) if( a != b ) { fprintf(stderr, "Assertion failed at %s:%d: expected %08X, but was %08X\n", __FILE__, __LINE__, a, b ); return -1; }
62 #define DMA_ALIGN(x) ((void *)((((unsigned int)(x))+0x1F)&0xFFFFFFE0))
65 /* SH4 Exceptions */
66 #define POWERON 0x000 /* reset vector */
67 #define MANRESET 0x020 /* reset vector */
68 #define OTLBMULTIHIT 0x140 /* reset vector */
69 #define RTLBMISS 0x040 /* TLB vector */
70 #define WTLBMISS 0x060 /* TLB vector */
71 #define FIRSTWRITE 0x080
72 #define READPROT 0x0A0
73 #define WRITEPROT 0x0C0
74 #define RADDERR 0x0E0
75 #define WADDERR 0x100
76 #define FPUEXC 0x120
77 #define ILLSLOT 0x1A0
78 #define RESINST 0x180
79 #define TRAP 0x160
80 #define FPUDIS 0x800
81 #define SLOTFPUDIS 0x820
83 #endif
.