https://github.com/embeddedos/larvaos
A multitasking operating system and kernel with an interactive shell.
https://github.com/embeddedos/larvaos
kernel osdev x86
Last synced: 11 months ago
JSON representation
A multitasking operating system and kernel with an interactive shell.
- Host: GitHub
- URL: https://github.com/embeddedos/larvaos
- Owner: EmbeddedOS
- Created: 2022-09-04T04:54:17.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-08T15:34:14.000Z (almost 3 years ago)
- Last Synced: 2024-07-08T15:14:26.514Z (over 1 year ago)
- Topics: kernel, osdev, x86
- Language: C
- Homepage:
- Size: 315 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LarvaOS
A multitasking operating system and kernel with an interactive shell.
## Using bless command to see our kernel image
bless - graphical hexadecimal Gtk# editor.
Edit the FILEs as a `sequence of bytes`, allowing read/write, search, pattern finding, efficient query-replace, multi-tabbing, customized data-views, plugins, and many other features. Using bless command:
```bash
bless ./bin/LavaOS.img
```
## Run your OS using qemu
```bash
qemu-system-x86_64 -hda ./bin/LavaOS.img
```
## Using cross compiler
```bash
./bin/cross/bin/$TARGET-gcc --version # For compile C files.
./bin/cross/bin/$TARGET-g++ --version # For compile C++ files.
./bin/cross/bin/$TARGET-ld # Linker.
```
## Assemble a assembly file with nasm
```bash
nasm -f bin file_name.asm -o file_name.bin
```
To disassemble it, simply using `ndisasm` command:
```bash
ndisasm boot.binemu-system-x86_64 -hda file_name.bin -S -gdb stdio
```
## Debug my kernel image with gdb
NOTE: We should use kernel.elf (kernel image) to add symbol instead of using disk image.
First, entering to gdb mode:
```bash
gdb
```
Adding traceable symbol file:
```bash
add-symbol-file /bin/kernel.o 0x0100000
```
Set break point in symbol:
```bash
break kernel_entry_point
```
Start debugging with remote target:
```bash
target remote | qemu-system-x86_64 -hda ./bin/LavaOS.img -S -gdb stdio
```
Switching to assembly:
```bash
layout asm
```
And step by step.
prints out registers in both raw format (hex) and natural format in gdb:
```bash
info registers
```
## debug variable
```bash
gdb
```
In gdb:
```bash
add-symbol-file ./src/kernel/core/kernel.o 0x0100000
target remote | qemu-system-x86_64 -hda ./bin/LavaOS.img -S -gdb stdio
# Set break point in file-line
break kernel.cc:21
# continue
c
# print value of ptr variable
print ptr
```
## mount the disk image to your host
```bash
sudo mount -t vfat ./bin/LavaOS.img /mnt/d/
# do some thing ...
sudo umount /mnt/d/
```