]> git.dujemihanovic.xyz Git - nameless-os.git/log
nameless-os.git
5 months agokernel: Enable -O2 and LTO again mm
Duje Mihanović [Wed, 3 Jul 2024 17:18:44 +0000 (19:18 +0200)]
kernel: Enable -O2 and LTO again

For some reason this makes exception handling work again.

16 months agox86: mbr: Copy by dword during relocation
Duje Mihanović [Tue, 22 Aug 2023 21:23:19 +0000 (23:23 +0200)]
x86: mbr: Copy by dword during relocation

16 months agoMakefile: Update QEMU arguments to more closely match i686 hardware
Duje Mihanović [Tue, 22 Aug 2023 21:07:19 +0000 (23:07 +0200)]
Makefile: Update QEMU arguments to more closely match i686 hardware

2 years agoMerge branch 'ps2-driver' into mm origin/mm
Duje Mihanović [Mon, 22 Aug 2022 20:11:21 +0000 (22:11 +0200)]
Merge branch 'ps2-driver' into mm

2 years agokernel: Huge refactoring of tty driver
Duje Mihanović [Sat, 2 Jul 2022 12:54:37 +0000 (14:54 +0200)]
kernel: Huge refactoring of tty driver

The VGA-specific parts now reside solely at arch/x86/tty.c and the
non-arch-specific functions (kprint*) are in kernel/kprint.c.

TODO: Make kernel/kprint.c more device agnostic

2 years agokernel, stage3: Disable -O2 and -flto, enable -Og
Duje Mihanović [Sat, 2 Jul 2022 12:26:41 +0000 (14:26 +0200)]
kernel, stage3: Disable -O2 and -flto, enable -Og

This effectively reverts commit 99a0307 ("kernel, stage3: Enable -O2 and LTO by
default") and instead enables -Og to aid in debugging.

2 years agokernel: Move source files out of kernel/ directory
Duje Mihanović [Fri, 1 Jul 2022 19:57:39 +0000 (21:57 +0200)]
kernel: Move source files out of kernel/ directory

Also alphabetically sort the includes in kernel/Makefile for extra tidiness.

2 years agokernel: Don't put entry.o at beginning of binary
Duje Mihanović [Fri, 1 Jul 2022 19:51:23 +0000 (21:51 +0200)]
kernel: Don't put entry.o at beginning of binary

Since we can now parse ELF headers (which will specify the start address of the
entry function), this can be safely done away with.

2 years agoall: Export {C,LD,AS}FLAGS
Duje Mihanović [Fri, 1 Jul 2022 19:38:43 +0000 (21:38 +0200)]
all: Export {C,LD,AS}FLAGS

This makes applying custom compiler/linker/assembler flags actually work.

2 years agoall: Add $(CROSS_COMPILE) support
Duje Mihanović [Fri, 1 Jul 2022 19:31:58 +0000 (21:31 +0200)]
all: Add $(CROSS_COMPILE) support

2 years agokernel: tty: Use recursion in byte/word printing
Duje Mihanović [Wed, 29 Jun 2022 09:01:23 +0000 (11:01 +0200)]
kernel: tty: Use recursion in byte/word printing

2 years agokernel, stage3: Enable -O2 and LTO by default
Duje Mihanović [Wed, 29 Jun 2022 08:49:01 +0000 (10:49 +0200)]
kernel, stage3: Enable -O2 and LTO by default

2 years agokernel: Remove LMAs from linker script
Duje Mihanović [Tue, 28 Jun 2022 13:57:49 +0000 (15:57 +0200)]
kernel: Remove LMAs from linker script

2 years agonameless2disk: Check for root privileges
Duje Mihanović [Tue, 28 Jun 2022 13:24:52 +0000 (15:24 +0200)]
nameless2disk: Check for root privileges

2 years agoSmall changes to double fault handler
Duje Mihanović [Tue, 28 Jun 2022 11:14:03 +0000 (13:14 +0200)]
Small changes to double fault handler

Uses the panic facility committed a bit before ELF and groups the registers by
general purpose, stack, index and EIP/EFLAGS.

2 years agoComplete build system rehaul
Duje Mihanović [Tue, 28 Jun 2022 10:39:28 +0000 (12:39 +0200)]
Complete build system rehaul

Inspired by Linux, the top Makefile is more recursive and practically every
directory has its own sub-Makefile which builds or includes only code inside its
directory. This new system works beautifully with -B and parallel jobs, while
the previous one would in either case build the bootloader multiple times (and,
in the case of parallel jobs, cause weird sporadic build errors).

2 years agoRemove leftovers from new IRQ system cherrypick
Duje Mihanović [Mon, 27 Jun 2022 20:03:01 +0000 (22:03 +0200)]
Remove leftovers from new IRQ system cherrypick

2 years agoUse interrupt frame and new double fault handler
Duje Mihanović [Tue, 14 Jun 2022 09:23:08 +0000 (11:23 +0200)]
Use interrupt frame and new double fault handler

2 years agoRework interrupt handling
Duje Mihanović [Mon, 13 Jun 2022 09:41:50 +0000 (11:41 +0200)]
Rework interrupt handling

This new system should, among other things, allow for more flexibility than the
previous one.

TODO: Define interrupt stack frame

2 years agoRemove leftover paging.s from merge
Duje Mihanović [Mon, 27 Jun 2022 19:33:06 +0000 (21:33 +0200)]
Remove leftover paging.s from merge

2 years agoMerge branch 'elf' into mm
Duje Mihanović [Mon, 27 Jun 2022 19:29:50 +0000 (21:29 +0200)]
Merge branch 'elf' into mm

2 years agoFix LMAs in kernel linker script
Duje Mihanović [Sat, 18 Jun 2022 11:33:40 +0000 (13:33 +0200)]
Fix LMAs in kernel linker script

2 years agoFix various warnings
Duje Mihanović [Sat, 18 Jun 2022 08:55:25 +0000 (10:55 +0200)]
Fix various warnings

2 years agoGet memory map from BIOS E820
Duje Mihanović [Fri, 17 Jun 2022 18:47:51 +0000 (20:47 +0200)]
Get memory map from BIOS E820

The entry order is reversed, but otherwise the map makes sense. Also print the
map out to screen.

2 years agoEnable paging in bootloader
Duje Mihanović [Fri, 17 Jun 2022 08:57:56 +0000 (10:57 +0200)]
Enable paging in bootloader

This makes interrupt handling functional. The keyboard handler also tries to
read from an unmapped address to demonstrate the page fault handler.

2 years ago(VERY BROKEN) Enable paging
Duje Mihanović [Fri, 13 May 2022 12:17:31 +0000 (14:17 +0200)]
(VERY BROKEN) Enable paging

This code (somewhat) successfully enables paging and identity maps addresses
0xB8000-0xBFFFF and 0x100000-0x10FFFF. I say somewhat because enabling paging
for some reason completely breaks interrupt and exception handling, making the
CPU triple fault on any keypress or other exception. For that reason, DO NOT USE
THIS.

2 years agoDefine start and end of each section
Duje Mihanović [Mon, 9 May 2022 14:41:31 +0000 (16:41 +0200)]
Define start and end of each section

This is needed so the kernel knows what are all the memory ranges that need to
be mapped in the paging tables.

2 years agoAdd number keys to PS/2 driver ps2-driver origin/ps2-driver
Duje Mihanović [Wed, 15 Jun 2022 19:04:08 +0000 (21:04 +0200)]
Add number keys to PS/2 driver

2 years agoUse interrupt frame and new double fault handler
Duje Mihanović [Tue, 14 Jun 2022 09:23:08 +0000 (11:23 +0200)]
Use interrupt frame and new double fault handler

2 years agoRework interrupt handling
Duje Mihanović [Mon, 13 Jun 2022 09:41:50 +0000 (11:41 +0200)]
Rework interrupt handling

This new system should, among other things, allow for more flexibility than the
previous one.

TODO: Define interrupt stack frame

2 years agoFix device initialization
Duje Mihanović [Fri, 13 May 2022 14:30:18 +0000 (16:30 +0200)]
Fix device initialization

Before doing a ps2_input_wait(), the code now first reads from the data
port once (for port 1 device) or twice (for port 2 device). This makes
the PS/2 initialization work.

2 years agoAdd PS/2 driver
Duje Mihanović [Sun, 20 Mar 2022 11:36:25 +0000 (12:36 +0100)]
Add PS/2 driver

Very incomplete PS/2 driver which can currently reset the controller
(partially), accept keystrokes and supports the shift key.

TODO: Find out why testing a **PS/2 device** hangs

2 years agoLoad ELF kernel instead of flat binary 0.1.1
Duje Mihanović [Tue, 21 Jun 2022 18:40:37 +0000 (20:40 +0200)]
Load ELF kernel instead of flat binary

Also moves most of the protected mode portion of the bootloader to a C
environment rather than assembly.

2 years agoSeparate generic and arch-specific headers
Duje Mihanović [Tue, 21 Jun 2022 14:54:06 +0000 (16:54 +0200)]
Separate generic and arch-specific headers

2 years agoDelete stage3/loader.elf in bootloader Makefile
Duje Mihanović [Tue, 21 Jun 2022 14:16:40 +0000 (16:16 +0200)]
Delete stage3/loader.elf in bootloader Makefile

2 years agoAdd panic facility
Duje Mihanović [Tue, 21 Jun 2022 14:04:59 +0000 (16:04 +0200)]
Add panic facility

2 years agoAdd ability to print numbers in decimal
Duje Mihanović [Fri, 13 May 2022 18:19:23 +0000 (20:19 +0200)]
Add ability to print numbers in decimal

2 years agoAdd C code for enabling paging in bootloader
Duje Mihanović [Tue, 21 Jun 2022 13:30:41 +0000 (15:30 +0200)]
Add C code for enabling paging in bootloader

Also compile the bootloader as ELF as well for easier debugging.

2 years agoCompile stage3 in ELF format
Duje Mihanović [Sat, 18 Jun 2022 13:38:14 +0000 (15:38 +0200)]
Compile stage3 in ELF format

During linking it gets converted to a good old flat binary. This was done so
that the ELF loading code can be written in C, which will save me plenty of
headaches later.

Also, since with ELF that's possible, stack space for stage3 is now reserved and
set up in a similar (same) fashion to the kernel.

2 years agoFix LMAs in kernel linker script
Duje Mihanović [Sat, 18 Jun 2022 11:33:40 +0000 (13:33 +0200)]
Fix LMAs in kernel linker script

2 years agoFix various warnings
Duje Mihanović [Sat, 18 Jun 2022 08:55:25 +0000 (10:55 +0200)]
Fix various warnings

2 years agoGet memory map from BIOS E820
Duje Mihanović [Fri, 17 Jun 2022 18:47:51 +0000 (20:47 +0200)]
Get memory map from BIOS E820

The entry order is reversed, but otherwise the map makes sense. Also print the
map out to screen.

2 years agoEnable paging in bootloader
Duje Mihanović [Fri, 17 Jun 2022 08:57:56 +0000 (10:57 +0200)]
Enable paging in bootloader

This makes interrupt handling functional. The keyboard handler also tries to
read from an unmapped address to demonstrate the page fault handler.

2 years ago(VERY BROKEN) Enable paging
Duje Mihanović [Fri, 13 May 2022 12:17:31 +0000 (14:17 +0200)]
(VERY BROKEN) Enable paging

This code (somewhat) successfully enables paging and identity maps addresses
0xB8000-0xBFFFF and 0x100000-0x10FFFF. I say somewhat because enabling paging
for some reason completely breaks interrupt and exception handling, making the
CPU triple fault on any keypress or other exception. For that reason, DO NOT USE
THIS.

2 years agoDefine start and end of each section
Duje Mihanović [Mon, 9 May 2022 14:41:31 +0000 (16:41 +0200)]
Define start and end of each section

This is needed so the kernel knows what are all the memory ranges that need to
be mapped in the paging tables.

2 years agoMerge branch 'drive' master origin/master
Duje Mihanović [Fri, 17 Jun 2022 19:26:27 +0000 (21:26 +0200)]
Merge branch 'drive'

This way that branch can be deleted without any history being lost.

2 years agoSlightly redo informational strings in stage3
Duje Mihanović [Fri, 13 May 2022 14:40:55 +0000 (16:40 +0200)]
Slightly redo informational strings in stage3

2 years agoRevert "Remove unneeded "informational" strings from stage3"
Duje Mihanović [Fri, 13 May 2022 14:32:04 +0000 (16:32 +0200)]
Revert "Remove unneeded "informational" strings from stage3"

This reverts commit 4ea950eb2243c099968ae328ecad99f94fca8a5b.

2 years agoUse `git describe --long` as revision number 0.1.0
Duje Mihanović [Sun, 8 May 2022 13:44:13 +0000 (15:44 +0200)]
Use `git describe --long` as revision number

2 years agoFix interrupt trap gates
Duje Mihanović [Sun, 8 May 2022 12:47:14 +0000 (14:47 +0200)]
Fix interrupt trap gates

Until now the code would set the most significant bit in the type part
of the IDT descriptor for trap gates as a result of my error, causing a
triple fault when trying to handle a double fault. A less significant, but still
noteworthy change is that the double fault handler has been slightly revamped to
print out :( on a red background and no longer spits out a warning because I
accidentally wrote a string there, not a char.

2 years agoRemove unneeded "informational" strings from stage3
Duje Mihanović [Sun, 8 May 2022 12:40:49 +0000 (14:40 +0200)]
Remove unneeded "informational" strings from stage3

2 years agoDelete the old bootloader
Duje Mihanović [Sun, 8 May 2022 11:28:47 +0000 (13:28 +0200)]
Delete the old bootloader

The new FAT32 bootloader has reached feature parity with the old bootloader (can
actually load the kernel). The new bootloader also brings some nice improvements
over the old bootloader such as loading the kernel at 1MB (fixing the potential
issue that when the kernel grows large enough it will overwrite the EBDA and
upper RAM before it ever happened) and automatically adapting to the kernel
size, and as such I believe that there is no reason to keep the old bootloader
in the source tree.

2 years agoAdd installer script
Duje Mihanović [Sun, 8 May 2022 11:23:58 +0000 (13:23 +0200)]
Add installer script

This script installs the OS to a real disk drive.

2 years agoRefactor Makefile, linker script, properly set up stack
Duje Mihanović [Sat, 7 May 2022 14:11:19 +0000 (16:11 +0200)]
Refactor Makefile, linker script, properly set up stack

2 years agoAlign all sections in kernel binary to page size
Duje Mihanović [Fri, 6 May 2022 18:31:25 +0000 (20:31 +0200)]
Align all sections in kernel binary to page size

2 years agoRehaul the memory map
Duje Mihanović [Fri, 6 May 2022 17:33:45 +0000 (19:33 +0200)]
Rehaul the memory map

This was done when I realized that not enough space is allocated to load
clusters. The current map is as follows (all numbers in hex):

* 600-800: MBR
* ee00-fe00: stack
* fe00-10000: VBR
* 800-1800: temporary FAT sector
* 10000-18000: temporary cluster
* 1800-fe00: LOADER.BIN

2 years agoFAT32 bootloader boots the kernel
Duje Mihanović [Fri, 6 May 2022 16:46:48 +0000 (18:46 +0200)]
FAT32 bootloader boots the kernel

Also did a fair share of refactoring in the makefiles.

2 years agoSeparate loading clusters and cluster chains
Duje Mihanović [Sat, 30 Apr 2022 20:23:40 +0000 (22:23 +0200)]
Separate loading clusters and cluster chains

This will be crucial for stage 3 loading the kernel, because we will need to
relocate each cluster to 0x100000 (or somewhere after that) manually, and we
can't just do that in the driver as it's also used by the VBR which does not run
in unreal mode.

2 years agoFixes and improvements to FAT32 driver
Duje Mihanović [Sat, 30 Apr 2022 14:35:18 +0000 (16:35 +0200)]
Fixes and improvements to FAT32 driver

* Fix issue where multiple clusters would be loaded 0x800 apart rather than
  contiguously.
* Get rid of some global variables, saving space.
* si points to the start LBA address rather than the partition table entry,
  saving a bit of space as we no longer need to use offsets.
* In read_cluster_chain, drop push/popad as they in fact do not
  save the upper 16 bytes of the registers. Instead, just push
  and pops the registers that are used.

2 years agoWIP: Add new FAT32 bootloader
Duje Mihanović [Wed, 27 Apr 2022 15:47:44 +0000 (17:47 +0200)]
WIP: Add new FAT32 bootloader

Loads a LOADER.BIN which currently prints a hello message.

TODO: Make it actually load the kernel.

2 years agoRemove unused protected-mode print routine
Duje Mihanović [Sun, 20 Mar 2022 13:51:56 +0000 (14:51 +0100)]
Remove unused protected-mode print routine

2 years agoSlim down print.s
Duje Mihanović [Sun, 20 Mar 2022 11:43:11 +0000 (12:43 +0100)]
Slim down print.s

2 years agoFix keyboard interrupts
Duje Mihanović [Sat, 12 Mar 2022 12:28:35 +0000 (13:28 +0100)]
Fix keyboard interrupts

3 years agoSimplify Makefile
Duje Mihanović [Sun, 17 Oct 2021 11:19:52 +0000 (13:19 +0200)]
Simplify Makefile

3 years agoHandle interrupts
Duje Mihanović [Wed, 22 Sep 2021 20:15:40 +0000 (22:15 +0200)]
Handle interrupts

Currently handles exception 8 and IRQ 1. EXC8 is double fault, and IRQ1 is
keyboard. EXC8 handler puts out a ':(' on the top left corner of the screen and
halts the machine, while IRQ1 puts out a string on the screen. However, it will
only do so once, and I have yet to figure out why.

3 years agoMore features in VGA driver
Duje Mihanović [Thu, 16 Sep 2021 17:38:34 +0000 (19:38 +0200)]
More features in VGA driver

Now supports color (specify color when using kprint) and moves the VGA cursor as
it prints.

3 years agoAlso compile kernel as ELF for easier disassembly
Duje Mihanović [Thu, 16 Sep 2021 14:48:26 +0000 (16:48 +0200)]
Also compile kernel as ELF for easier disassembly

3 years agoEnable A20 gate
Duje Mihanović [Thu, 16 Sep 2021 14:41:24 +0000 (16:41 +0200)]
Enable A20 gate

3 years agoRestructure the bootloader
Duje Mihanović [Thu, 9 Sep 2021 09:13:53 +0000 (11:13 +0200)]
Restructure the bootloader

3 years agokprint can accept a const string
Duje Mihanović [Thu, 9 Sep 2021 08:27:18 +0000 (10:27 +0200)]
kprint can accept a const string

3 years agoBetter gitignore and tidier string
Duje Mihanović [Wed, 8 Sep 2021 08:43:37 +0000 (10:43 +0200)]
Better gitignore and tidier string

3 years agoEnable generation of debug symbols for C source files
Duje Mihanović [Wed, 8 Sep 2021 08:04:10 +0000 (10:04 +0200)]
Enable generation of debug symbols for C source files

3 years agoAdd linker script and partial VGA driver
Duje Mihanović [Tue, 7 Sep 2021 20:05:14 +0000 (22:05 +0200)]
Add linker script and partial VGA driver

3 years agoDocument the code
Duje Mihanović [Tue, 7 Sep 2021 18:33:39 +0000 (20:33 +0200)]
Document the code

3 years agoA new beginning
Duje Mihanović [Tue, 7 Sep 2021 09:25:40 +0000 (11:25 +0200)]
A new beginning

This boots into protected mode, prints a string from assembly and then prints an
A from a minimal C kernel.

3 years agoAllow controlling (no) newline when printing and listen to keystrokes
Duje Mihanović [Sat, 21 Aug 2021 15:06:36 +0000 (17:06 +0200)]
Allow controlling (no) newline when printing and listen to keystrokes

3 years agoRead bytes from boot drive
Duje Mihanović [Sat, 21 Aug 2021 16:24:44 +0000 (18:24 +0200)]
Read bytes from boot drive

3 years agoAllow controlling (no) newline when printing and listen to keystrokes
Duje Mihanović [Sat, 21 Aug 2021 15:06:36 +0000 (17:06 +0200)]
Allow controlling (no) newline when printing and listen to keystrokes

3 years agoAdd Makefile
Duje Mihanović [Sat, 21 Aug 2021 11:00:34 +0000 (13:00 +0200)]
Add Makefile

Can compile, clean and run the boot sector.

3 years agoAdd print function with some examples
Duje Mihanović [Sat, 21 Aug 2021 10:56:47 +0000 (12:56 +0200)]
Add print function with some examples

3 years agoCan now print hexadecimal numbers
Duje Mihanović [Sat, 21 Aug 2021 10:00:08 +0000 (12:00 +0200)]
Can now print hexadecimal numbers

3 years agoAdd basic bootsector
Duje Mihanović [Fri, 20 Aug 2021 14:46:08 +0000 (16:46 +0200)]
Add basic bootsector

It prints out "Gotta start somewhere". Tested on QEMU and even on real hardware
with success.