diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rwxr-xr-x | run | 23 | ||||
-rw-r--r-- | src/entry.asm | 65 | ||||
-rw-r--r-- | src/main.c | 6 |
5 files changed, 42 insertions, 59 deletions
@@ -6,3 +6,4 @@ build/ cmake/ cross/ disk/bin/ +disk/boot/ diff --git a/CMakeLists.txt b/CMakeLists.txt index fbfae14..3dac915 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,14 +20,14 @@ set(CMAKE_ASM_LINKER_PREFERENCE ${CMAKE_LINKER}) set(CMAKE_C_LINKER_PREFERENCE ${CMAKE_LINKER}) # Compiler and linker flags -set(CMAKE_C_FLAGS "-Wall -Wno-int-conversion -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdlib -nostdinc -ffreestanding -std=gnu99 -pedantic-errors -c -I${CMAKE_CURRENT_SOURCE_DIR}/src/lib/") +set(CMAKE_C_FLAGS "-Wall -Wextra -nostdlib -nostdinc -ffreestanding -std=gnu99 -pedantic-errors -c -I${CMAKE_CURRENT_SOURCE_DIR}/src/lib/") set(CMAKE_EXE_LINKER_FLAGS "-ffreestanding -O2 -nostdlib -nostdinc") -set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <SOURCE> -o <OBJECT> -f elf32 -O0") +set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <SOURCE> -o <OBJECT> -f bin -O0") set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_ASM_LINK_EXECUTABLE "<CMAKE_LINKER> ${CMAKE_EXE_LINKER_FLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") # Recursive sources -file(GLOB_RECURSE sources src/*.c src/*.asm) +file(GLOB_RECURSE sources src/*.c) file(GLOB_RECURSE apps_sources apps/*.c) # MELVIX @@ -89,7 +89,7 @@ make_cross() { } make_build() { - mkdir -p build/ disk/bin/ + mkdir -p build/ disk/bin/ disk/boot echo "Building..." cd build/ @@ -98,27 +98,22 @@ make_build() { cd .. # Create disk image - # make_genext2fs - # mkdir ./mnt/ - # mkdir -p ./mnt/etc/ - # mkdir -p ./mnt/usr/ - # mkdir -p ./mnt/bin/ - - # cp ./build/res/font.bin ./mnt/bin/font - # cp ./build/user/* ./mnt/bin/ - # echo "Hello world, ext2!" | tee -a ./mnt/etc/test - # /usr/local/bin/genext2fs -B 4096 -d mnt -U -N 4096 -b 65536 ./build/disk.img - # rm -r mnt/ + make_genext2fs + /usr/local/bin/genext2fs -B 4096 -d disk/ -U -N 4096 -b 65536 build/disk.img + + nasm ./src/entry.asm -f bin -o disk/boot/boot.bin + cp build/melvix.bin disk/boot/ + dd if=disk/boot/boot.bin bs=512 of=build/disk.img printf "Build finshed successfully!\n\n" } make_test() { - qemu_with_flags -cdrom ./build/melvix.iso# -hda ./build/disk.img + qemu_with_flags -hda ./build/disk.img } make_disasm() { - objdump -drwC -Mintel ./build/kernel.bin --visualize-jumps=color | less -R + objdump -drwC -Mintel build/kernel.bin --visualize-jumps=color | less -R } make_sync() { diff --git a/src/entry.asm b/src/entry.asm index 35cede5..7404ccc 100644 --- a/src/entry.asm +++ b/src/entry.asm @@ -1,49 +1,30 @@ -bits 32 +bits 16 -kernel_stack equ 0x4000 -multiboot_magic equ 0xe85250d6 +org 0x7c00 -section .text - align 4 +jmp start - multiboot: - header_start: - dd multiboot_magic - dd 0 - dd header_end - header_start - dd 0x100000000 - (multiboot_magic + 0 + (header_end - header_start)) +print: + mov ah, 0x0E + xor bh, bh + print_ch: + lodsb + test al, al + jz print_end + int 0x10 + jmp print_ch + print_end: + ret - ; Information tag - align 8 - dw 1 - dw 1 - dd 24 - dd 2 ; bootloader name - dd 4 ; meminfo - dd 6 ; mmap - dd 13 ; smbios +start: + mov ax, 0x003 + int 0x10 - ; Empty tag - align 8 - dw 0 - dw 0 - dd 8 - header_end: + mov si, hello + call print + jmp $ - global boot - ;extern kernel_main - boot: - mov esp, stack_top - push esp - push ebx - push eax - cli - ;call kernel_main - hlt - jmp $ +hello db "Loading Melvix...", 0x0A, 0x0D, 0x00 -section .bss - align 32 - stack_bottom: - resb kernel_stack - stack_top: +times 510 - ($ - $$) db 0 +dw 0xAA55 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..88bcde0 --- /dev/null +++ b/src/main.c @@ -0,0 +1,6 @@ +int main(int argc, char *argv[]) +{ + while (1) { + }; + return 0; +} |