Oh yeah uh huh I'm making my own os...
os osdev asm assembly
at master 983 B view raw
1# |$|*file*packdisk.py*| |$|*noclean*| 2# |$|*artifact*disk.bin*packdisk.py&kernel.bin*"python3 {artifact0} {file} {artifact1}"*| 3from sys import argv 4import struct, math 5# USAGE: python3 packdisk.py <disk-location> <kernel.bin> 6assert len(argv) == 3 7print(argv) 8 9f_disk = open(argv[1], "wb") 10 11f_kernel = open(argv[2], "rb") 12 13f_kernel.seek(0, 2) 14kernel_size = f_kernel.tell() 15kernel_sector_count = math.ceil(kernel_size / 512) 16print(kernel_size, kernel_sector_count) 17f_kernel.seek(0, 0) 18 19# write the first sector 20""" 21struct sec_1 { 22 uint32_t kern_lba; 23 uint32_t kern_block_count; 24 void*(64) kern_addr; 25 padding to 512; 26} 27""" 28# HARDCODED 29# VV VV 30sec_1 = struct.pack("<IIQ"+("x"*(512-16)), 8, kernel_sector_count, 0x7B00) 31 32f_disk.write(sec_1) 33f_disk.write(f_kernel.read(kernel_size)) 34padding_count = 512 - (kernel_size%512) 35f_disk.write(struct.pack("x"*padding_count)) 36f_kernel.close() 37f_disk.close()