Commit Graph

266 Commits

Author SHA1 Message Date
Bananymous 1ee37cb671 Kernel: Make sure stack is aligned on interrupts for i686 target
I just realized that only x86_64 aligns stack pointer when interrupt is
triggered.
2024-07-22 00:10:42 +03:00
Bananymous 0578d41500 Kernel: Implement WriteCombining memory
This makes framebuffer much faster on real hardware
2024-07-15 22:09:09 +03:00
Bananymous 076f1efecb Kernel: Fix 32 bit fast page locking
I forgot to change this when changing the lock type. 32 bit boots again
fine :D
2024-05-29 19:44:39 +03:00
Bananymous 53e572f072 Kernel: Fix s_fast_page_lock type on 32 bit target 2024-05-29 18:04:23 +03:00
Bananymous 2be4fe8404 Kernel: Make PageTable::s_fast_page_lock non-recursive
This lock is only used in wrapper of PageTable. There is no possiblity
of taking the lock outside of these wrappers.
2024-05-24 14:12:35 +03:00
Bananymous bb061d2a0a Kernel: Make 32bit not use large pages during boot
There is no guarantee that they are supported
2024-04-18 13:33:15 +03:00
Bananymous 061012a268 Kernel: Fix signal trampoline
32 bit did not even support it and 64 bit did not align stack
2024-04-18 13:32:40 +03:00
Bananymous e7ef7a9e55 Kernel: Implement barebones AML parser
This implements only parsing for AML in qemu. InvokeMethods are not
parsed since number of arguments to Methods is not yet known.

Parsing AML uses multiple kilobytes of stack space, so I increased
boot stack size by a lot :D

I am not sure where my own AML is going, but this is good start if
I decide to implement full ACPI on my own.

This code is very much just ugly macro expansion.

Qemu has 2 DefPackage elements that I am not able to parse. Package
data ends while there should be still multiple elements.
2024-04-07 17:03:30 +03:00
Bananymous 7ef751ba95 Kernel: Fix multiprocessor for i686
i686 is now actually ran with multiple processors.
2024-04-03 14:42:17 +03:00
Bananymous f8c01418b1 Kernel: Fix multiprocessing on x86_64
I did not even start APs after initializing them... :D
2024-04-03 14:21:55 +03:00
Bananymous d2df55b1ac Kernel: Allow booting with multiple processors on i686
Also remove unnecessary ds clearing in x86_64.
2024-04-03 02:30:38 +03:00
Bananymous 0dd74e3c9d Kernel: Implement syscalls for i686 and cleanup x86_64
This actually allows i686 to boot properly!
2024-04-03 02:23:23 +03:00
Bananymous fe386fa819 Kernel: Implement thread start trampoline for userspace
This is needed on i686 to set segment registers.
2024-04-03 00:42:39 +03:00
Bananymous 4d70322eab Kernel: Save segment registers on all interrupts on i686 2024-04-03 00:41:13 +03:00
Bananymous d9b8391968 Kernel: Fix i686 page table global mappings 2024-04-03 00:40:16 +03:00
Bananymous 2106a9e373 Kernel: Rework scheduler/processor stacks. 2024-04-02 12:34:42 +03:00
Bananymous 5050047cef Kernel: Rewrite whole scheduler
Current context saving was very hacky and dependant on compiler
behaviour that was not consistent. Now we always use iret for
context saving. This makes everything more clean.
2024-03-29 18:02:12 +02:00
Bananymous 96babec22a Kernel: Implement Thread trampolines for x86_32 2024-03-26 21:01:18 +02:00
Bananymous c12d1e9bd9 Kernel: Implement PageTable for x86_32
This is mostly copied from x86_64 with necessary modifications
2024-03-26 20:16:20 +02:00
Bananymous d7bf34ecd0 Kernel: Write isr handler for x86_32 and cleanup x86_64 2024-03-26 20:16:20 +02:00
Bananymous 1943c3e7a1 Kernel: Unify IDT and GDT code between x86_64 and x86_32
The code is pretty much the same, so there are just couple macros
differiating initialization.
2024-03-26 16:42:02 +02:00
Bananymous af050cc729 Kernel: Fix boot code for x86_32
Boot assembly now initializes processor and jumps to kernel
2024-03-26 13:25:22 +02:00
Bananymous 99e30a4d7d Kernel: Replace i386 with i686
I don't really want to be working with i386 since it doesn't support
compare exchange instruction
2024-03-26 02:48:26 +02:00
Bananymous fc7e96fa66 Kernel: Rewrite i386 boot code + linker script 2024-03-26 00:10:42 +02:00
Bananymous 097d9a6479 Kernel: Implement dummy IDT and GDT for i386 2024-03-26 00:10:42 +02:00
Bananymous 2dd0bfdece Kernel: Make i386 thread tramplines crash 2024-03-26 00:10:42 +02:00
Bananymous 26585bb1d9 Kernel: Implement signal trampoline for i386 2024-03-22 15:41:15 +02:00
Bananymous 0d92719433 Kernel: Remove old i386 spinlock code 2024-03-22 15:41:15 +02:00
Bananymous 1ab2722850 Kernel: Add PageTable stub to progress linking 2024-03-22 15:41:15 +02:00
Bananymous fe17958b9f Kernel: Rename rsp->sp and rip->ip
This makes more sense if we support i386
2024-03-22 15:41:15 +02:00
Bananymous 45cea14165 Kernel: Move sys_fork trampolines to kernel/arch/ directory 2024-03-22 12:48:54 +02:00
Bananymous 26ed689d30 Kernel: Remove old GDT, IDT and MMU code from i386
It will be easier to just rewrite them
2024-03-22 12:47:34 +02:00
Bananymous 42469b83fe Kernel: kernel panic is now sent to all processors 2024-03-15 13:45:01 +02:00
Bananymous e65bc040af Kernel: Now all active processors are used in scheduling
When a timer reschedule happens, ipi is broadcasted too all
processors for them to perform a reschedule!
2024-03-09 23:53:50 +02:00
Bananymous 89ca4c8a8b Kernel: Implement IPI broadcasting 2024-03-09 23:53:38 +02:00
Bananymous 55d2a64f54 Kernel: Map interrupt handlers for all processors
This doesn't mean that processors will actually handle the irqs
2024-03-09 23:50:57 +02:00
Bananymous 29fd682672 Kernel: Store current processor pointer in IA32_GS_BASE
This allows easier access to processors fields
2024-03-07 16:05:29 +02:00
Bananymous 54f64e7618 Kernel: Move current page table to Processor
APs can now map kernel page table and print current time!
2024-03-06 02:19:59 +02:00
Bananymous 76b0f80169 Kernel: Move IDT to Processor 2024-03-06 00:45:54 +02:00
Bananymous 58aca68726 Kernel: Move GDT to Processor 2024-03-06 00:35:45 +02:00
Bananymous 9c36d7c338 BAN/Kernel: Rework assertion/panic system
BAN/Assert.h does not need any includes meaning it can be included
anywhere without problems.
2024-03-04 11:41:54 +02:00
Bananymous 8141b9977d Kernel: Per processor information is now stored in class Processor
This allows us to allocate processor stacks, and other per processor
structures dynamically in runtime. Giving processor stack to
ap_trampoline feels super hacky, but it works for now.
2024-03-03 22:30:06 +02:00
Bananymous c035d3c82c Kernel: Start all processors on kernel boot
Processors don't do anything, except print hello message and halt.
2024-03-03 02:19:43 +02:00
Bananymous ec0cb5fd54 Kernel: Remove CriticalScopes from memory handing code 2024-02-29 19:16:41 +02:00
Bananymous d94f6388b7 Kernel: Fix all broken locks from new mutexes 2024-02-28 22:45:34 +02:00
Bananymous 9314528b9b Kernel: Improve syscall handling
Syscalls are now called from a list of function pointers
2024-02-12 21:51:11 +02:00
Bananymous 139bb5c2a5 Kernel: Fix linker script
I have no idea why rodata was executable :D
2024-01-30 17:32:50 +02:00
Bananymous dfe5a2d665 All: Cleanup all files
Add newline to end of files and remove whitespace from end of lines
2024-01-24 15:53:38 +02:00
Bananymous b0ff2392a1 Kernel: Add some helpful debug prints
Log RIP when stack pointer is out of bounds.

Log all syscalls that return ENOTSUP
2024-01-03 02:08:01 +02:00
Bananymous 001e95f973 Kernel: Optimize sse saving/loading
Only save and load sse when new thread is trying to execute sse
instruction. There is no need to do that every time we enter kernel.
2024-01-03 02:06:49 +02:00