Subversion Repositories Kolibri OS

Rev

Rev 7140 | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                      ;;
  3. ;;                  16 BIT ENTRY FROM BOOTSECTOR                        ;;
  4. ;;                                                                      ;;
  5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6.  
  7. include 'macros.inc'
  8. include 'struct.inc'
  9. include 'lang.inc'
  10. include 'encoding.inc'
  11. include 'const.inc'
  12.  
  13. os_code = code_l - tmp_gdt
  14. PREBOOT_TIMEOUT = 5   ; seconds
  15.  
  16. use16
  17.                   org   0x0
  18.         jmp     start_of_code
  19.  
  20. if lang eq sp
  21. include "kernelsp.inc"  ; spanish kernel messages
  22. else if lang eq et
  23. version db    'Kolibri OS  versioon 0.7.7.0+    ',13,10,13,10,0
  24. else
  25. version db    'Kolibri OS  version 0.7.7.0+     ',13,10,13,10,0
  26. end if
  27.  
  28. include "boot/bootstr.inc"     ; language-independent boot messages
  29. include "boot/preboot.inc"
  30.  
  31. if lang eq ge
  32. include "boot/bootge.inc"     ; german system boot messages
  33. else if lang eq sp
  34. include "boot/bootsp.inc"     ; spanish system boot messages
  35. else if lang eq ru
  36. include "boot/bootru.inc"      ; russian system boot messages
  37. include "boot/ru.inc"          ; Russian font
  38. else if lang eq et
  39. include "boot/bootet.inc"      ; estonian system boot messages
  40. include "boot/et.inc"          ; Estonian font
  41. else
  42. include "boot/booten.inc"      ; english system boot messages
  43. end if
  44.  
  45. include "boot/bootcode.inc"    ; 16 bit system boot code
  46. include "bus/pci/pci16.inc"
  47. include "detect/biosdisk.inc"
  48.  
  49. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  50. ;;                                                                      ;;
  51. ;;                  SWITCH TO 32 BIT PROTECTED MODE                     ;;
  52. ;;                                                                      ;;
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54.  
  55.  
  56. ; CR0 Flags - Protected mode and Paging
  57.  
  58.         mov     ecx, CR0_PE+CR0_AM
  59.  
  60. ; Enabling 32 bit protected mode
  61.  
  62.         sidt    [cs:old_ints_h]
  63.  
  64.         cli                             ; disable all irqs
  65.         cld
  66.         mov     al, 255                 ; mask all irqs
  67.         out     0xa1, al
  68.         out     0x21, al
  69.    l.5:
  70.         in      al, 0x64                ; Enable A20
  71.         test    al, 2
  72.         jnz     l.5
  73.         mov     al, 0xD1
  74.         out     0x64, al
  75.    l.6:
  76.         in      al, 0x64
  77.         test    al, 2
  78.         jnz     l.6
  79.         mov     al, 0xDF
  80.         out     0x60, al
  81.    l.7:
  82.         in      al, 0x64
  83.         test    al, 2
  84.         jnz     l.7
  85.         mov     al, 0xFF
  86.         out     0x64, al
  87.  
  88.         lgdt    [cs:tmp_gdt]            ; Load GDT
  89.         mov     eax, cr0                ; protected mode
  90.         or      eax, ecx
  91.         and     eax, 10011111b *65536*256 + 0xffffff ; caching enabled
  92.         mov     cr0, eax
  93.         jmp     pword os_code:B32       ; jmp to enable 32 bit mode
  94.  
  95. align 8
  96. tmp_gdt:
  97.  
  98.         dw     23
  99.         dd     tmp_gdt+0x10000
  100.         dw     0
  101. code_l:
  102.         dw     0xffff
  103.         dw     0x0000
  104.         db     0x00
  105.         dw     11011111b *256 +10011010b
  106.         db     0x00
  107.  
  108.         dw     0xffff
  109.         dw     0x0000
  110.         db     0x00
  111.         dw     11011111b *256 +10010010b
  112.         db     0x00
  113.  
  114. include "data16.inc"
  115.  
  116. if ~ lang eq sp
  117. diff16 "end of bootcode",0,$+0x10000
  118. end if
  119.  
  120. use32
  121. org $+0x10000
  122.  
  123. align 4
  124. B32:
  125.