mirror of
https://github.com/gbowne1/ClassicOS.git
synced 2024-11-21 13:56:53 -08:00
fixed up some bad comments in boot.asm
This commit is contained in:
parent
6c4ee8ed02
commit
a6f5bdb64c
BIN
.vscode/browse.vc.db
vendored
BIN
.vscode/browse.vc.db
vendored
Binary file not shown.
BIN
.vscode/browse.vc.db-shm
vendored
BIN
.vscode/browse.vc.db-shm
vendored
Binary file not shown.
BIN
.vscode/browse.vc.db-wal
vendored
BIN
.vscode/browse.vc.db-wal
vendored
Binary file not shown.
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
@ -4,6 +4,7 @@
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "gcc-8 - Build and debug active file Level 1",
|
||||
"type": "cppdbg",
|
||||
@ -27,6 +28,16 @@
|
||||
"logging": {
|
||||
"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
165
.vscode/settings.json
vendored
@ -1,113 +1,66 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"*.c": "c",
|
||||
"*.h": "c",
|
||||
"*.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",
|
||||
// General C/C++ settings
|
||||
"C_Cpp.autoAddFileAssociations": true,
|
||||
"C_Cpp.autocompleteAddParentheses": 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.configurationWarnings": "disabled",
|
||||
"cmake.configureOnOpen": false,
|
||||
"C_Cpp.configurationWarnings": "enabled",
|
||||
"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.configureOnEdit": false,
|
||||
"c-cpp-flylint.flexelint.configFile": "",
|
||||
"c-cpp-flylint.flexelint.executable": "",
|
||||
"c-cpp-flylint.language": "c",
|
||||
"C_Cpp.autocompleteAddParentheses": true,
|
||||
"C_Cpp.errorSquiggles": "enabled",
|
||||
"C_Cpp_Runner.makePath": "",
|
||||
"cmake.sourceDirectory": "${workspaceFolder}",
|
||||
"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"
|
||||
"cmake.configureOnOpen": false,
|
||||
"cmake.cmakePath": "/usr/bin/cmake",
|
||||
"cmake.sourceDirectory": "${workspaceFolder}/",
|
||||
// Language-specific settings
|
||||
"[c]": {
|
||||
"editor.defaultFormatter": "ms-vscode.cpptools",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"C_Cpp.default.intelliSenseMode": "linux-gcc-x86",
|
||||
"cmake.cmakePath": "/usr/bin/cmake"
|
||||
"[cpp]": {
|
||||
"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",
|
||||
}
|
@ -16,10 +16,10 @@ identify_drive:
|
||||
cmp cl, 0x80 ; Check for hard disk interrupt vector (example)
|
||||
je is_harddrive
|
||||
; Handle invalid drive type (error handling)
|
||||
...
|
||||
; ...
|
||||
|
||||
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 al, 1 ; Number of sectors to read (1)
|
||||
|
||||
@ -68,8 +68,8 @@ memory_error:
|
||||
; ... (error handling or continue with limited memory)
|
||||
|
||||
; 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:
|
||||
Code snippet
|
||||
; Here's an improved version of the load_second_stage section with the placeholder jump replaced by actual loading logic:
|
||||
; Code snippet
|
||||
|
||||
load_second_stage:
|
||||
; Calculate address of second stage bootloader (assuming offset from boot sector)
|
||||
|
@ -8,12 +8,11 @@ start:
|
||||
MOV SP, 0xFFFF ; Stack grows downwards from the top of the segment
|
||||
|
||||
; Copy boot sector data to a safe location
|
||||
mCopyBootSector
|
||||
|
||||
call mCopyBootSector
|
||||
; Load the kernel
|
||||
CALL load_kernel
|
||||
|
||||
switch_to_protected_mode:
|
||||
switch_to_protected_mode:
|
||||
CLI ; Disable interrupts
|
||||
lgdt [gdt_descriptor] ; Load the global descriptor table
|
||||
MOV EAX, CR0
|
||||
@ -21,7 +20,7 @@ start:
|
||||
MOV CR0, EAX
|
||||
; Far jump to flush CPU queue after changing to protected mode
|
||||
JMP CODE_SEG:init_pm ; CODE_SEG is the segment selector for code segment in GDT
|
||||
init_pm:
|
||||
init_pm:
|
||||
; Update segment registers here
|
||||
; Set code segment register (CS) to point to code segment descriptor (selector 1)
|
||||
mov ax, 0x0001
|
||||
@ -29,9 +28,7 @@ start:
|
||||
mov es, ax ; Set other segment registers (ES, SS, etc.) as needed
|
||||
RET
|
||||
|
||||
|
||||
enable_a20:
|
||||
; Enable A20 gate
|
||||
enable_a20:
|
||||
cli ; Disable interrupts to prevent interference
|
||||
call a20wait ; Wait for the keyboard controller to be ready
|
||||
mov al, 0xAD ; Command to disable keyboard
|
||||
@ -42,56 +39,52 @@ start:
|
||||
call a20wait ; Wait for the keyboard controller to be ready
|
||||
in al, 0x60 ; Read current state of output port
|
||||
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
|
||||
mov al, 0xD1 ; Command to write output port
|
||||
out 0x64, al ; Send command to keyboard controller command port
|
||||
call a20wait ; Wait for the keyboard controller to be ready
|
||||
mov al, 0x02 ; New output port data with A20 enabled
|
||||
out 0x60, al ; Write new output port data
|
||||
call a20wait ; Wait for the keyboard controller to be ready
|
||||
mov al, 0xAE ; Command to re-enable keyboard
|
||||
out 0x64, al ; Send command to keyboard controller command port
|
||||
sti ; Re-enable interrupts
|
||||
ret
|
||||
|
||||
; Wait for keyboard controller to be ready
|
||||
a20wait:
|
||||
; Wait for keyboard controller to be ready
|
||||
a20wait:
|
||||
in al, 0x64 ; Read keyboard controller status port
|
||||
test al, 0x02 ; Check if input buffer is full
|
||||
jnz a20wait ; Wait until it's not full
|
||||
ret
|
||||
|
||||
; Enter kernel space and jump to the kernel entry point
|
||||
JMP 0x1000:0x0000
|
||||
; Enter kernel space and jump to the kernel entry point
|
||||
JMP 0x1000:0x0000
|
||||
|
||||
; Code to set up flat memory model for protected mode
|
||||
; This involves setting up the segment registers with selectors
|
||||
; that point to descriptors in the GDT that define a flat memory model
|
||||
; Code to set up flat memory model for protected mode
|
||||
; This involves setting up the segment registers with selectors
|
||||
; that point to descriptors in the GDT that define a flat memory model
|
||||
|
||||
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:
|
||||
|
||||
base_addr equ 0x0000000
|
||||
|
||||
; Define GDT structure
|
||||
gdt_struct:
|
||||
; Null descriptor (ignored)
|
||||
dq 0x0000000000000000h
|
||||
dq 0x0000000000000000h
|
||||
dd base_addr, 0 ; Both values are zero for a null descriptor
|
||||
|
||||
; Code segment descriptor (flat memory model)
|
||||
; Base address 0, limit 0xffffffff (full 4GB)
|
||||
; Present, Readable, Accessed, Code segment, 4KB granularity
|
||||
; Flags: 0x9A (Bits explained below)
|
||||
dq 0x0000000000000000h
|
||||
dq 0x00CFFFFFFFh
|
||||
dd base_addr, limit
|
||||
db 0x9A
|
||||
db 0xCF
|
||||
|
||||
; Data segment descriptor (flat memory model)
|
||||
; Similar structure to code segment descriptor with Data segment flag set
|
||||
dq 0x0000000000000000h
|
||||
dq 0x00CFFFFFFFh
|
||||
dd base_addr, limit
|
||||
db 0x92
|
||||
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
|
||||
mCopyBootSector:
|
||||
pusha ; Save all general-purpose registers
|
||||
|
@ -28,7 +28,4 @@ SECTIONS {
|
||||
bootloader_padding : {
|
||||
*(.bootloader_padding)
|
||||
}
|
||||
|
||||
/* Set the bootloader size to 512 bytes */
|
||||
= 512;
|
||||
}
|
Loading…
Reference in New Issue
Block a user