|
|
1.1 root 1: #include "main.h"
2: #include "configuration.h"
3: #include "m68000.h"
4: #include "sysdeps.h"
5: #include "bmap.h"
6:
7:
8: /* NeXT bmap chip emulation */
9:
10:
11: uae_u32 NEXTbmap[16];
12:
1.1.1.2 ! root 13: int bmap_tpe_select = 0;
! 14:
1.1 root 15: uae_u32 bmap_get(uae_u32 addr);
16: void bmap_put(uae_u32 addr, uae_u32 val);
17:
18:
19: #define BMAP_DATA_RW 0xD
20:
1.1.1.2 ! root 21: #define BMAP_TPE_RXSEL 0x80000000
! 22: #define BMAP_HEARTBEAT 0x20000000
! 23: #define BMAP_TPE_ILBC 0x10000000
! 24: #define BMAP_TPE (BMAP_TPE_RXSEL|BMAP_TPE_ILBC)
1.1 root 25:
26: uae_u32 bmap_lget(uaecptr addr) {
1.1.1.2 ! root 27: uae_u32 l;
! 28:
! 29: if (addr&3) {
1.1 root 30: Log_Printf(LOG_WARN, "[BMAP] Unaligned access.");
1.1.1.2 ! root 31: return 0;
1.1 root 32: }
1.1.1.2 ! root 33:
! 34: l = bmap_get(addr>>2);
1.1 root 35:
1.1.1.2 ! root 36: return l;
1.1 root 37: }
38:
39: uae_u32 bmap_wget(uaecptr addr) {
1.1.1.2 ! root 40: uae_u32 w;
! 41: int shift;
1.1 root 42:
1.1.1.2 ! root 43: if (addr&1) {
! 44: Log_Printf(LOG_WARN, "[BMAP] Unaligned access.");
! 45: return 0;
1.1 root 46: }
1.1.1.2 ! root 47:
! 48: shift = (2 - (addr&2)) * 8;
! 49:
! 50: w = bmap_get(addr>>2);
! 51: w >>= shift;
! 52: w &= 0xFFFF;
1.1 root 53:
54: return w;
55: }
56:
57: uae_u32 bmap_bget(uaecptr addr) {
1.1.1.2 ! root 58: uae_u32 b;
! 59: int shift;
1.1 root 60:
1.1.1.2 ! root 61: shift = (3 - (addr&3)) * 8;
! 62:
! 63: b = bmap_get(addr>>2);
! 64: b >>= shift;
! 65: b &= 0xFF;
1.1 root 66:
67: return b;
68: }
69:
70: void bmap_lput(uaecptr addr, uae_u32 l) {
1.1.1.2 ! root 71: if (addr&3) {
1.1 root 72: Log_Printf(LOG_WARN, "[BMAP] Unaligned access.");
1.1.1.2 ! root 73: return;
1.1 root 74: }
1.1.1.2 ! root 75:
! 76: bmap_put(addr>>2, l);
1.1 root 77: }
78:
79: void bmap_wput(uaecptr addr, uae_u32 w) {
80: uae_u32 val;
1.1.1.2 ! root 81: int shift;
1.1 root 82:
1.1.1.2 ! root 83: if (addr&1) {
! 84: Log_Printf(LOG_WARN, "[BMAP] Unaligned access.");
! 85: return;
1.1 root 86: }
1.1.1.2 ! root 87:
! 88: shift = (2 - (addr&2)) * 8;
! 89:
! 90: val = NEXTbmap[addr>>2];
! 91: val &= ~(0xFFFF << shift);
! 92: val |= w << shift;
1.1 root 93:
1.1.1.2 ! root 94: bmap_put(addr>>2, val);
1.1 root 95: }
96:
97: void bmap_bput(uaecptr addr, uae_u32 b) {
1.1.1.2 ! root 98: uae_u32 val;
! 99: int shift;
1.1 root 100:
1.1.1.2 ! root 101: shift = (3 - (addr&3)) * 8;
! 102:
! 103: val = NEXTbmap[addr>>2];
! 104: val &= ~(0xFF << shift);
! 105: val |= b << shift;
1.1 root 106:
1.1.1.2 ! root 107: bmap_put(addr>>2, val);
1.1 root 108: }
109:
110:
111: uae_u32 bmap_get(uae_u32 bmap_reg) {
112: uae_u32 val;
113:
114: switch (bmap_reg) {
115: case BMAP_DATA_RW:
116: /* This is for detecing thin wire ethernet.
117: * It prevents from switching ethernet
118: * transceiver to loopback mode.
119: */
1.1.1.2 ! root 120: val = NEXTbmap[BMAP_DATA_RW];
! 121:
! 122: if (ConfigureParams.Ethernet.bEthernetConnected && ConfigureParams.Ethernet.bTwistedPair) {
! 123: val &= ~BMAP_HEARTBEAT;
! 124: } else {
! 125: val |= BMAP_HEARTBEAT;
! 126: }
1.1 root 127: break;
128:
129: default:
130: val = NEXTbmap[bmap_reg];
131: break;
132: }
133:
134: return val;
135: }
136:
137: void bmap_put(uae_u32 bmap_reg, uae_u32 val) {
138: switch (bmap_reg) {
139: case BMAP_DATA_RW:
1.1.1.2 ! root 140: if ((val&BMAP_TPE) != (NEXTbmap[bmap_reg]&BMAP_TPE)) {
! 141: if ((val&BMAP_TPE)==BMAP_TPE) {
1.1 root 142: Log_Printf(LOG_WARN, "[BMAP] Switching to twisted pair ethernet.");
1.1.1.2 ! root 143: bmap_tpe_select = 1;
! 144: } else if ((val&BMAP_TPE)==0) {
1.1 root 145: Log_Printf(LOG_WARN, "[BMAP] Switching to thin ethernet.");
1.1.1.2 ! root 146: bmap_tpe_select = 0;
1.1 root 147: }
148: }
149: break;
150:
151: default:
152: break;
153: }
154:
155: NEXTbmap[bmap_reg] = val;
1.1.1.2 ! root 156: }
! 157:
! 158: void bmap_init(void) {
! 159: int i;
! 160:
! 161: for (i = 0; i < 16; i++) {
! 162: NEXTbmap[i] = 0;
! 163: }
! 164: bmap_tpe_select = 0;
! 165: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.