Rev 1 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 18 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | # on head 0, track 0, sector 2 of the first floppy drive (1440K). |
32 | # on head 0, track 0, sector 2 of the first floppy drive (1440K). |
33 | # Next kernel sectors follow on disk sector 3, 4, ... |
33 | # Next kernel sectors follow on disk sector 3, 4, ... |
34 | # |
34 | # |
35 | 35 | ||
36 | 36 | ||
- | 37 | # KERNEL_SIZE is passed from the outside to the preprocessor |
|
- | 38 | #if (KERNEL_SIZE%512>0) |
|
- | 39 | #define TAIL 1 |
|
- | 40 | #else |
|
- | 41 | #define TAIL 0 |
|
- | 42 | #endif |
|
- | 43 | ||
- | 44 | #define SECTORS (KERNEL_SIZE/512+TAIL) |
|
- | 45 | ||
37 | .text |
46 | .text |
38 | .global _start_0x7c00 |
47 | .global _start_0x7c00 |
39 | 48 | ||
40 | .code16 |
49 | .code16 |
41 | _start_0x7c00: |
50 | _start_0x7c00: |
42 | xorw %ax,%ax # reset, %al will be used below |
51 | xorw %ax,%ax # reset, %al will be used below |
43 | movw %ax,%dx # fd0, %dh and %dl will be used below |
52 | movw %ax,%dx # fd0, %dh and %dl will be used below |
44 | int $0x13 |
- | |
45 | jc stop_trying |
53 | movw %dx,%ds |
46 | 54 | ||
47 | movb $2,%ah # read |
- | |
48 | incb %al # one sector |
- | |
49 | movb %ah,%cl # from disk sector 2 |
55 | movw %dx,%ss # initialize stack |
50 | movw %dx,%es |
56 | movw $stack,%sp |
- | 57 | ||
51 | movw $0x8000,%bx # at %es:%bx |
58 | int $0x13 # reset floppy |
52 | int $0x13 |
- | |
53 | jc stop_trying |
59 | jc stop_trying |
54 | 60 | ||
55 | pushw $('.') |
- | |
56 | call echo_mark |
- | |
57 | add $2,%sp |
- | |
58 | - | ||
59 | movw %dx,%ds |
61 | movw %dx,%ds |
- | 62 | movw %dx,%ss |
|
- | 63 | movw $0x7c00,%sp |
|
- | 64 | movw $0xffe0,%si # after next increment, %si will become 0x0000 |
|
- | 65 | movw %si,%es |
|
- | 66 | movw $0x8000,%bx # at %es:%bx |
|
60 | 67 | ||
61 | # KERNEL_SIZE is passed from the outside to the preprocessor |
- | |
62 | movl $(KERNEL_SIZE),%edi |
68 | movl $(SECTORS),%edi |
63 | 69 | ||
64 | shrl $9,%edi # number of sectors that kernel occupies (%edi div 512) |
- | |
65 | - | ||
66 | read_next: |
70 | read_next: |
67 | test %edi,%edi |
71 | test %edi,%edi |
68 | jnz read_sectors |
72 | jnz read_sectors |
69 | 73 | ||
70 | movb $12,%al |
74 | movb $12,%al |
71 | movw $0x3f2,%dx |
75 | movw $0x3f2,%dx |
72 | outb %al,%dx |
76 | outb %al,%dx |
73 | 77 | ||
74 | pushw $('$') |
78 | movb $('$'),%al |
75 | call echo_mark |
79 | call echo_mark |
76 | add $2,%sp |
- | |
77 | 80 | ||
78 | jmpl $0,$0x8000 |
81 | jmpl $0,$0x8000 |
79 | 82 | ||
80 | read_sectors: |
83 | read_sectors: |
81 | pushw $('.') |
84 | movb $('.'),%al |
82 | call echo_mark |
85 | call echo_mark |
83 | add $2,%sp |
- | |
84 | 86 | ||
85 | decl %edi |
87 | decl %edi |
86 | incw logical_sector |
88 | incw logical_sector |
87 | movw %es,%si |
89 | movw %es,%si |
88 | addw $0x20,%si |
90 | addw $0x20,%si |
Line 102... | Line 104... | ||
102 | 104 | ||
103 | movw $0x0201,%ax |
105 | movw $0x0201,%ax |
104 | int $0x13 |
106 | int $0x13 |
105 | jnc read_next |
107 | jnc read_next |
106 | 108 | ||
107 | pushw $('R') |
109 | movb $('R'),%al |
108 | call echo_mark |
110 | call echo_mark |
109 | add $2,%sp |
- | |
110 | 111 | ||
111 | xorw %ax,%ax # try to reset |
112 | xorw %ax,%ax # try to reset |
112 | movw %ax,%dx # fd0 |
113 | movw %ax,%dx # fd0 |
113 | int $0x13 |
114 | int $0x13 |
114 | jnc read_next |
115 | jnc read_next |
115 | 116 | ||
116 | stop_trying: |
117 | stop_trying: |
117 | pushw $('F') |
118 | movb $('F'),%al |
118 | call echo_mark |
119 | call echo_mark |
119 | add $2,%sp |
- | |
120 | 120 | ||
121 | cli |
121 | cli |
122 | hlt |
122 | hlt |
123 | 123 | ||
124 | CH=4 |
124 | CH=4 |
125 | echo_mark: |
125 | echo_mark: |
126 | push %bp |
126 | push %bp |
127 | movw %sp,%bp |
127 | movw %sp,%bp |
128 | pusha |
128 | pusha |
129 | 129 | ||
130 | movw CH(%bp),%ax |
- | |
131 | movb $0xe,%ah |
130 | movb $0xe,%ah |
132 | movb $7,%bl |
131 | movb $7,%bl |
133 | int $0x10 |
132 | int $0x10 |
134 | 133 | ||
135 | popa |
134 | popa |
136 | pop %bp |
135 | pop %bp |
137 | ret |
136 | ret |
138 | 137 | ||
139 | # current logical sector from the beginning of the disk |
138 | # current logical sector from the beginning of the disk |
140 | logical_sector: |
139 | logical_sector: |
141 | .word 1 |
140 | .word 0 |
142 | 141 | ||
143 | # number of sectors per track on 1440 floppy |
142 | # number of sectors per track on 1440 floppy |
144 | sectors: |
143 | sectors: |
145 | .byte 18 |
144 | .byte 18 |
146 | 145 | ||
147 | - | ||
148 | # boot floppy signature |
146 | # boot floppy signature |
149 | .org 0x1fe |
147 | .org 0x1fe |
150 | boot_floppy_signature: |
148 | boot_floppy_signature: |
151 | .byte 0x55 |
149 | .byte 0x55 |
152 | .byte 0xaa |
150 | .byte 0xaa |
- | 151 | stack: |