--- head-2.2.16.S Fri Jan 15 16:57:25 1999 +++ head.S Sat Feb 16 19:09:00 2002 @@ -84,8 +84,20 @@ #ifdef __SMP__ orw %bx,%bx jz 1f /* Initial CPU cleans BSS */ + +/* + * If Open Firmware is running, leave the eflags register as-is so + * Open Firmware's debugger can step through the startup code. + * The kernel will run under Open Firmware without this modification, + * but the debugger won't work. + */ + movl $CL_BASE_ADDR,%ebp + cmpl $0x2057464F, 0x7f0(%ebp) /* Magic number "OFW " */ + je 2f + pushl $0 popfl +2: jmp checkCPUtype 1: #endif __SMP__ @@ -104,6 +116,17 @@ * in 16-bit mode for the "real" operations. */ call setup_idt + +/* + * If Open Firmware is running, leave the eflags register as-is so + * Open Firmware's debugger can step through the startup code. + * The kernel will run under Open Firmware without this modification, + * but the debugger won't work. + */ + movl $CL_BASE_ADDR,%ebp + cmpl $0x2057464F, 0x7fc(%ebp) /* Magic number "OFW " */ + je 1f + /* * Initialize eflags. Some BIOS's leave bits like NT set. This would * confuse the debugger if this code is traced. @@ -111,6 +134,8 @@ */ pushl $0 popfl +1: + /* * Copy bootup parameters out of the way. First 2kB of * _empty_zero_page is for boot parameters, second 2kB @@ -294,6 +319,32 @@ addl $8,%edi dec %ecx jne rp_sidt + + /* + * If Open Firmware loaded us, incorporate its handlers for + * vectors 1 (debugger) and 3 (breakpoint) into our new trap table. + */ + + movl $CL_BASE_ADDR,%ebp + cmpl $0x2057464F, 0x7fc(%ebp) /* Magic number "OFW " */ + jne 1f + + movl 0x7f4(%ebp),%ebp /* IDT address */ + lea SYMBOL_NAME(idt_table),%edi + + /* Vector 1 - debugger */ + movl 8(%ebp),%eax + movl %eax,8(%edi) + movl 0xc(%ebp),%eax + movl %eax,0xc(%edi) + + /* Vector 3 - breakpoint */ + movl 0x18(%ebp),%eax + movl %eax,0x18(%edi) + movl 0x1c(%ebp),%eax + movl %eax,0x1c(%edi) +1: + ret ENTRY(stack_start) --- traps-2.2.16.c Thu Jun 8 07:26:42 2000 +++ traps.c Sat Feb 16 19:09:00 2002 @@ -682,9 +682,18 @@ EISA_bus = 1; set_call_gate(&default_ldt,lcall7); set_trap_gate(0,÷_error); - set_trap_gate(1,&debug); - set_trap_gate(2,&nmi); - set_system_gate(3,&int3); /* int3-5 can be called from all */ + +#define PARAM ((unsigned char *)empty_zero_page) +#define OFW_SIGNATURE (*(unsigned long *) (PARAM+0x7fc)) + /* Leave Open Firmware's debugger active if its signature is present */ + if (OFW_SIGNATURE == 0x2057464F) { /* Magic number "OFW " */ + set_trap_gate(2,&nmi); + } else { + set_trap_gate(1,&debug); + set_trap_gate(2,&nmi); + set_system_gate(3,&int3); /* int3-5 can be called from all */ + } + set_system_gate(4,&overflow); set_system_gate(5,&bounds); set_trap_gate(6,&invalid_op);