diff --git a/reactos/lib/ppcmmu/devint.s b/reactos/lib/ppcmmu/devint.s index 77106204334..5ed65b4d501 100644 --- a/reactos/lib/ppcmmu/devint.s +++ b/reactos/lib/ppcmmu/devint.s @@ -5,61 +5,60 @@ mmumain: mr 0,1 lis 1,2 - subi 1,1,432 - stw 0,4(1) - stw 2,8(1) - stw 3,12(1) - stw 4,16(1) - stw 5,20(1) - stw 6,24(1) - stw 7,28(1) - stw 8,32(1) - stw 9,36(1) - stw 10,40(1) - stw 11,44(1) - stw 12,48(1) - stw 13,52(1) - stw 14,56(1) - stw 15,60(1) - stw 16,64(1) - stw 17,68(1) - stw 18,72(1) - stw 19,76(1) - stw 20,80(1) - stw 21,84(1) - stw 22,88(1) - stw 23,92(1) - stw 24,96(1) - stw 25,100(1) - stw 26,104(1) - stw 27,108(1) - stw 28,112(1) - stw 29,116(1) - stw 30,120(1) - stw 31,124(1) - mflr 0 - stw 0,384(1) - mfmsr 0 - stw 0,388(1) - mfcr 0 - stw 0,392(1) - mflr 0 - stw 0,396(1) - mfctr 0 + subi 1,1,448 + stw 0,20(1) + stw 2,24(1) + stw 3,28(1) + stw 4,32(1) + stw 5,36(1) + stw 6,40(1) + stw 7,44(1) + stw 8,48(1) + stw 9,52(1) + stw 10,56(1) + stw 11,60(1) + stw 12,64(1) + stw 13,68(1) + stw 14,72(1) + stw 15,76(1) + stw 16,80(1) + stw 17,84(1) + stw 18,88(1) + stw 19,92(1) + stw 20,96(1) + stw 21,100(1) + stw 22,104(1) + stw 23,108(1) + stw 24,112(1) + stw 25,116(1) + stw 26,120(1) + stw 27,124(1) + stw 28,128(1) + stw 29,132(1) + stw 30,136(1) + stw 31,140(1) + mfsrr0 0 stw 0,400(1) - mfxer 0 + mfmsr 0 stw 0,404(1) - xor 0,0,0 + mfcr 0 stw 0,408(1) - mfdsisr 0 + mflr 0 stw 0,412(1) + mfctr 0 + stw 0,416(1) + mfxer 0 + stw 0,420(1) + /* xor 0,0,0 -- We can omit this since PPC doesn't have MQ */ + stw 0,424(1) + mfdsisr 0 + stw 0,428(1) mfdar 0 - stw 0,416(1) - mr 7,1 + stw 0,432(1) + addi 7,1,16 lis 8,_mmumain@ha addi 8,8,_mmumain@l mtctr 8 - subi 1,1,16 bctrl addi 1,1,16 lwz 2,8(1) @@ -98,7 +97,9 @@ mmumain: mtlr 0 lwz 0,400(1) mtctr 0 + lwz 0,388(1) /* Copy out new MSR bits if needed */ lwz 1,4(1) + mtmsr 0 blr .globl trap_start @@ -106,68 +107,67 @@ mmumain: trap_start: mtsprg1 1 lis 1,2 - subi 1,1,432 - stw 0,0(1) + subi 1,1,448 + stw 0,16(1) mfsprg1 0 - stw 0,4(1) - stw 2,8(1) - stw 3,12(1) - stw 4,16(1) - stw 5,20(1) - stw 6,24(1) - stw 7,28(1) - stw 8,32(1) - stw 9,36(1) - stw 10,40(1) - stw 11,44(1) - stw 12,48(1) - stw 13,52(1) - stw 14,56(1) - stw 15,60(1) - stw 16,64(1) - stw 17,68(1) - stw 18,72(1) - stw 19,76(1) - stw 20,80(1) - stw 21,84(1) - stw 22,88(1) - stw 23,92(1) - stw 24,96(1) - stw 25,100(1) - stw 26,104(1) - stw 27,108(1) - stw 28,112(1) - stw 29,116(1) - stw 30,120(1) - stw 31,124(1) + stw 0,20(1) + stw 2,24(1) + stw 3,28(1) + stw 4,32(1) + stw 5,36(1) + stw 6,40(1) + stw 7,44(1) + stw 8,48(1) + stw 9,52(1) + stw 10,56(1) + stw 11,60(1) + stw 12,64(1) + stw 13,68(1) + stw 14,72(1) + stw 15,76(1) + stw 16,80(1) + stw 17,84(1) + stw 18,88(1) + stw 19,92(1) + stw 20,96(1) + stw 21,100(1) + stw 22,104(1) + stw 23,108(1) + stw 24,112(1) + stw 25,116(1) + stw 26,120(1) + stw 27,124(1) + stw 28,128(1) + stw 29,132(1) + stw 30,136(1) + stw 31,140(1) mfsrr0 0 - stw 0,384(1) - mfsrr1 0 - stw 0,388(1) - mfcr 0 - stw 0,392(1) - mflr 0 - stw 0,396(1) - mfctr 0 stw 0,400(1) - mfxer 0 + mfsrr1 0 stw 0,404(1) - xor 0,0,0 + mfcr 0 stw 0,408(1) - mfdsisr 0 + mflr 0 stw 0,412(1) + mfctr 0 + stw 0,416(1) + mfxer 0 + stw 0,420(1) + /* xor 0,0,0 -- We can omit this since PPC doesn't have MQ */ + stw 0,424(1) + mfdsisr 0 + stw 0,428(1) mfdar 0 - stw 0,416(1) + stw 0,432(1) bl 1f 1: mflr 5 - mr 4,1 + addi 4,1,16 rlwinm 3,5,24,0xff lwz 5,36(5) mtctr 5 lis 5,trap_finish_start@ha addi 5,5,trap_finish_start@l mtlr 5 - subi 1,1,16 bctr trap_end: .space 4 diff --git a/reactos/lib/ppcmmu/gdblib.c b/reactos/lib/ppcmmu/gdblib.c index 7a2d7189064..5a423db6ceb 100644 --- a/reactos/lib/ppcmmu/gdblib.c +++ b/reactos/lib/ppcmmu/gdblib.c @@ -31,6 +31,7 @@ * * Modified for 386 by Jim Kingdon, Cygnus Support. * Modified for ReactOS by Casper S. Hornstrup + * Modified heavily for PowerPC ReactOS by arty * * To enable debugger support, two things need to happen. One, setting * up a routine so that it is in the exception path, is necessary in order @@ -127,12 +128,12 @@ int isxdigit(int ch) (ch >= '0' && ch <= '9'); } -void sync() { +inline void sync() { __asm__("eieio\n\t" "sync"); } -void send(char *serport, char c) { +inline void send(char *serport, char c) { /* Wait for Clear to Send */ while( !(serport[LSR] & 0x20) ) sync(); @@ -140,16 +141,22 @@ void send(char *serport, char c) { sync(); } -int rdy(char *serport) +inline int rdy(char *serport) { sync(); return (serport[LSR] & 0x20); } -char recv(char *serport) { +inline int chr(char *serport) +{ + sync(); + return serport[LSR] & 1; +} + +inline char recv(char *serport) { char c; - while( !(serport[LSR] & 1) ) sync(); + while( !chr(serport) ) sync(); c = serport[RCV]; sync(); @@ -167,8 +174,6 @@ void setup(char *serport, int baud) { sync(); serport[LCR] = 3; sync(); - serport[IER] = 1; - sync(); } void SerialSetUp(int deviceType, void *deviceAddr, int baud) @@ -178,11 +183,11 @@ void SerialSetUp(int deviceType, void *deviceAddr, int baud) setup(serport, baud); } -extern void SerialInterrupt(); +extern int SerialInterrupt(int signal, ppc_trap_frame_t *tf); -void Wait() +void IntEnable() { - while(!Continue) if (rdy(serport)) SerialInterrupt(); + serport[IER] |= 1; } void SerialWrite(int ch) @@ -240,22 +245,44 @@ void PacketStart() void PacketFinish() { - int i, ch; + int i, ch, count = 0; PacketSent = 0; do { - SerialWrite('$'); - for (i = 0; i < DataOutAddr; i++) - { - SerialWrite(DataOutBuffer[i]); + if (!count) + { + SerialWrite('$'); + for (i = 0; i < DataOutAddr; i++) + { + SerialWrite(DataOutBuffer[i]); + } + SerialWrite('#'); + SerialWrite(hex[(DataOutCsum >> 4) & 15]); + SerialWrite(hex[DataOutCsum & 15]); } - SerialWrite('#'); - SerialWrite(hex[(DataOutCsum >> 4) & 15]); - SerialWrite(hex[DataOutCsum & 15]); + while(count-- != 0) + { + if (chr(serport)) + { + ch = SerialRead(); + break; + } + } + + switch (ch) + { + default: + break; - while(!rdy(serport)); - if (SerialRead() == '+') break; + case '-': + count = 0; + break; + + case '+': + PacketSent = 1; + break; + } } while(PacketSent != 1); } @@ -293,10 +320,13 @@ void PacketWriteError(int code) PacketFinish(); } +void marker() { } + void GotPacket() { int i, memaddr, memsize; - + + Continue = 0; switch (DataInBuffer[DataInAddr++]) { case 'g': @@ -349,10 +379,16 @@ void GotPacket() Continue = 1; break; + case 'S': + PacketOk(); + Continue = 0; + break; + case 's': - RegisterSaveArea->srr1 |= 16; + RegisterSaveArea->srr1 |= 0x400; PacketOk(); Continue = 1; + marker(); break; case 'q': @@ -374,59 +410,74 @@ void GotPacket() } } -void SerialInterrupt() +int SerialInterrupt(int signal, ppc_trap_frame_t *tf) { - int ch = SerialRead(); + int ch; - if (ch == '+') + if (!chr(serport)) return 0; + + Signal = signal; + RegisterSaveArea = tf; + + do { - PacketSent = 1; - } - else if (ch == '-') - { - PacketSent = -1; - } - else if (ch == '$') - { - DataInAddr = 0; - ParseState = 0; - ComputedCsum = 0; - ActualCsum = 0; - } - else if (ch == '#' && ParseState == 0) - { - ParseState = 2; - } - else if (ParseState == 0) - { - ComputedCsum += ch; - DataInBuffer[DataInAddr++] = ch; - } - else if (ParseState == 2) - { - ActualCsum = ch; - ParseState++; - } - else if (ParseState == 3) - { - ActualCsum = hex2int(ch) | (hex2int(ActualCsum) << 4); - ComputedCsum &= 255; - ParseState = -1; - if (ComputedCsum == ActualCsum) + ch = SerialRead(); + + if (ch == 3) /* Break in - tehe */ { - ComputedCsum = 0; - DataInBuffer[DataInAddr] = 0; - DataInAddr = 0; Continue = 0; - SerialWrite('+'); - GotPacket(); + PacketWriteSignal(3); } - else + else if (ch == '-' || ch == '+') + { + /* Nothing */ + } + else if (ch == '$') + { + DataInAddr = 0; + ParseState = 0; + ComputedCsum = 0; + ActualCsum = 0; + } + else if (ch == '#' && ParseState == 0) + { + ParseState = 2; + } + else if (ParseState == 0) + { + ComputedCsum += ch; + DataInBuffer[DataInAddr++] = ch; + } + else if (ParseState == 2) + { + ActualCsum = ch; + ParseState++; + } + else if (ParseState == 3) + { + ActualCsum = hex2int(ch) | (hex2int(ActualCsum) << 4); + ComputedCsum &= 255; + ParseState = -1; + if (ComputedCsum == ActualCsum) + { + ComputedCsum = 0; + DataInBuffer[DataInAddr] = 0; + DataInAddr = 0; + Continue = 0; + SerialWrite('+'); + GotPacket(); + } + else + SerialWrite('-'); + } + else if (ParseState == -1) SerialWrite('-'); } + while (!Continue); + return 1; } -void TakeException(int n, int *tf) +int TakeException(int n, ppc_trap_frame_t *tf) { Signal = n; RegisterSaveArea = tf; @@ -434,7 +485,8 @@ void TakeException(int n, int *tf) PacketWriteSignal(Signal); SendSignal = 0; Continue = 0; - Wait(); + while(!Continue) SerialInterrupt(n, tf); + return 1; } /* EOF */ diff --git a/reactos/lib/ppcmmu/mmuobject.c b/reactos/lib/ppcmmu/mmuobject.c index 9b5c5d7b41c..cc8ab4c4535 100644 --- a/reactos/lib/ppcmmu/mmuobject.c +++ b/reactos/lib/ppcmmu/mmuobject.c @@ -68,7 +68,8 @@ MmuVsidInfo *Segs[16], *VsidHead = 0; extern void fmtout(const char *fmt, ...); int ptegreload(ppc_trap_frame_t *frame, vaddr_t addr); void SerialSetUp(int deviceType, void *deviceAddr, int baud); -void TakeException(int n, int *tf); +int SerialInterrupt(int n, ppc_trap_frame_t *tf); +void TakeException(int n, ppc_trap_frame_t *tf); int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf) { @@ -83,36 +84,42 @@ int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf) if(!ptegreload(trap_frame, trap_frame->dar)) { __asm__("mfmsr 3\n\tori 3,3,0x30\n\tmtmsr 3\n\t"); - if (!callback[action](action,tf)) hang(action, tf); + if (!callback[action](action,trap_frame)) hang(action, trap_frame); } break; case 4: if(!ptegreload(trap_frame, trap_frame->srr0)) { __asm__("mfmsr 3\n\tori 3,3,0x30\n\tmtmsr 3\n\t"); - if (!callback[action](action,tf)) hang(action, tf); + if (!callback[action](action,trap_frame)) hang(action, trap_frame); } break; + case 5: + /* EE -- Try to get a serial interrupt if debugging enabled, then fall + * back to primary handler + */ + if (!SerialInterrupt(action, trap_frame)) + callback[action](action, trap_frame); + else + trap_frame->srr1 |= 0x8000; + break; case 0: case 2: - case 5: case 6: case 7: case 8: case 9: case 0xa: - if (!callback[action](action,tf)) hang(action, tf); - break; - + case 0xc: case 0x20: - // Single step - TakeException(action, tf); + if (!callback[action](action,trap_frame)) hang(action, trap_frame); break; /* MMU Functions */ case 0x100: initme(); + trap_frame->srr1 |= 0x8000; break; case 0x101: ret = mmuaddpage(arg1, (int)arg2); @@ -161,7 +168,7 @@ int _mmumain(int action, void *arg1, void *arg2, void *arg3, void *tf) SerialSetUp((int)arg1, arg2, 9600); break; case 0x201: - TakeException((int)arg1, (int *)trap_frame); + TakeException((int)arg1, trap_frame); break; default: @@ -251,7 +258,7 @@ int hang(int trapCode, ppc_trap_frame_t *trap) GdbAttach = 1; SerialSetUp(0, (void *)0x800003f8, 9600); } - TakeException(trapCode, (int *)trap); + while(1) SerialInterrupt(trapCode, trap); return 1; } @@ -294,11 +301,17 @@ void initme() copy_trap_handler(i); } + /* Serial Interrupt */ + callback[5] = SerialInterrupt; + /* Floating point exception */ callback[8] = fpenable; /* Ignore decrementer and EE */ callback[9] = ignore; + + /* Single Step */ + callback[0x20] = TakeException; } ppc_map_t *allocpage()