[mbrcopy] First draft and FIRST BOOT!

This commit is contained in:
John Stefanelli 2022-09-28 23:25:25 -04:00
parent ad55abdeb0
commit 1f88f01c33
Signed by: jstefanelli
GPG key ID: 60EDE2437640D2AA
6 changed files with 178 additions and 72 deletions

View file

@ -17,6 +17,9 @@ set(CMAKE_ASM_NASM_OBJECT_FORMAT elf32)
set(CMAKE_STATIC_LINKER_FLAGS "")
set(CMAKE_EXE_LINKER_FLAGS "-m elf_i386 --nmagic -nostdlib")
set(OS3_OBJDUMP_EXE i686-elf-objdump)
set(OS3_OBJCOPY_EXE i686-elf-objcopy)
# Locate i686 sysroot?
set(CMAKE_FIND_ROOT_PATH $ENV{I686_CROSS_ROOT})

View file

@ -1,6 +1,10 @@
#include "libfat.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
os_u32 loaded_fat_segment[512];
os_u8 mbr_buffer[512];
os_u32 readRoutine(os_u32 amount, void* buffer, void* user_data) {
if (user_data == 0) {
@ -75,22 +79,66 @@ void printNumber(os_u32 number) {
}
int main(int argc, char** argv) {
if (argc < 2) {
printf("No file provided\n");
if (argc < 3) {
printf("No files provided\n");
return 1;
}
FILE* f = fopen(argv[1], "rb+");
FileHandle h;
LFFileHandle h;
h.read = readRoutine;
h.write = writeRoutine;
h.seek = seekRoutine;
h.tell = tellRoutine;
h.user_data = (void*)&f;
libfat_test(h, printRoutine, printNumber);
LFControlBlock fat;
if(libfat_init(h, loaded_fat_segment, 512 * sizeof(os_u32), &fat) != OS_TRUE) {
fprintf(stderr, "libfat_init failed.\n");
return 1;
}
FILE* f2 = fopen(argv[2], "rb");
LFFileHandle mbrHandle;
mbrHandle.read = readRoutine;
mbrHandle.write = writeRoutine;
mbrHandle.seek = seekRoutine;
mbrHandle.tell = tellRoutine;
mbrHandle.user_data = (void*)&f2;
if(libfat_test_mbr(&mbrHandle) != OS_TRUE) {
printf("Failed to test MBR...\n");
return 1;
}
printf("FAT Ok.\n");
FatHeader_32 header = fat.header;
fseek(f2, 0, SEEK_SET);
os_u32 read = fread(mbr_buffer, 1, 512, f2);
if (read < 512) {
fprintf(stderr, "MBR size is incorrect: %d\n", read);
return 1;
}
if (*(os_u16*)(mbr_buffer + 510) != 0xAA55) {
fprintf(stderr, "MBR boot signature is missing: %#x\n", *(os_u16*)(mbr_buffer + 510));
return 1;
}
printf("MBR Ok.\n");
memcpy(mbr_buffer + 3, ((void*)&header) + 3, sizeof(FatHeader_32) - 3);
fseek(f, 0, SEEK_SET);
fwrite(mbr_buffer, 1, 512, f);
fclose(f);
fclose(f2);
printf("MBR Written on FAT.\n");
return 0;
}

View file

@ -22,7 +22,7 @@ typedef struct _FileHandle {
SeekRoutine seek;
TellRoutine tell;
void* user_data;
} FileHandle;
} LFFileHandle;
OS_PACK_START
struct _FatHeader_12 {
@ -112,50 +112,54 @@ typedef struct _FatDirectoryEntry FatDirectoryEntry;
typedef struct _FatHeader_32 FatHeader_32;
typedef struct _LibFatDirectoryEntry {
typedef struct _LFDirectoryEntry {
FatDirectoryEntry entry;
os_u32 entry_cluster;
os_u32 entry_offset;
} LibFatDirectoryEntry;
} LFDirectoryEntry;
typedef struct _FatControlBlock {
FileHandle handle;
typedef struct _LFControlBlock {
LFFileHandle handle;
FatHeader_32 header;
os_u32 first_loaded_cluster;
os_u32* loaded_fat_segment;
os_u32 loaded_fat_cluster_amount;
} FatControlBlock;
} LFControlBlock;
typedef struct _LibFatFile {
FatControlBlock* fat;
LibFatDirectoryEntry file_entry;
typedef struct _LFFile {
LFControlBlock* fat;
LFDirectoryEntry file_entry;
os_u32 current_cluster;
os_u32 position;
os_u32 in_cluster_position;
os_u32 fat_cluster_size;
} LibFatFile;
} LFFile;
typedef struct _LibFatDirectory {
FatControlBlock* fat;
typedef struct _LFDirectory {
LFControlBlock* fat;
os_u32 fat_cluster_size;
os_u32 base_cluster;
os_u32 current_cluster;
os_u32 position_in_cluster;
os_bool done;
} LibFatDirectory;
} LFDirectory;
extern os_bool libfat_init(FileHandle handle, void* buffer, os_u32 buffer_size, FatControlBlock* result);
extern os_bool libfat_open(FatControlBlock* fat, LibFatDirectoryEntry* entry, LibFatFile* result);
extern os_u32 libfat_read(LibFatFile* file, void* buffer, os_u32 buffer_size);
extern os_u32 libfat_write(LibFatFile* file, void* biffer, os_u32 buffer_size);
extern os_bool libfat_seek(LibFatFile* file, os_s32 position, os_u32 direction);
extern os_u32 libfat_tell(LibFatFile* file);
extern os_bool libfat_init(LFFileHandle handle, void* buffer, os_u32 buffer_size, LFControlBlock* result);
extern os_bool libfat_open(LFControlBlock* fat, LFDirectoryEntry* entry, LFFile* result);
extern os_u32 libfat_read(LFFile* file, void* buffer, os_u32 buffer_size);
extern os_u32 libfat_write(LFFile* file, void* biffer, os_u32 buffer_size);
extern os_bool libfat_seek(LFFile* file, os_s32 position, os_u32 direction);
extern os_u32 libfat_tell(LFFile* file);
extern os_bool libfat_create(FatControlBlock* fat, LibFatDirectoryEntry* parent_entry, os_s8* name, os_bool directory, LibFatDirectoryEntry* result);
extern os_bool libfat_create(LFControlBlock* fat, LFDirectoryEntry* parent_entry, os_s8* name, os_bool directory, LFDirectoryEntry* result);
extern os_bool libfat_open_directory(FatControlBlock* fat, LibFatDirectoryEntry* entry, LibFatDirectory* result);
extern os_bool libfat_read_directory(LibFatDirectory* dir, LibFatDirectoryEntry* entry);
extern void libfat_test(FileHandle handle, PrintRoutine print, PrintNumber printNumber);
extern os_bool libfat_open_directory(LFControlBlock* fat, LFDirectoryEntry* entry, LFDirectory* result);
extern os_bool libfat_read_directory(LFDirectory* dir, LFDirectoryEntry* entry);
extern os_u32 libfat_get_true_entry_offset(LFControlBlock* fat, LFDirectoryEntry* entry);
extern os_bool libfat_test_mbr(LFFileHandle* mbr);
extern void libfat_test(LFFileHandle handle, PrintRoutine print, PrintNumber printNumber);
#endif //!__OS3_LIBFAT_H

View file

@ -1,13 +1,13 @@
#include "libfat.h"
os_u32 loaded_fat_segment[512];
#define FAT_ENTRY_CLUSTER(entry) ((((os_u32)entry.start_cluster_high) << 16) + entry.start_cluster)
#define DIRECTORY_BUFFER_SIZE 32
FatDirectoryEntry directory_buffer[DIRECTORY_BUFFER_SIZE];
os_bool libfat_read_header_12(FileHandle handle, FatHeader_12* result) {
os_bool libfat_read_header_12(LFFileHandle handle, FatHeader_12* result) {
handle.seek(0, LIBFAT_SEEK_END, handle.user_data);
os_u32 size = handle.tell(handle.user_data);
@ -22,7 +22,7 @@ os_bool libfat_read_header_12(FileHandle handle, FatHeader_12* result) {
return OS_TRUE;
}
os_bool libfat_read_header_32(FileHandle handle, FatHeader_32* result) {
os_bool libfat_read_header_32(LFFileHandle handle, FatHeader_32* result) {
handle.seek(0, LIBFAT_SEEK_END, handle.user_data);
os_u32 size = handle.tell(handle.user_data);
@ -36,15 +36,7 @@ os_bool libfat_read_header_32(FileHandle handle, FatHeader_32* result) {
return OS_TRUE;
}
os_bool libfat_img_write_mbr(FileHandle image_file, FileHandle mbr_file) {
return OS_TRUE;
}
os_u32 libfat_img_copy_file(FileHandle image_file, FileHandle file, os_s8* name) {
return 0;
}
os_bool libfat_load_fat_cluster(FatControlBlock* fat, os_u32 target_cluster, os_bool force) {
os_bool libfat_load_fat_cluster(LFControlBlock* fat, os_u32 target_cluster, os_bool force) {
if (fat->first_loaded_cluster > target_cluster ||
fat->first_loaded_cluster + fat->loaded_fat_cluster_amount <= target_cluster ||
@ -69,7 +61,7 @@ os_bool libfat_load_fat_cluster(FatControlBlock* fat, os_u32 target_cluster, os_
return OS_TRUE;
}
os_u32 libfat_read_cluster(FatControlBlock* fat, os_u32 cluster) {
os_u32 libfat_read_cluster(LFControlBlock* fat, os_u32 cluster) {
if(libfat_load_fat_cluster(fat, cluster, OS_FALSE) == OS_FALSE) {
return 0;
}
@ -78,7 +70,7 @@ os_u32 libfat_read_cluster(FatControlBlock* fat, os_u32 cluster) {
}
os_bool libfat_write_fat_cluster(FatControlBlock* fat, os_u32 cluster_id, os_u32 cluster_value) {
os_bool libfat_write_fat_cluster(LFControlBlock* fat, os_u32 cluster_id, os_u32 cluster_value) {
os_u32 fat_size = fat->header.sectors_per_fat_32 * fat->header.base.bytes_per_sector;
if (cluster_id < 2 || cluster_id >= fat_size / sizeof(os_u32)) {
return OS_FALSE;
@ -99,7 +91,7 @@ os_bool libfat_write_fat_cluster(FatControlBlock* fat, os_u32 cluster_id, os_u32
return OS_TRUE;
}
os_u32 libfat_load_cluster(FatControlBlock* fat, os_u32 cluster, void* buffer, os_u32 buffer_size, os_u32 offset_in_cluster) {
os_u32 libfat_load_cluster(LFControlBlock* fat, os_u32 cluster, void* buffer, os_u32 buffer_size, os_u32 offset_in_cluster) {
os_u32 cluster_size = fat->header.base.bytes_per_sector * fat->header.base.sectors_per_cluster;
os_u32 data_offset = (fat->header.base.reserved_sectors + (fat->header.sectors_per_fat_32 * fat->header.base.number_of_fats)) * fat->header.base.bytes_per_sector;
@ -120,7 +112,7 @@ os_u32 libfat_load_cluster(FatControlBlock* fat, os_u32 cluster, void* buffer, o
}
os_u32 libfat_write_cluster(FatControlBlock* fat, os_u32 cluster, void* buffer, os_u32 buffer_size, os_u32 offset_in_cluster) {
os_u32 libfat_write_cluster(LFControlBlock* fat, os_u32 cluster, void* buffer, os_u32 buffer_size, os_u32 offset_in_cluster) {
os_u32 cluster_size = fat->header.base.bytes_per_sector * fat->header.base.sectors_per_cluster;
os_u32 data_offset = (fat->header.base.reserved_sectors + (fat->header.sectors_per_fat_32 * fat->header.base.number_of_fats)) * fat->header.base.bytes_per_sector;
@ -136,7 +128,7 @@ os_u32 libfat_write_cluster(FatControlBlock* fat, os_u32 cluster, void* buffer,
return written;
}
os_bool libfat_open(FatControlBlock* fat, LibFatDirectoryEntry* entry, LibFatFile* result) {
os_bool libfat_open(LFControlBlock* fat, LFDirectoryEntry* entry, LFFile* result) {
if(result == 0 || fat == 0 || entry == 0) {
return OS_FALSE;
}
@ -150,13 +142,13 @@ os_bool libfat_open(FatControlBlock* fat, LibFatDirectoryEntry* entry, LibFatFil
result->file_entry = *entry;
result->fat_cluster_size = fat->header.base.sectors_per_cluster * fat->header.base.bytes_per_sector;
result->position = 0;
result->current_cluster = (((os_u32)entry->entry.start_cluster_high) << 16) + entry->entry.start_cluster;
result->current_cluster = FAT_ENTRY_CLUSTER(entry->entry);
result->in_cluster_position = 0;
return OS_TRUE;
}
os_bool libfat_open_directory(FatControlBlock* fat, LibFatDirectoryEntry* entry, LibFatDirectory* result) {
os_bool libfat_open_directory(LFControlBlock* fat, LFDirectoryEntry* entry, LFDirectory* result) {
if (fat == 0 || result == 0) {
return OS_FALSE;
}
@ -167,7 +159,7 @@ os_bool libfat_open_directory(FatControlBlock* fat, LibFatDirectoryEntry* entry,
result->fat = fat;
result->fat_cluster_size = fat->header.base.sectors_per_cluster * fat->header.base.bytes_per_sector;
result->current_cluster = entry == 0 ? fat->header.first_root_cluster : (((os_u32)entry->entry.start_cluster_high) << 16) + entry->entry.start_cluster;
result->current_cluster = entry == 0 ? fat->header.first_root_cluster : FAT_ENTRY_CLUSTER(entry->entry);
result->base_cluster = result->current_cluster;
result->position_in_cluster = 0;
result->done = 0;
@ -175,7 +167,7 @@ os_bool libfat_open_directory(FatControlBlock* fat, LibFatDirectoryEntry* entry,
return OS_TRUE;
}
os_bool libfat_read_directory(LibFatDirectory* dir, LibFatDirectoryEntry* entry) {
os_bool libfat_read_directory(LFDirectory* dir, LFDirectoryEntry* entry) {
if (dir == 0 || entry == 0) {
return OS_FALSE;
}
@ -208,7 +200,7 @@ os_bool libfat_read_directory(LibFatDirectory* dir, LibFatDirectoryEntry* entry)
return OS_TRUE;
}
os_u32 libfat_read(LibFatFile* file, void* buffer, os_u32 buffer_size) {
os_u32 libfat_read(LFFile* file, void* buffer, os_u32 buffer_size) {
os_u32 read = 0;
os_bool eof = file->position >= file->file_entry.entry.file_size ? OS_TRUE : OS_FALSE;
while(read < buffer_size && eof != OS_TRUE) {
@ -241,7 +233,7 @@ os_u32 libfat_read(LibFatFile* file, void* buffer, os_u32 buffer_size) {
return read;
}
os_u32 libfat_tell(LibFatFile* file) {
os_u32 libfat_tell(LFFile* file) {
if(file == 0) {
return 0;
}
@ -249,7 +241,7 @@ os_u32 libfat_tell(LibFatFile* file) {
return file->position;
}
os_bool libfat_init(FileHandle file, void* buffer, os_u32 buffer_size, FatControlBlock* result) {
os_bool libfat_init(LFFileHandle file, void* buffer, os_u32 buffer_size, LFControlBlock* result) {
if(libfat_read_header_32(file, &result->header) != OS_TRUE) {
return OS_FALSE;
}
@ -266,7 +258,7 @@ os_bool libfat_init(FileHandle file, void* buffer, os_u32 buffer_size, FatContro
return OS_TRUE;
}
os_bool libfat_seek(LibFatFile* file, os_s32 position, os_u32 direction) {
os_bool libfat_seek(LFFile* file, os_s32 position, os_u32 direction) {
if (direction != LIBFAT_SEEK_CURRENT && direction != LIBFAT_SEEK_END && direction != LIBFAT_SEEK_ORIGIN) {
return OS_FALSE;
}
@ -303,7 +295,7 @@ os_bool libfat_seek(LibFatFile* file, os_s32 position, os_u32 direction) {
return OS_FALSE;
}
os_u32 cluster = (((os_u32)file->file_entry.entry.start_cluster_high) << 16) + file->file_entry.entry.start_cluster;
os_u32 cluster = FAT_ENTRY_CLUSTER(file->file_entry.entry);
os_u32 tmp_pos = 0;
while((tmp_pos + file->fat_cluster_size) <= target) {
@ -318,7 +310,7 @@ os_bool libfat_seek(LibFatFile* file, os_s32 position, os_u32 direction) {
return OS_TRUE;
}
os_u32 libfat_find_free_cluster(FatControlBlock* fat) {
os_u32 libfat_find_free_cluster(LFControlBlock* fat) {
os_u32 cluster_id = 2;
os_u32 cluster_value = FAT_LAST_CLUSTER_32;
do {
@ -334,7 +326,7 @@ os_u32 libfat_find_free_cluster(FatControlBlock* fat) {
}
os_bool libfat_fsinfo_update(FatControlBlock* fat) {
os_bool libfat_fsinfo_update(LFControlBlock* fat) {
os_u32 fsinfo_offset = fat->header.fsinfo_sector * fat->header.base.bytes_per_sector;
if(fat->handle.seek(fsinfo_offset, LIBFAT_SEEK_ORIGIN, fat->handle.user_data) != OS_TRUE) {
return OS_FALSE;
@ -385,7 +377,7 @@ os_bool libfat_fsinfo_update(FatControlBlock* fat) {
return OS_TRUE;
}
os_u32 libfat_add_cluster_to_chain(FatControlBlock* fat, os_u32 last_cluster_id) {
os_u32 libfat_add_cluster_to_chain(LFControlBlock* fat, os_u32 last_cluster_id) {
os_u32 cluster_value;
do {
cluster_value = libfat_read_cluster(fat, last_cluster_id);
@ -412,10 +404,10 @@ os_u32 libfat_add_cluster_to_chain(FatControlBlock* fat, os_u32 last_cluster_id)
return free_cluster;
}
os_bool libfat_add_entry_to_directory(FatControlBlock* fat, LibFatDirectoryEntry* parent, FatDirectoryEntry* entry, LibFatDirectoryEntry* result) {
os_bool libfat_add_entry_to_directory(LFControlBlock* fat, LFDirectoryEntry* parent, FatDirectoryEntry* entry, LFDirectoryEntry* result) {
os_u32 cluster = fat->header.first_root_cluster;
if (parent != 0) {
cluster = (((os_u32)parent->entry.start_cluster_high) << 16) + parent->entry.start_cluster;
cluster = FAT_ENTRY_CLUSTER(parent->entry);
}
os_u32 cluster_offset = 0;
os_u32 next_cluster = libfat_read_cluster(fat, cluster);
@ -467,7 +459,7 @@ os_bool libfat_add_entry_to_directory(FatControlBlock* fat, LibFatDirectoryEntry
return OS_TRUE;
}
os_bool libfat_create(FatControlBlock* fat, LibFatDirectoryEntry* parent_entry, os_s8* name, os_bool directory, LibFatDirectoryEntry* result) {
os_bool libfat_create(LFControlBlock* fat, LFDirectoryEntry* parent_entry, os_s8* name, os_bool directory, LFDirectoryEntry* result) {
FatDirectoryEntry new_entry;
for(int i = 0; i < 8; i++) {
new_entry.file_name[i] = name[i];
@ -504,7 +496,7 @@ os_bool libfat_create(FatControlBlock* fat, LibFatDirectoryEntry* parent_entry,
return OS_TRUE;
}
os_u32 libfat_write(LibFatFile* f, void* buffer, os_u32 buffer_size) {
os_u32 libfat_write(LFFile* f, void* buffer, os_u32 buffer_size) {
if (f == 0 || buffer == 0 || buffer_size == 0) {
return 0;
}
@ -542,21 +534,50 @@ os_u32 libfat_write(LibFatFile* f, void* buffer, os_u32 buffer_size) {
return written;
}
void libfat_test(FileHandle handle, PrintRoutine print, PrintNumber printNumber) {
FatControlBlock cb;
os_u32 libfat_get_true_entry_offset(LFControlBlock* fat, LFDirectoryEntry* entry) {
if (fat == 0 || entry == 0) {
return 0;
}
os_u32 cluster_size = fat->header.base.bytes_per_sector * fat->header.base.sectors_per_cluster;
os_u32 data_offset = (fat->header.base.reserved_sectors + (fat->header.sectors_per_fat_32 * fat->header.base.number_of_fats)) * fat->header.base.bytes_per_sector;
return data_offset + (cluster_size * FAT_ENTRY_CLUSTER(entry->entry) - 2);
}
os_bool libfat_test_mbr(LFFileHandle* mbr) {
if (mbr == 0) {
return OS_FALSE;
}
if(mbr->seek(0, LIBFAT_SEEK_ORIGIN, mbr->user_data) != OS_TRUE) {
return OS_FALSE;
}
char buffer[6];
os_u32 read = mbr->read(6, buffer, mbr->user_data);
if (read < 6) {
return OS_FALSE;
}
return (buffer[2] != 0x49 && buffer[3] == 0x49) ? OS_TRUE : OS_FALSE;
}
/*
void libfat_test(LFFileHandle handle, PrintRoutine print, PrintNumber printNumber) {
LFControlBlock cb;
if (libfat_init(handle, loaded_fat_segment, 512 * sizeof(os_u32), &cb) != OS_TRUE) {
print("Failed to init FAT.", 0);
return;
}
LibFatDirectory dir;
LFDirectory dir;
if (libfat_open_directory(&cb, 0, &dir) != OS_TRUE) {
print("Failecd to open directory.", 0);
return;
}
os_bool any = OS_FALSE;
LibFatDirectoryEntry entry;
LFDirectoryEntry entry;
while(libfat_read_directory(&dir, &entry) == OS_TRUE) {
if ((entry.entry.attribute & (os_s8)FAT_HIDDEN_BIT) != 0 ||
(entry.entry.attribute & (os_s8)FAT_VOLUME_BIT) != 0 ||
@ -568,7 +589,7 @@ void libfat_test(FileHandle handle, PrintRoutine print, PrintNumber printNumber)
print("Entry name: ", 0);
print(entry.entry.file_name, 11);
os_u32 cluster = (((os_u32)entry.entry.start_cluster_high) << 16) + entry.entry.start_cluster;
os_u32 cluster = FAT_ENTRY_CLUSTER(entry.entry);
print("Cluster: ", 0);
printNumber(cluster);
@ -578,7 +599,7 @@ void libfat_test(FileHandle handle, PrintRoutine print, PrintNumber printNumber)
os_u32 effective_size = entry.entry.file_size > 512 ? 512 : entry.entry.file_size;
if(effective_size > 0) {
LibFatFile f;
LFFile f;
if (libfat_open(&cb, &entry, &f) == OS_TRUE) {
char buffer[512];
os_u32 amount = libfat_read(&f, buffer, 512);
@ -591,11 +612,11 @@ void libfat_test(FileHandle handle, PrintRoutine print, PrintNumber printNumber)
}
if(any == OS_FALSE) {
LibFatDirectoryEntry created_file;
LFDirectoryEntry created_file;
libfat_create(&cb, 0, "TEST TXT", OS_FALSE, &created_file);
print("Added file 'test.txt'", 0);
LibFatFile new_file;
LFFile new_file;
if(libfat_open(&cb, &created_file, &new_file) != OS_TRUE) {
print("Failed to open new file", 0);
return;
@ -604,4 +625,5 @@ void libfat_test(FileHandle handle, PrintRoutine print, PrintNumber printNumber)
char* data = "test";
libfat_write(&new_file, data, 5);
}
}
}
*/

View file

@ -1,3 +1,6 @@
add_executable(mbr mbr.asm linker.ld)
target_link_options(mbr PRIVATE -T${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
target_link_options(mbr PRIVATE -T${CMAKE_CURRENT_SOURCE_DIR}/linker.ld)
add_custom_target(mbr_bin ${OS3_OBJCOPY_EXE} -O binary -g -S -R .eh_frame $<TARGET_FILE:mbr> $<TARGET_FILE:mbr>.bin COMMAND ${OS3_OBJCOPY_EXE} --only-keep-debug $<TARGET_FILE:mbr> $<TARGET_FILE:mbr>.sym DEPENDS mbr)

View file

@ -73,11 +73,24 @@ print:
PUSH BX ; save BX
PUSH CX ; save CX
PUSH BP ; save BP (can change due to scrolling)
PUSH SI ; save SI
MOV BP, SP ; set up stack frame
MOV SI, [BP + 12] ; load parameter 'address'
MOV CX, [BP + 10] ; load parameter 'size'
print_loop:
MOV AL, [SI] ; load character of string
MOV AH, 0Eh ; load INT 10h parameter
MOV BX, 0 ; zero-out BX (extra parameters)
INT 10h ; call INT 10h AH=0Eh
INC SI ; move to next character
LOOP print_loop ; loop until all characters are printed
POP SI ; restore SI
POP BP ; restore BP
POP CX ; restore CX
POP BX ; restore BX
RET ; return
entry:
@ -96,6 +109,17 @@ entry:
PUSH DX ; save drive number (DL)
; Print message
MOV AX, msg ; load address of msg
PUSH AX ; push parameter 'address of string'
MOV AX, 12 ; load size of msg
PUSH AX ; push parameter 'size of string'
CALL print ; call function 'print'
over:
JMP over ; loop forever
; Load drive parameters
MOV AX, 4800h ; load AH=48h, AL=0h
MOV SI, disk_info_packet ; load address of Disk_Info_Packet
@ -124,4 +148,6 @@ packet_lba dq 0h
build_settings:
build_settings_magic_0 dd 0x49494949
build_settings_bytes dw 0x0
build_settings_magic_1 dd 0x49494949
build_settings_magic_1 dd 0x49494949
msg db "OS3_BOOT_OK!"