kernel: mon_return cleanup

cleanup of boot monitor related code.
This commit is contained in:
Ben Gras
2012-04-25 17:44:55 +02:00
parent c662389d25
commit b41df2eb0d
10 changed files with 8 additions and 213 deletions

View File

@@ -16,120 +16,6 @@
* kernel.
*/
/*
* The routines only guarantee to preserve the registers the C compiler
* expects to be preserved (ebx, esi, edi, ebp, esp, segment registers, and
* direction bit in the flags).
*/
/*===========================================================================*/
/* monitor */
/*===========================================================================*/
/* PUBLIC void monitor(); */
/* exit Minix and return to the monitor */
ENTRY(monitor)
movl _C_LABEL(mon_sp), %esp /* restore monitor stack pointer */
movw $SS_SELECTOR, %dx /* monitor data segment */
mov %dx, %ds
mov %dx, %es
mov %dx, %fs
mov %dx, %gs
mov %dx, %ss
pop %edi
pop %esi
pop %ebp
lretw /* return to the monitor */
/*===========================================================================*/
/* int86 */
/*===========================================================================*/
/* PUBLIC void int86(); */
/* let the monitor make an 8086 interrupt call */
ENTRY(int86)
cmpb $0, _C_LABEL(mon_return) /* is the monitor there? */
jne 0f
movb $0x01, %ah /* an int 13 error seems appropriate */
movb %ah, _C_LABEL(reg86)+0 /* reg86.w.f = 1 (set carry flag) */
movb %ah, _C_LABEL(reg86)+13 /* reg86.b.ah = 0x01 = "invalid command" */
ret
0:
push %ebp /* save C registers */
push %esi
push %edi
push %ebx
pushf /* save flags */
cli /* no interruptions */
inb $INT2_CTLMASK
movb %al, %ah
inb $INT_CTLMASK
push %eax /* save interrupt masks */
movl _C_LABEL(irq_use), %eax /* map of in-use IRQ's */
and $~(1<<CLOCK_IRQ), %eax /* keep the clock ticking */
outb $INT_CTLMASK /* enable all unused IRQ's and vv. */
movb %ah, %al
outb $INT2_CTLMASK
mov $SS_SELECTOR, %eax /* monitor data segment */
mov %ax, %ss
xchgl _C_LABEL(mon_sp), %esp /* switch stacks */
push _C_LABEL(reg86)+36 /* parameters used in INT call */
push _C_LABEL(reg86)+32
push _C_LABEL(reg86)+28
push _C_LABEL(reg86)+24
push _C_LABEL(reg86)+20
push _C_LABEL(reg86)+16
push _C_LABEL(reg86)+12
push _C_LABEL(reg86)+8
push _C_LABEL(reg86)+4
push _C_LABEL(reg86)+0
mov %ax, %ds /* remaining data selectors */
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
push %cs
push $return /* kernel return address and selector */
ljmpw *20+2*4+10*4+2*4(%esp)
return:
pop _C_LABEL(reg86)+0
pop _C_LABEL(reg86)+4
pop _C_LABEL(reg86)+8
pop _C_LABEL(reg86)+12
pop _C_LABEL(reg86)+16
pop _C_LABEL(reg86)+20
pop _C_LABEL(reg86)+24
pop _C_LABEL(reg86)+28
pop _C_LABEL(reg86)+32
pop _C_LABEL(reg86)+36
lgdt _C_LABEL(gdt)+GDT_SELECTOR /* reload global descriptor table */
ljmp $CS_SELECTOR, $csinit
csinit:
mov $DS_SELECTOR, %eax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
mov %ax, %ss
xchgl _C_LABEL(mon_sp), %esp /* unswitch stacks */
lidt _C_LABEL(gdt)+IDT_SELECTOR /* reload interrupt descriptor table */
pop %eax
outb $INT_CTLMASK /* restore interrupt masks */
movb %ah, %al
outb $INT2_CTLMASK
6:
addl %ecx, _C_LABEL(lost_ticks) /* record lost clock ticks */
popf /* restore flags */
pop %ebx /* restore C registers */
pop %edi
pop %esi
pop %ebp
ret
ENTRY(__main)
ret