Subversion Repositories Kolibri OS

Rev

Rev 9249 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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