VirtualBox

Changeset 5196 in vbox for trunk/src/VBox/Devices/PC/BIOS


Ignore:
Timestamp:
Oct 9, 2007 11:39:06 AM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25123
Message:

Implemented INT 15h/89h (switch to protected mode). Used by AIX 1.3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/BIOS/rombios.c

    r4449 r5196  
    37323732  Bit8u   base23_16;
    37333733  Bit16u  ss;
    3734   Bit16u  CX,DX;
     3734  Bit16u  BX,CX,DX;
    37353735
    37363736  Bit16u bRegister;
     
    39993999#endif
    40004000      break;
     4001
     4002#ifdef VBOX
     4003  case 0x89:
     4004    // Switch to Protected Mode.
     4005    // ES:DI points to user-supplied GDT
     4006    // BH/BL contains starting interrupt numbers for PIC0/PIC1
     4007    // This subfunction does not return!
     4008
     4009// turn off interrupts
     4010ASM_START
     4011  cli
     4012ASM_END
     4013
     4014      set_enable_a20(1); // enable A20 line; we're supposed to fail if that fails
     4015
     4016      // Initialize CS descriptor for BIOS
     4017      write_word(ES, regs.u.r16.si+0x38+0, 0xffff);// limit 15:00 = normal 64K limit
     4018      write_word(ES, regs.u.r16.si+0x38+2, 0x0000);// base 15:00
     4019      write_byte(ES, regs.u.r16.si+0x38+4, 0x000f);// base 23:16 (hardcoded to f000:0000)
     4020      write_byte(ES, regs.u.r16.si+0x38+5, 0x9b);  // access
     4021      write_word(ES, regs.u.r16.si+0x38+6, 0x0000);// base 31:24/reserved/limit 19:16
     4022
     4023      BX = regs.u.r16.bx;
     4024ASM_START
     4025      // Compiler generates locals offset info relative to SP.
     4026      // Get BX (PIC offsets) from stack.
     4027      mov  bx, sp
     4028      SEG SS
     4029        mov  bx, _int15_function.BX [bx]
     4030
     4031      // Program PICs
     4032      mov al, #0x11 ; send initialisation commands
     4033      out 0x20, al
     4034      out 0xa0, al
     4035      mov al, bh
     4036      out 0x21, al
     4037      mov al, bl
     4038      out 0xa1, al
     4039      mov al, #0x04
     4040      out 0x21, al
     4041      mov al, #0x02
     4042      out 0xa1, al
     4043      mov al, #0x01
     4044      out 0x21, al
     4045      out 0xa1, al
     4046      mov  al, #0xff ; mask all IRQs, user must re-enable
     4047      out  0x21, al
     4048      out  0xa1, al
     4049
     4050      // Load GDT and IDT from supplied data
     4051      SEG ES
     4052        lgdt [si + 0x08]
     4053      SEG ES
     4054        lidt [si + 0x10]
     4055
     4056      // set PE bit in CR0
     4057      mov  eax, cr0
     4058      or   al, #0x01
     4059      mov  cr0, eax
     4060      // far jump to flush CPU queue after transition to protected mode
     4061      JMP_AP(0x0038, protmode_switch)
     4062
     4063protmode_switch:
     4064      ;; GDT points to valid descriptor table, now load SS, DS, ES
     4065      mov  ax, #0x28
     4066      mov  ss, ax
     4067      mov  ax, #0x18
     4068      mov  ds, ax
     4069      mov  ax, #0x20
     4070      mov  es, ax
     4071
     4072      // unwind the stack - this will break if calling sequence changes!
     4073      mov   sp,bp
     4074      add   sp,#4   ; skip return address
     4075      popa          ; restore regs
     4076      pop   ax      ; skip saved es
     4077      pop   ax      ; skip saved ds
     4078      pop   ax      ; skip saved flags
     4079
     4080      // return to caller - note that we do not use IRET because
     4081      // we cannot enable interrupts
     4082      pop   cx          ; get return offset
     4083      pop   ax          ; skip return segment
     4084      pop   ax          ; skip flags
     4085      mov   ax, #0x30   ; ah must be 0 on successful exit
     4086      push  ax
     4087      push  cx          ; re-create modified ret address on stack
     4088      retf
     4089
     4090ASM_END
     4091
     4092      break;
     4093#endif
    40014094
    40024095    case 0x90:
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette