Search
lxdream.org :: lxdream/test/lib.h
lxdream 0.9.1
released Jun 29
Download Now
filename test/lib.h
changeset 976:e57a25d9eb7d
prev815:866c103d72cd
author nkeynes
date Mon Jan 26 12:32:23 2009 +0000 (13 years ago)
permissions -rw-r--r--
last change Add some initial TLB test cases
file annotate diff log raw
nkeynes@185
     1
#ifndef dc_lib_H
nkeynes@185
     2
#define dc_lib_H
nkeynes@185
     3
nkeynes@185
     4
#include <stdio.h>
nkeynes@185
     5
nkeynes@185
     6
typedef unsigned char uint8_t;
nkeynes@185
     7
typedef unsigned short uint16_t;
nkeynes@185
     8
typedef unsigned int uint32_t;
nkeynes@185
     9
typedef volatile unsigned int vuint32_t;
nkeynes@185
    10
typedef volatile unsigned short vuint16_t;
nkeynes@185
    11
nkeynes@185
    12
#define ASIC_STATUS0    0xA05F6900
nkeynes@185
    13
#define ASIC_STATUS1    0xA05F6904
nkeynes@185
    14
#define ASIC_STATUS2    0xA05F6908
nkeynes@185
    15
#define ASIC_IRQB0      0xA05F6920
nkeynes@185
    16
#define ASIC_IRQC2      0xA05f6938
nkeynes@185
    17
#define IRQB0_MASK      0x0007B000
nkeynes@185
    18
nkeynes@812
    19
#define AICA_RESET      0xA0702C00
nkeynes@812
    20
nkeynes@210
    21
#define float_read(A)      (*((volatile float*)(A)))
nkeynes@210
    22
#define float_write(A, V) ( (*((volatile float*)(A))) = (V) )
nkeynes@185
    23
#define long_read(A)      (*((volatile unsigned long*)(A)))
nkeynes@185
    24
#define long_write(A, V) ( (*((volatile unsigned long*)(A))) = (V) )
nkeynes@185
    25
#define word_read(A)      (*((volatile unsigned short*)(A)))
nkeynes@185
    26
#define word_write(A, V) ( (*((volatile unsigned short*)(A))) = (V) )
nkeynes@185
    27
#define byte_read(A)       (unsigned int)(*((volatile unsigned char*)(A)))
nkeynes@185
    28
#define byte_write(A, V) ( (*((volatile unsigned char*)(A))) = (V) )
nkeynes@185
    29
nkeynes@185
    30
int asic_wait(int event);
nkeynes@185
    31
void asic_clear(void);
nkeynes@185
    32
void asic_dump(FILE *f);
nkeynes@185
    33
nkeynes@185
    34
void fwrite_dump(FILE *f, char *buf, int length);
nkeynes@190
    35
void fwrite_diff(FILE *f, char *expect, int exp_length, char *buf, int length);
nkeynes@190
    36
void fwrite_diff32(FILE *f, char *expect, int exp_length, char *buf, int length);
nkeynes@185
    37
nkeynes@185
    38
void *align32(char *buf );
nkeynes@185
    39
void write_asic_status(void);
nkeynes@185
    40
void reset_asic_status(void);
nkeynes@185
    41
nkeynes@812
    42
#define aica_enable() long_write( AICA_RESET, (long_read(AICA_RESET) & 0xFFFFFFFE) )
nkeynes@812
    43
#define aica_disable()  long_write( AICA_RESET, (long_read(AICA_RESET) | 1) )
nkeynes@185
    44
nkeynes@185
    45
struct spudma_struct {
nkeynes@185
    46
    uint32_t g2_addr;
nkeynes@185
    47
    uint32_t sh4_addr;
nkeynes@185
    48
    uint32_t count;
nkeynes@185
    49
    uint32_t direction;
nkeynes@185
    50
    uint32_t mode;
nkeynes@185
    51
    uint32_t enable;
nkeynes@185
    52
    uint32_t status;
nkeynes@185
    53
    uint32_t blah;
nkeynes@185
    54
};
nkeynes@185
    55
extern struct spudma_struct *spudma;
nkeynes@185
    56
nkeynes@185
    57
#define get_asic_status() (long_read(ASIC_STATUS0)&EVENT_MAPLE_MASK)
nkeynes@185
    58
nkeynes@185
    59
int is_start_pressed();
nkeynes@185
    60
nkeynes@185
    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; }
nkeynes@278
    62
#define DMA_ALIGN(x)   ((void *)((((unsigned int)(x))+0x1F)&0xFFFFFFE0))
nkeynes@185
    63
nkeynes@976
    64
nkeynes@976
    65
/* SH4 Exceptions */
nkeynes@976
    66
#define POWERON      0x000 /* reset vector */
nkeynes@976
    67
#define MANRESET     0x020 /* reset vector */
nkeynes@976
    68
#define OTLBMULTIHIT 0x140 /* reset vector */
nkeynes@976
    69
#define RTLBMISS     0x040 /* TLB vector */
nkeynes@976
    70
#define WTLBMISS     0x060 /* TLB vector */
nkeynes@976
    71
#define FIRSTWRITE   0x080
nkeynes@976
    72
#define READPROT     0x0A0
nkeynes@976
    73
#define WRITEPROT    0x0C0
nkeynes@976
    74
#define RADDERR      0x0E0
nkeynes@976
    75
#define WADDERR      0x100
nkeynes@976
    76
#define FPUEXC       0x120
nkeynes@976
    77
#define ILLSLOT      0x1A0
nkeynes@976
    78
#define RESINST      0x180
nkeynes@976
    79
#define TRAP         0x160
nkeynes@976
    80
#define FPUDIS       0x800
nkeynes@976
    81
#define SLOTFPUDIS   0x820
nkeynes@976
    82
nkeynes@185
    83
#endif
.