--- //depot/vendor/freebsd/src/sys/boot/i386/btx/btx/btx.S 2008/03/10 21:45:25 +++ //depot/user/jhb/boot/sys/boot/i386/btx/btx/btx.S 2008/05/23 19:58:47 @@ -34,6 +34,12 @@ .set PAG_SIZ,0x1000 # Page size .set PAG_CNT,0x1000 # Pages to map /* + * Fields in %eflags. + */ + .set PSL_T,0x00000100 # Trap flag + .set PSL_I,0x00000200 # Interrupt enable flag + .set PSL_VM,0x00020000 # Virtual 8086 mode flag +/* * Segment selectors. */ .set SEL_SCODE,0x8 # Supervisor code @@ -54,6 +60,7 @@ */ .set SYS_EXIT,0x0 # Exit .set SYS_EXEC,0x1 # Exec + .set SYS_PANIC,0x1 # Panic /* * Fields in V86 interface structure. */ @@ -369,7 +376,7 @@ je except.3 # Yes cmpb $0x1,(%esp,1) # Debug? jne except.2a # No - testl $0x100,0x10(%esp,1) # Trap flag set? + testl $PSL_T,0x10(%esp,1) # Trap flag set? jnz except.3 # Yes except.2a: jmp exit # Exit except.3: leal 0x8(%esp,1),%esp # Discard err, int no @@ -460,7 +467,17 @@ pushl %ds # address popl %es # data leal 0x44(%esp,1),%esi # Base of frame - movl -0x14(%esi),%eax # Get Int no + testl $PSL_I,-0x08(%esi) # Are interrupts enabled? + jnz intusr.1 # Yes + movl $clivm86,%esi # Display bad + call putstr # VM86 call + popl %es # Restore + popl %ds # seg + popl %fs # regs + popl %gs + popal # Restore gp regs + jmp ex_noc # Panic +intusr.1: movl -0x14(%esi),%eax # Get Int no cmpl $-1,%eax # Hardware interrupt? jne intusr.2 # Yes /* @@ -491,7 +508,7 @@ movl %edx,-0x40(%esi) # Real mode %ds of 0 movl %edx,-0x44(%esi) # Real mode %es of 0 movl -0x08(%esi),%ebx # Pass user flags with - andl $~0x200,%ebx # interrupts disabled + andl $~PSL_I,%ebx # interrupts disabled movw %bx,MEM_ESPR-0x12 # to real mode target /* * %eax now holds either the interrupt number or segment:offset of function. @@ -667,8 +684,12 @@ leal 0x4(%eax),%esp # stack popl %eax # Call call *%eax # program -intx30.1: orb $0x1,%ss:btx_hdr+0x7 # Flag reboot +intx30.1: cmpl $SYS_EXIT,%eax # Exit system call? + jne intx30.2 # No + orb $0x1,%ss:btx_hdr+0x7 # Flag reboot jmp exit # Exit +intx30.2: pushl $0x30 # Interrupt Number + jmp ex_noc # Panic /* * Dump structure [EBX] to [EDI], using format string [ESI]. */ @@ -696,7 +717,7 @@ dump.2: testb $DMP_MEM,%ch # Dump memory? jz dump.8 # No pushl %ds # Save - testb $0x2,0x52(%ebx) # V86 mode? + testl $PSL_VM,0x50(%ebx) # V86 mode? jnz dump.3 # Yes verr 0x4(%esi) # Readable selector? jnz dump.3 # No @@ -1028,6 +1049,7 @@ * Bad VM86 call panic */ badvm86: .asciz "Invalid VM86 Request\n" +clivm86: .asciz "VM86 Request with interrupts disabled\n" /* * End of BTX memory. --- //depot/vendor/freebsd/src/sys/boot/i386/btx/lib/btxsys.s 2001/07/17 07:17:28 +++ //depot/user/jhb/boot/sys/boot/i386/btx/lib/btxsys.s 2008/05/23 19:58:47 @@ -24,6 +24,7 @@ # .global __exit .global __exec + .global __panic # # Constants. # @@ -38,3 +39,8 @@ # __exec: movl $0x1,%eax # BTX system int $INT_SYS # call 0x1 +# +# System call: panic +# +__panic: movl $0x2,%eax # BTX system + int $INT_SYS # call 0x2 --- //depot/vendor/freebsd/src/sys/boot/i386/btx/lib/btxv86.s 2001/07/17 07:17:28 +++ //depot/user/jhb/boot/sys/boot/i386/btx/lib/btxv86.s 2008/05/23 19:58:47 @@ -55,6 +55,11 @@ call __v86_swap # Load user registers addl $0x4,%esp # Discard pointer pushl __v86ret # Restore return address + pushfl # Push flags + testl $0x200,(%esp,1) # Interrupts enabled? + jnz 1f # Yes + call __panic # Panic otherwise +1: popfl # Restore flags ret # To user # # Swap V86 and user registers.