Mercurial > ecos-v3_0-branch
comparison packages/hal/i386/pc/current/include/platform.inc @ 134:d2f49caf9e38 ecos-sw-2000-11-03
Merge from eCos master repository on 2000-11-03-09:00:49-GMT
| author | jlarmour |
|---|---|
| date | Fri, 03 Nov 2000 21:17:40 +0000 |
| parents | 6ed91473a1cd |
| children | ac086aa3217e |
comparison
equal
deleted
inserted
replaced
| 133:98d71f4d8243 | 134:d2f49caf9e38 |
|---|---|
| 63 | 63 |
| 64 .extern _end | 64 .extern _end |
| 65 | 65 |
| 66 sectorsPerTrack = 18 | 66 sectorsPerTrack = 18 |
| 67 bytesPerSector = 512 | 67 bytesPerSector = 512 |
| 68 bytesPerTrack = sectorsPerTrack * bytesPerSector | 68 esPerSector = 32 /* = 512/16 */ |
| 69 dptLength = 3 /* words. */ | |
| 70 | 69 |
| 71 cld /* always count up. */ | 70 cld /* always count up. */ |
| 72 | 71 |
| 73 /* Configure a stack that we can use. */ | 72 /* Configure a stack that we can use. */ |
| 74 | 73 |
| 76 movw %ax, %sp | 75 movw %ax, %sp |
| 77 shr $4, %eax | 76 shr $4, %eax |
| 78 andl $0xF000, %eax | 77 andl $0xF000, %eax |
| 79 movw %ax, %ss | 78 movw %ax, %ss |
| 80 | 79 |
| 81 /* Ask the BIOS for info about the amount of RAM available. We push these | 80 /* Ask the BIOS for info about the amount of RAM available. We push |
| 82 onto the stack for later use. | 81 * these onto the stack for later use. |
| 83 */ | 82 */ |
| 84 | 83 |
| 85 xorl %eax, %eax | 84 xorl %eax, %eax |
| 86 movb $0x88, %ah /* Get the amount of extended memory. */ | 85 movb $0x88, %ah /* Get the amount of extended memory. */ |
| 87 int $0x15 | 86 int $0x15 |
| 88 shl $10, %eax | 87 shl $10, %eax |
| 91 xorl %eax, %eax | 90 xorl %eax, %eax |
| 92 int $0x12 /* Get the amount of standard memory. */ | 91 int $0x12 /* Get the amount of standard memory. */ |
| 93 shl $10, %eax | 92 shl $10, %eax |
| 94 pushl %eax | 93 pushl %eax |
| 95 | 94 |
| 96 | 95 /* reset floppy */ |
| 97 /* Read the rest of the image to _start. This code works by reading a track | 96 movb $0,%ah |
| 98 at a time... | 97 movb $0,%dl |
| 98 int $0x13 | |
| 99 jc _error | |
| 100 | |
| 101 /* Read the rest of the image to _start. This code works by reading | |
| 102 only one sector at a time to avoid "buffer cross 64k boundary" fatal | |
| 103 problem... This is slow but should work in almost all situations. | |
| 104 _start should be aligned on a 512 bytes boundary to be sure. | |
| 99 */ | 105 */ |
| 100 | 106 |
| 101 movl $_edata, %eax | 107 /* destination pointer es:bx */ |
| 102 movl $_start, %ebx /* Our destination address. */ | 108 /* With correct alignement, bx should be 0 and es should be a multiple |
| 103 subl %ebx, %eax /* Number of bytes in the image. */ | 109 * of 32. If not it may cause the "buffer cross 64k boundary" problem |
| 104 movl $1, %ecx /* Track/sector to read from (starts at 1). */ | 110 * (cf above) |
| 105 | 111 */ |
| 106 0: | 112 movl $_start,%eax |
| 107 cmpl $0, %eax | 113 movw %ax,%bx |
| 108 jle 1f | 114 andw $0xF,%bx |
| 109 | 115 shrl $4,%eax |
| 110 pushl %eax /* Save the number of bytes we want. */ | |
| 111 pushl %ebx /* Save our current address. */ | |
| 112 pushl %ecx /* Save our disk location. */ | |
| 113 | |
| 114 /* Read in a track with head 0. */ | |
| 115 | |
| 116 movl %ebx, %eax /* Put our address into ES:BX. */ | |
| 117 shr $4, %eax | |
| 118 movw %ax, %es | 116 movw %ax, %es |
| 119 andl $0xF, %ebx | 117 |
| 120 movw $0, %dx /* Disk 0, head 0 */ | 118 /* initials head/track/sector */ |
| 121 movb $0x02, %ah | 119 movw $0,%dx |
| 122 movb $sectorsPerTrack, %al /* Read the entire track. */ | 120 movw $1,%cx |
| 121 | |
| 122 xorl %edi,%edi | |
| 123 jmp _loadsector | |
| 124 | |
| 125 _nextsector: | |
| 126 addw $esPerSector, %di /* advance buffer pointer */ | |
| 127 shll $4,%edi | |
| 128 cmpl $_edata,%edi | |
| 129 jg _endload /* next sector ? */ | |
| 130 shrl $4,%edi | |
| 131 movw %di,%es | |
| 132 incb %cl | |
| 133 cmpb $sectorsPerTrack, %cl | |
| 134 jbe _loadsector /* next head ?*/ | |
| 123 movb $1, %cl | 135 movb $1, %cl |
| 124 int $0x13 /* CX points to our track/sector. */ | 136 incb %dh |
| 137 cmpb $1, %dh | |
| 138 je _loadsector /* next track ? */ | |
| 139 movb $0, %dh | |
| 140 incb %ch | |
| 141 | |
| 142 _loadsector: | |
| 143 | |
| 144 pushw %es | |
| 145 movw $0x0201, %ax | |
| 146 int $0x13 | |
| 147 popw %di | |
| 148 jc _error | |
| 149 | |
| 150 movw $(0x0E*256+'.'), %ax /* print a dot */ | |
| 151 int $0x10 | |
| 125 | 152 |
| 126 /* So go ahead and resume execution at the real starting address. This | 153 /* So go ahead and resume execution at the real starting address. This |
| 127 only serves to move us quickly to the real starting location; and has | 154 only serves to move us quickly to the real starting location; and has |
| 128 no effect after reading additional tracks. If we didn't jump after | 155 no effect after reading additional tracks. If we didn't jump after |
| 129 reading the first track, then we limit ourselves to reading images of | 156 reading the first track, then we limit ourselves to reading images of |
| 130 30k bytes max before overwriting ourselves at 0x7C00. | 157 30k bytes max before overwriting ourselves at 0x7C00. |
| 131 */ | 158 */ |
| 132 | 159 |
| 133 ljmp $0, $2f | 160 ljmp $0,$_nextsector |
| 161 | |
| 162 _error: /* halt on error */ | |
| 163 cli | |
| 134 hlt | 164 hlt |
| 135 | 165 jmp _start |
| 136 .align 4 | |
| 137 2: | |
| 138 | |
| 139 popl %ecx | |
| 140 popl %ebx | |
| 141 popl %eax | |
| 142 | |
| 143 /* Add our length to the address. */ | |
| 144 addl $bytesPerTrack, %ebx | |
| 145 subl $bytesPerTrack, %eax | |
| 146 | |
| 147 /* Maybe read in a track with head 1. */ | |
| 148 cmpl $0, %eax | |
| 149 jle 1f | |
| 150 | |
| 151 pushl %eax /* Save the number of bytes we want. */ | |
| 152 pushl %ebx /* Save our current address. */ | |
| 153 pushl %ecx | |
| 154 | |
| 155 movl %ebx, %eax /* Put our address into ES:BX. */ | |
| 156 shr $4, %eax | |
| 157 movw %ax, %es | |
| 158 andl $0xF, %ebx | |
| 159 movw $0x0100, %dx /* Disk 0, head 1 */ | |
| 160 movb $0x02, %ah | |
| 161 movb $sectorsPerTrack, %al /* Read the entire track. */ | |
| 162 movb $1, %cl | |
| 163 int $0x13 /* CX points to our track/sector. */ | |
| 164 | |
| 165 popl %ecx | |
| 166 popl %ebx | |
| 167 popl %eax | |
| 168 | |
| 169 /* Add our length to the address. */ | |
| 170 addl $bytesPerTrack, %ebx | |
| 171 subl $bytesPerTrack, %eax | |
| 172 | |
| 173 /* Move to the next track. */ | |
| 174 addb $0x1, %ch | |
| 175 | |
| 176 jmp 0b | |
| 177 | |
| 178 /* Write the 0x55/0xAA signature at the end of the first | 166 /* Write the 0x55/0xAA signature at the end of the first |
| 179 block. Without this signature the BIOS won't consider this | 167 block. Without this signature the BIOS won't consider this |
| 180 block to be bootable. | 168 block to be bootable. |
| 181 */ | 169 */ |
| 182 | 170 |
| 183 . = _start + 510 | 171 . = _start + 510 |
| 184 .byte 0x55 | 172 .byte 0x55 |
| 185 .byte 0xAA | 173 .byte 0xAA |
| 186 | 174 |
| 187 | 175 _endload: |
| 188 1: | 176 1: |
| 189 | 177 |
| 190 /* Lets be nice and wait for the diskette drive motor to go off before continuing. */ | 178 /* Lets be nice and wait for the diskette drive motor to go off |
| 179 * before continuing. */ | |
| 191 | 180 |
| 192 movw $0x40, %ax | 181 movw $0x40, %ax |
| 193 movw %ax, %es | 182 movw %ax, %es |
| 194 movl $0x40, %ebx | 183 movl $0x40, %ebx |
| 195 2: es | 184 2: es |
| 248 .byte 0x00 | 237 .byte 0x00 |
| 249 .byte 0x93 | 238 .byte 0x93 |
| 250 .byte 0xCF | 239 .byte 0xCF |
| 251 .byte 0x00 | 240 .byte 0x00 |
| 252 | 241 |
| 253 /* Selector 0x18 == shorter code: faults any code access 0xF0000000-0xFFFFFFFF. */ | 242 /* Selector 0x18 == shorter code: faults any code |
| 243 * access 0xF0000000-0xFFFFFFFF. | |
| 244 */ | |
| 254 .word 0xFFFF | 245 .word 0xFFFF |
| 255 .word 0x0000 | 246 .word 0x0000 |
| 256 .byte 0x00 | 247 .byte 0x00 |
| 257 .byte 0x9B | 248 .byte 0x9B |
| 258 .byte 0xC7 | 249 .byte 0xC7 |
| 290 /* Reset the flags register. */ | 281 /* Reset the flags register. */ |
| 291 pushl $0 | 282 pushl $0 |
| 292 popfl | 283 popfl |
| 293 | 284 |
| 294 /* Save the standard and extended memory lengths into some static variables... | 285 /* Save the standard and extended memory lengths into some static variables... |
| 295 I'm predicting that someone is going to break our way of passing a pointer | 286 I'm predicting that someone is going to break our way of passing a |
| 296 to this structure... may as well avoid that problem now. | 287 pointer to this structure... may as well avoid that problem now. |
| 297 */ | 288 */ |
| 298 .data | 289 .data |
| 299 .align 4 | 290 .align 4 |
| 300 .globl pc_standard_memory_size | 291 .globl pc_standard_memory_size |
| 301 pc_standard_memory_size: | 292 pc_standard_memory_size: |
| 310 movl %ebx, pc_extended_memory_size | 301 movl %ebx, pc_extended_memory_size |
| 311 | 302 |
| 312 /* _pc_entry() takes a pointer to our startup array (which only has standard | 303 /* _pc_entry() takes a pointer to our startup array (which only has standard |
| 313 and extended memory sizes in it, on the stack). | 304 and extended memory sizes in it, on the stack). |
| 314 */ | 305 */ |
| 315 movl %esp, %ebx /* They are the last parameters on the stack. */ | 306 movl %esp, %ebx /* They are the last parameters on the stack. */ |
| 316 pushl %ebx | 307 pushl %ebx |
| 317 | 308 |
| 318 #endif /* CYG_HAL_STARTUP_FLOPPY */ | 309 #endif /* CYG_HAL_STARTUP_FLOPPY */ |
| 319 | 310 |
| 320 #ifdef CYG_HAL_STARTUP_RAM | 311 #ifdef CYG_HAL_STARTUP_RAM |
| 321 | 312 |
| 322 /* In this case, the sizes of memory are pointed to by a pointer in IRQ | 313 /* In this case, the sizes of memory are pointed to by a pointer in IRQ |
| 323 vector 15. | 314 vector 15. |
| 324 */ | 315 */ |
| 325 | 316 |
| 326 /* Save the standard and extended memory lengths into some static variables... | 317 /* Save the standard and extended memory lengths into some static |
| 327 */ | 318 * variables... |
| 319 */ | |
| 328 .data | 320 .data |
| 329 .align 4 | 321 .align 4 |
| 330 .globl pc_standard_memory_size | 322 .globl pc_standard_memory_size |
| 331 pc_standard_memory_size: | 323 pc_standard_memory_size: |
| 332 .long 0 | 324 .long 0 |
