Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/i386/locore.s
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | recover_bootinfo: | ||||
* | * | ||||
* Old disk boot blocks: | * Old disk boot blocks: | ||||
* (*btext)(howto, bootdev, cyloffset, esym); | * (*btext)(howto, bootdev, cyloffset, esym); | ||||
* [return address == 0, and can NOT be returned to] | * [return address == 0, and can NOT be returned to] | ||||
* [cyloffset was not supported by the FreeBSD boot code | * [cyloffset was not supported by the FreeBSD boot code | ||||
* and always passed in as 0] | * and always passed in as 0] | ||||
* [esym is also known as total in the boot code, and | * [esym is also known as total in the boot code, and | ||||
* was never properly supported by the FreeBSD boot code] | * was never properly supported by the FreeBSD boot code] | ||||
* This code from 1.x/2.x doesn't supply now-required metadata and | |||||
* likely will fail (we test for it to avoid dereferencing stack | |||||
* garbage here). | |||||
* | * | ||||
* Old diskless netboot code: | * Old diskless netboot code: | ||||
* (*btext)(0,0,0,0,&nfsdiskless,0,0,0); | * (*btext)(0,0,0,0,&nfsdiskless,0,0,0); | ||||
* [return address != 0, and can NOT be returned to] | * [return address != 0, and can NOT be returned to] | ||||
* If we are being booted by this code it will NOT work, | * If we are being booted by this code it will NOT work, | ||||
* so we are just going to halt if we find this case. | * so we are just going to halt if we find this case. | ||||
* | * | ||||
* New uniform boot code: | * New uniform boot code: | ||||
* (*btext)(howto, bootdev, 0, 0, 0, &bootinfo) | * (*btext)(howto, bootdev, 0, 0, 0, &bootinfo) | ||||
* [return address != 0, and can be returned to] | * [return address != 0, and can be returned to] | ||||
* | * | ||||
* There may seem to be a lot of wasted arguments in here, but | * There may seem to be a lot of wasted arguments in here, but | ||||
* that is so the newer boot code can still load very old kernels | * that is so the newer boot code can still load very old kernels | ||||
* and old boot code can load new kernels. | * and old boot code can load new kernels. | ||||
*/ | */ | ||||
/* | /* | ||||
* The old style disk boot blocks fake a frame on the stack and | * The old style disk boot blocks fake a frame on the stack and did an | ||||
* did an lret to get here. The frame on the stack has a return | * lret to get here. The frame on the stack has a return address of 0. | ||||
* address of 0. | * This style of boot (from 1.x / 2.x) almost certainly won't work, | ||||
* since the kernel has required metadata since about 7.x or so and none | |||||
* are present. | |||||
*/ | */ | ||||
cmpl $0,4(%ebp) | cmpl $0,4(%ebp) | ||||
je olddiskboot | je olddiskboot | ||||
/* | /* | ||||
* We have some form of return address, so this is either the | * We have some form of return address, so this is either the | ||||
* old diskless netboot code, or the new uniform code. That can | * old diskless netboot code, or the new uniform code. That can | ||||
* be detected by looking at the 5th argument, if it is 0 | * be detected by looking at the 5th argument, if it is 0 | ||||
* we are being booted by the new uniform boot code. | * we are being booted by the new uniform boot code. | ||||
*/ | */ | ||||
cmpl $0,24(%ebp) | cmpl $0,24(%ebp) | ||||
je newboot | je newboot | ||||
/* | /* | ||||
* Seems we have been loaded by the old diskless boot code, we | * Seems we have been loaded by the old 1.x/2.x diskless boot code, we | ||||
* don't stand a chance of running as the diskless structure | * don't stand a chance of running as the diskless structure changed | ||||
* changed considerably between the two, so just halt. | * considerably between the two, so just halt. | ||||
*/ | */ | ||||
hlt | hlt | ||||
/* | /* | ||||
* We have been loaded by the new uniform boot code. | * We have been loaded by the new uniform boot code. | ||||
* Let's check the bootinfo version, and if we do not understand | * Let's check the bootinfo version, and if we do not understand | ||||
* it we return to the loader with a status of 1 to indicate this error | * it we return to the loader with a status of 1 to indicate this error | ||||
*/ | */ | ||||
newboot: | newboot: | ||||
movl 28(%ebp),%ebx /* &bootinfo.version */ | movl 28(%ebp),%ebx /* &bootinfo.version */ | ||||
movl BI_VERSION(%ebx),%eax | movl BI_VERSION(%ebx),%eax | ||||
cmpl $1,%eax /* We only understand version 1 */ | cmpl $1,%eax /* We only understand version 1 */ | ||||
je 1f | je 1f | ||||
testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */ | |||||
jne 1f | |||||
movl $1,%eax /* Return status */ | movl $1,%eax /* Return status */ | ||||
leave | leave | ||||
/* | /* | ||||
* XXX this returns to our caller's caller (as is required) since | * XXX this returns to our caller's caller (as is required) since | ||||
* we didn't set up a frame and our caller did. | * we didn't set up a frame and our caller did. | ||||
*/ | */ | ||||
ret | ret | ||||
Show All 14 Lines | |||||
1: | 1: | ||||
cld | cld | ||||
rep | rep | ||||
movsb | movsb | ||||
2: | 2: | ||||
/* | /* | ||||
* Determine the size of the boot loader's copy of the bootinfo | * Determine the size of the boot loader's copy of the bootinfo | ||||
* struct. This is impossible to do properly because old versions | * struct. Copy min(our size, loader's size) into our bootinfo. | ||||
* of the struct don't contain a size field and there are 2 old | * Incompatible with really old boot loaders from FreeBSD 1.x and 2.0. | ||||
darius-dons.net.au: laoder -> loader | |||||
* versions with the same version number. | |||||
*/ | */ | ||||
movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */ | |||||
testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */ | |||||
je got_bi_size /* no, sizeless version */ | |||||
movl BI_SIZE(%ebx),%ecx | |||||
got_bi_size: | |||||
/* | |||||
* Copy the common part of the bootinfo struct | |||||
*/ | |||||
movl %ebx,%esi | movl %ebx,%esi | ||||
movl $bootinfo,%edi | movl $bootinfo,%edi | ||||
movl BI_SIZE(%ebx),%ecx | |||||
cmpl $BOOTINFO_SIZE,%ecx | cmpl $BOOTINFO_SIZE,%ecx | ||||
jbe got_common_bi_size | jbe got_common_bi_size | ||||
movl $BOOTINFO_SIZE,%ecx | movl $BOOTINFO_SIZE,%ecx | ||||
got_common_bi_size: | got_common_bi_size: | ||||
cld | cld | ||||
rep | rep | ||||
movsb | movsb | ||||
▲ Show 20 Lines • Show All 173 Lines • Show Last 20 Lines |
laoder -> loader