limine-install: Make sure stage 2 chunks are sector aligned
This commit is contained in:
parent
f26b6045a7
commit
5dc8f48d6c
|
@ -10,6 +10,8 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define DIV_ROUNDUP(a, b) (((a) + ((b) - 1)) / (b))
|
||||||
|
|
||||||
struct gpt_table_header {
|
struct gpt_table_header {
|
||||||
// the head
|
// the head
|
||||||
char signature[8];
|
char signature[8];
|
||||||
|
@ -318,8 +320,11 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t stage2_size = bootloader_file_size - 512;
|
size_t stage2_size = bootloader_file_size - 512;
|
||||||
uint16_t stage2_size_a = stage2_size / 2 + stage2_size % 2;
|
|
||||||
uint16_t stage2_size_b = stage2_size / 2;
|
size_t stage2_sects = DIV_ROUNDUP(stage2_size, 512);
|
||||||
|
|
||||||
|
uint16_t stage2_size_a = (stage2_sects / 2) * 512 + (stage2_sects % 2 ? 512 : 0);
|
||||||
|
uint16_t stage2_size_b = (stage2_sects / 2) * 512;
|
||||||
|
|
||||||
// Default split of stage2 for MBR (consecutive in post MBR gap)
|
// Default split of stage2 for MBR (consecutive in post MBR gap)
|
||||||
uint64_t stage2_loc_a = 512;
|
uint64_t stage2_loc_a = 512;
|
||||||
|
|
|
@ -55,7 +55,7 @@ read_sectors:
|
||||||
; EBP:EAX address to EAX LBA sector
|
; EBP:EAX address to EAX LBA sector
|
||||||
div ebp
|
div ebp
|
||||||
mov dword [si+8], eax
|
mov dword [si+8], eax
|
||||||
mov dword [si+12], edx
|
mov dword [si+12], 0
|
||||||
|
|
||||||
pop dx
|
pop dx
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue