1 ##*******************************************************************************
2 ## The first job of OS that load the bootsector of flopy is done here. *
3 ## Nothing speciall here,BIOS will auto load the first sector called *
5 ## bootsector, and then the loaded sector will load our OS kernel that *
6 ## just behined the bootsector at address 0x10000. *
8 ## After that's been done, we move the kernel again to physic address *
9 ## 0x0000, the start address of memory, 'cause we don't need BIOS any more. *
10 ## But that's a litter unsafe, we haven't finished our interrupt handler *
11 ## yet. But this will be done just later, and now we just block all of the *
12 ## interrupts by cli. Wish GOD bless us. :) *
14 ## And will move the GDT base to specified address,too. *
15 ## After that's all been done, it's the time switch into PM now. *
16 ## We do it first by enable A20 line, so that we call access lagre memory *
17 ## here is 4G. Then load GDT structer, set the PM flag of CR0 register, and *
18 ## last do a far jump to Protect Mode. *
20 ## Copyright (C) 2007-2008 Aleaxander *
21 ## Email: Aleaxander@gmail.com *
22 ##*******************************************************************************
30 .quad 0x0000000000000000 # null descriptor
31 .quad 0x00cf9a000000ffff # cs
32 .quad 0x00cf92000000ffff # ds
33 .quad 0x0000000000000000 # sys
34 .quad 0x0000000000000000 # reserved for tss0
35 .quad 0x0000000000000000 # reserved for ldt0
36 .quad 0x0000000000000000 # reserved for tss1
37 .quad 0x0000000000000000 # reserved for ldt1
38 .quad 0x0000000000000000 # reserved for tss2
39 .quad 0x0000000000000000 # reserved for ldt2
46 movw
%ax
, %ds
# ds = 0x0000
47 movw
%ax
, %ss
# stack segment = 0x0000
48 movw $
0x1000,%sp
# arbitrary value
51 ## read rest of kernel to 0x10000
54 xorw
%bx
, %bx
# es:bs destination address
56 movw $
1, %si
# 0 is boot sector
65 ## move first 512 bytes of kernel to 0x0000
66 ## it will move rest of kernel to 0x0200,
67 ## that is, next to this sector
82 movw
%ax
, %ds
# reset ds to 0x0000
110 ## in: ax: LBA address, starts from 0
111 ## es:bx address for reading sector
120 movw $
18, %bx
# 18 sectors per track
124 movb
%dl
, %cl
# cl=sector number
126 movw $
2, %bx
# 2 headers per track
131 xorb
%dl
, %dl
# driver
132 movb
%al
, %ch
# cylinder
133 popw
%bx
# save to es:bx
135 movb $
0x1, %al
# read 1 sector
145 .word 0xaa55 # bootsector flag