[444] | 1 | |
---|
| 2 | |
---|
| 3 | #define READ_UINT8( _register_, _value_ ) \ |
---|
| 4 | ((_value_) = *((volatile unsigned char *)(_register_))) |
---|
| 5 | |
---|
| 6 | #define WRITE_UINT8( _register_, _value_ ) \ |
---|
| 7 | (*((volatile unsigned char *)(_register_)) = (_value_)) |
---|
| 8 | |
---|
| 9 | /* - Board specific addresses for serial chip */ |
---|
| 10 | #define DIAG_BASE 0xfffff300 |
---|
| 11 | #define DIAG_SLCR (DIAG_BASE+0x00) |
---|
| 12 | #define DIAG_SLSR (DIAG_BASE+0x04) |
---|
| 13 | #define DIAG_SLDICR (DIAG_BASE+0x08) |
---|
| 14 | #define DIAG_SLDISR (DIAG_BASE+0x0C) |
---|
| 15 | #define DIAG_SFCR (DIAG_BASE+0x10) |
---|
| 16 | #define DIAG_SBRG (DIAG_BASE+0x14) |
---|
| 17 | #define DIAG_TFIFO (DIAG_BASE+0x20) |
---|
| 18 | #define DIAG_RFIFO (DIAG_BASE+0x30) |
---|
| 19 | |
---|
| 20 | #define BRG_T0 0x0000 |
---|
| 21 | #define BRG_T2 0x0100 |
---|
| 22 | #define BRG_T4 0x0200 |
---|
| 23 | #define BRG_T5 0x0300 |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | #define READ_UINT16( _register_, _value_ ) \ |
---|
| 27 | ((_value_) = *((volatile unsigned short *)(_register_))) |
---|
| 28 | |
---|
| 29 | #define WRITE_UINT16( _register_, _value_ ) \ |
---|
| 30 | (*((volatile unsigned short *)(_register_)) = (_value_)) |
---|
| 31 | |
---|
| 32 | unsigned char |
---|
| 33 | inbyte (void) |
---|
| 34 | { |
---|
| 35 | unsigned char c; |
---|
| 36 | unsigned short disr; |
---|
| 37 | |
---|
| 38 | for (;;) |
---|
| 39 | { |
---|
| 40 | READ_UINT16 (DIAG_SLDISR, disr); |
---|
| 41 | if (disr & 0x0001) |
---|
| 42 | break; |
---|
| 43 | } |
---|
| 44 | disr = disr & ~0x0001; |
---|
| 45 | READ_UINT8 (DIAG_RFIFO, c); |
---|
| 46 | WRITE_UINT16 (DIAG_SLDISR, disr); |
---|
| 47 | return c; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | void |
---|
| 51 | outbyte (unsigned char c) |
---|
| 52 | { |
---|
| 53 | unsigned short disr; |
---|
| 54 | |
---|
| 55 | for (;;) |
---|
| 56 | { |
---|
| 57 | READ_UINT16 (DIAG_SLDISR, disr); |
---|
| 58 | if (disr & 0x0002) |
---|
| 59 | break; |
---|
| 60 | } |
---|
| 61 | disr = disr & ~0x0002; |
---|
| 62 | WRITE_UINT8 (DIAG_TFIFO, c); |
---|
| 63 | WRITE_UINT16 (DIAG_SLDISR, disr); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /* Stuff required to setup IO on this board */ |
---|
| 67 | void board_serial_init (void) |
---|
| 68 | { |
---|
| 69 | WRITE_UINT16 (DIAG_SLCR, 0x0020); |
---|
| 70 | WRITE_UINT16 (DIAG_SLDICR, 0x0000); |
---|
| 71 | WRITE_UINT16 (DIAG_SFCR, 0x0000); |
---|
| 72 | WRITE_UINT16 (DIAG_SBRG, BRG_T2 | 5); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | /* If you want this to be initialized as part of the stuff which gets called |
---|
| 76 | by crt0, it should be named 'hardware_init_hook'. |
---|
| 77 | Local implementations may want to move or add to this function OR |
---|
| 78 | do the initializations after main() is entered. |
---|
| 79 | */ |
---|
| 80 | void hardware_init_hook(void) |
---|
| 81 | { |
---|
| 82 | board_serial_init() ; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | /* Structure filled in by get_mem_info. Only the size field is |
---|
| 86 | actually used (by sbrk), so the others aren't even filled in. */ |
---|
| 87 | |
---|
| 88 | struct s_mem |
---|
| 89 | { |
---|
| 90 | unsigned int size; |
---|
| 91 | unsigned int icsize; |
---|
| 92 | unsigned int dcsize; |
---|
| 93 | }; |
---|
| 94 | |
---|
| 95 | /* mem_size is provided in the linker script so that we don't have to |
---|
| 96 | define it here. */ |
---|
| 97 | extern char _mem_size[]; |
---|
| 98 | |
---|
| 99 | void |
---|
| 100 | get_mem_info (mem) |
---|
| 101 | struct s_mem *mem; |
---|
| 102 | { |
---|
| 103 | mem->size = (unsigned int)_mem_size; |
---|
| 104 | } |
---|