fixed up some bad comments in boot.asm

This commit is contained in:
Gregory Kenneth Bowne 2024-03-24 19:38:29 -07:00
parent 6c4ee8ed02
commit a6f5bdb64c
8 changed files with 137 additions and 183 deletions

BIN
.vscode/browse.vc.db vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

11
.vscode/launch.json vendored
View File

@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "gcc-8 - Build and debug active file Level 1", "name": "gcc-8 - Build and debug active file Level 1",
"type": "cppdbg", "type": "cppdbg",
@ -27,6 +28,16 @@
"logging": { "logging": {
"engineLogging": true "engineLogging": true
} }
},
{
"name": "Debug with QEMU",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/boot.bin",
"miDebuggerPath": "/usr/bin/qemu-system-i386",
"miDebuggerArgs": "-kernel",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build"
} }
] ]
} }

165
.vscode/settings.json vendored
View File

@ -1,113 +1,66 @@
{ {
"files.associations": { // General C/C++ settings
"*.c": "c", "C_Cpp.autoAddFileAssociations": true,
"*.h": "c", "C_Cpp.autocompleteAddParentheses": true,
"*.cpp": "cpp",
"*.hpp": "hpp",
"*.asm": "asm",
"*.bin": "bin"
},
"files.fileAssociations": {
".c": "c",
".h": "c",
".cpp": "cpp",
".hpp": "cpp",
".asm": "asm",
".bin": "bin"
},
"emmet.includeLanguages": {
"c": "c",
"cpp": "cpp",
"assembly": "asm"
},
"C_Cpp_Runner.cCompilerPath": "/usr/bin",
"C_Cpp_Runner.cppCompilerPath": "/usr/bin",
"C_Cpp_Runner.debuggerPath": "/usr/bin",
"C_Cpp_Runner.cStandard": "c17",
"C_Cpp_Runner.cppStandard": "c++20",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wextra",
"-Wpedantic"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [
"-dynamic-linker {/lib64/ld-linux-x86-64.so.2}"
],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"c-cpp-flylint.enable": true,
"c-cpp-flylint.debug": true,
"c-cpp-flylint.flexelint.enable": false,
"c-cpp-flylint.cppcheck.enable": true,
"c-cpp-flylint.clang.enable": false,
"C_Cpp_Config.cCompilerPath": "gcc",
"C_Cpp_Config.cppCompilerPath": "g++",
"C_Cpp_Config.debuggerPath": "gdb",
"C_Cpp_Config.makePath": "make",
"C_Cpp.clang_format_sortIncludes": true, "C_Cpp.clang_format_sortIncludes": true,
"C_Cpp.vcFormat.indent.preserveComments": true,
"C_Cpp.vcFormat.indent.namespaceContents": false,
"C_Cpp.vcFormat.indent.caseContentsWhenBlock": true,
"C_Cpp.vcFormat.space.pointerReferenceAlignment": "right",
"C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false,
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.formatting": "clangFormat",
"[c]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"[cpp]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "ms-vscode.cpptools"
},
"C_Cpp.codeAnalysis.clangTidy.enabled": true, "C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.configurationWarnings": "disabled", "C_Cpp.configurationWarnings": "enabled",
"cmake.configureOnOpen": false, "C_Cpp.default.browse.limitSymbolsToIncludedHeaders": false,
"C_Cpp.default.cStandard": "c11",
"C_Cpp.default.compilerPath": "",
"C_Cpp.default.cppStandard": "c++11",
"C_Cpp.default.enableConfigurationSquiggles": true,
"C_Cpp.errorSquiggles": "enabledIfIncludesResolve",
"C_Cpp.formatting": "default",
"C_Cpp.loggingLevel": "Debug",
"C_Cpp.vcFormat.indent.caseContentsWhenBlock": true,
"C_Cpp.vcFormat.indent.namespaceContents": false,
"C_Cpp.vcFormat.indent.preserveComments": true,
"C_Cpp.vcFormat.space.pointerReferenceAlignment": "right",
// CMake integration settings
"cmake.autoSelectActiveFolder": false, "cmake.autoSelectActiveFolder": false,
"cmake.configureOnEdit": false, "cmake.configureOnEdit": false,
"c-cpp-flylint.flexelint.configFile": "", "cmake.configureOnOpen": false,
"c-cpp-flylint.flexelint.executable": "", "cmake.cmakePath": "/usr/bin/cmake",
"c-cpp-flylint.language": "c", "cmake.sourceDirectory": "${workspaceFolder}/",
"C_Cpp.autocompleteAddParentheses": true, // Language-specific settings
"C_Cpp.errorSquiggles": "enabled", "[c]": {
"C_Cpp_Runner.makePath": "", "editor.defaultFormatter": "ms-vscode.cpptools",
"cmake.sourceDirectory": "${workspaceFolder}", "editor.formatOnSave": true
"C_Cpp.default.compilerPath": "/usr/bin",
"C_Cpp.loggingLevel": "Error",
"C_Cpp.default.enableConfigurationSquiggles": true,
"C_Cpp.default.includePath": [
"${workspaceFolder}/**", // Include all files in the workspace folder
"/usr/include", // Standard system include path
"/usr/local/include", // Additional system include path
"/path/to/custom/includes" // Custom include path
],
"workbench.editorAssociations": {
"*.bin": "default",
"*.h": "default",
"*.c": "default",
"*.json": "default",
"*.asm": "default"
}, },
"C_Cpp.default.intelliSenseMode": "linux-gcc-x86", "[cpp]": {
"cmake.cmakePath": "/usr/bin/cmake" "editor.defaultFormatter": "ms-vscode.cpptools",
"editor.formatOnSave": true
},
// File associations
"files.associations": {
"*.c": "c",
"*.cpp": "cpp",
"*.h": "c",
"*.hpp": "c"
},
"workbench.editorAssociations": {
"*.c": "default",
"*.cpp": "default",
"*.h": "default",
"*.hpp": "default"
},
// IntelliSense configuration
"C_Cpp.default.includePath": [
"/usr/include",
"${workspaceFolder}/**",
"${workspaceFolder}/src/include",
"${workspaceFolder}/include"
],
"C_Cpp.default.defines": [],
"C_Cpp.default.compileCommands": "build/compile_commands.json",
"C_Cpp.default.browse.path": [
"/usr/include",
"${workspaceFolder}/**",
"${workspaceFolder}/src/include",
"${workspaceFolder}/include"
],
"C_Cpp.default.browse.databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db",
"C_Cpp.default.configurationProvider": "ms-vscode.cpptools",
"C_Cpp.default.intelliSenseMode": "linux-gcc-x64",
} }

View File

@ -16,10 +16,10 @@ identify_drive:
cmp cl, 0x80 ; Check for hard disk interrupt vector (example) cmp cl, 0x80 ; Check for hard disk interrupt vector (example)
je is_harddrive je is_harddrive
; Handle invalid drive type (error handling) ; Handle invalid drive type (error handling)
... ; ...
is_floppy: is_floppy:
Perform floppy disk access (assuming AH=0x02 for read sectors) ; Perform floppy disk access (assuming AH=0x02 for read sectors)
mov ah, 0x02 ; Read sectors mov ah, 0x02 ; Read sectors
mov al, 1 ; Number of sectors to read (1) mov al, 1 ; Number of sectors to read (1)
@ -68,8 +68,8 @@ memory_error:
; ... (error handling or continue with limited memory) ; ... (error handling or continue with limited memory)
; Second stage loading (simplified example) ; Second stage loading (simplified example)
Here's an improved version of the load_second_stage section with the placeholder jump replaced by actual loading logic: ; Here's an improved version of the load_second_stage section with the placeholder jump replaced by actual loading logic:
Code snippet ; Code snippet
load_second_stage: load_second_stage:
; Calculate address of second stage bootloader (assuming offset from boot sector) ; Calculate address of second stage bootloader (assuming offset from boot sector)

View File

@ -8,8 +8,7 @@ start:
MOV SP, 0xFFFF ; Stack grows downwards from the top of the segment MOV SP, 0xFFFF ; Stack grows downwards from the top of the segment
; Copy boot sector data to a safe location ; Copy boot sector data to a safe location
mCopyBootSector call mCopyBootSector
; Load the kernel ; Load the kernel
CALL load_kernel CALL load_kernel
@ -29,9 +28,7 @@ start:
mov es, ax ; Set other segment registers (ES, SS, etc.) as needed mov es, ax ; Set other segment registers (ES, SS, etc.) as needed
RET RET
enable_a20: enable_a20:
; Enable A20 gate
cli ; Disable interrupts to prevent interference cli ; Disable interrupts to prevent interference
call a20wait ; Wait for the keyboard controller to be ready call a20wait ; Wait for the keyboard controller to be ready
mov al, 0xAD ; Command to disable keyboard mov al, 0xAD ; Command to disable keyboard
@ -42,13 +39,13 @@ start:
call a20wait ; Wait for the keyboard controller to be ready call a20wait ; Wait for the keyboard controller to be ready
in al, 0x60 ; Read current state of output port in al, 0x60 ; Read current state of output port
or al, 0x02 ; Set A20 bit or al, 0x02 ; Set A20 bit
out 0x64, al ; Send command to keyboard controller command port
call a20wait ; Wait for the keyboard controller to be ready call a20wait ; Wait for the keyboard controller to be ready
mov al, 0xD1 ; Command to write output port mov al, 0xD1 ; Command to write output port
out 0x64, al ; Send command to keyboard controller command port out 0x64, al ; Send command to keyboard controller command port
call a20wait ; Wait for the keyboard controller to be ready call a20wait ; Wait for the keyboard controller to be ready
mov al, 0x02 ; New output port data with A20 enabled mov al, 0xAE ; Command to re-enable keyboard
out 0x60, al ; Write new output port data out 0x64, al ; Send command to keyboard controller command port
call a20wait ; Wait for the keyboard controller to be ready
sti ; Re-enable interrupts sti ; Re-enable interrupts
ret ret
@ -66,32 +63,28 @@ start:
; This involves setting up the segment registers with selectors ; This involves setting up the segment registers with selectors
; that point to descriptors in the GDT that define a flat memory model ; that point to descriptors in the GDT that define a flat memory model
; Define GDT structure limit = 0x00CFFFFFh ; Define limit as a separate variable within gdt_struct
; Placeholder instruction to satisfy NASM
dummy_instruction DB 0x90 ; NOP instruction as a placeholder
gdt_struct: gdt_struct:
base_addr equ 0x0000000
; Null descriptor (ignored) ; Null descriptor (ignored)
dq 0x0000000000000000h dd base_addr, 0 ; Both values are zero for a null descriptor
dq 0x0000000000000000h
; Code segment descriptor (flat memory model) ; Code segment descriptor (flat memory model)
; Base address 0, limit 0xffffffff (full 4GB) dd base_addr, limit
; Present, Readable, Accessed, Code segment, 4KB granularity
; Flags: 0x9A (Bits explained below)
dq 0x0000000000000000h
dq 0x00CFFFFFFFh
db 0x9A db 0x9A
db 0xCF db 0xCF
; Data segment descriptor (flat memory model) ; Data segment descriptor (flat memory model)
; Similar structure to code segment descriptor with Data segment flag set dd base_addr, limit
dq 0x0000000000000000h
dq 0x00CFFFFFFFh
db 0x92 db 0x92
db 0xCF db 0xCF
; Jump to the kernel entry point
JMP 0x1000:0x0000 ; Assuming the kernel is loaded at 0x1000:0x0000
; Macro to copy boot sector data to a safe location ; Macro to copy boot sector data to a safe location
mCopyBootSector: mCopyBootSector:
pusha ; Save all general-purpose registers pusha ; Save all general-purpose registers

View File

@ -28,7 +28,4 @@ SECTIONS {
bootloader_padding : { bootloader_padding : {
*(.bootloader_padding) *(.bootloader_padding)
} }
/* Set the bootloader size to 512 bytes */
= 512;
} }