Commit Graph

1087 Commits

Author SHA1 Message Date
Bananymous df260fe0e8 Kernel: Process::validate_pointer_access now maps the whole range
This fixes a bug where userspace provided address is not fully mapped
and the kernel tries to read/write it while using PageTable fast page.

In the future userspace input should be copied on syscall entry, so
userspace could not modify the input during syscall. Currently there
is change that userspace input passes kernel syscall validation and
after that userspace could modify the input before the value is
actually used.
2024-05-24 14:14:17 +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 06f4b0b29a BAN: Make String and StringView header only
This allows linking with libc without having to link ban
2024-05-23 15:43:26 +03:00
Bananymous 83e3409bd8 Kernel/LibC: Update SYS_SEEK to return new offset and implement lseek 2024-05-23 14:49:23 +03:00
Bananymous 0af74fccda Kernel/LibC: Rework dirent structure
dirent now contains statically sized d_name. This allows using
sizeof on the name and dirent properly, which some programs seem
to be using.
2024-05-22 20:19:59 +03:00
Bananymous e77de1804f Kernel: Fix some race conditions in TCP stack
Remove race condition if two acks are to be sent one after another.

Always unblock semaphore once TCP thread has done something. This
allows better chance of TCP sending to succeed.

There are multiple places in the networking code that would require
thread-safe entering to blocking mode. I should add some API for this
so that a lot of race conditions could be removed.
2024-05-21 01:53:45 +03:00
Bananymous e00b92225d Kernel: Fix E1000 interrupt handling condition
I had written the ICR register check backwards which lead to interrupt
handling only when it was not needed, and no handling when it was
needed. This somehow still worked, just much slower often requiring tcp
resends from the server.
2024-05-21 01:52:19 +03:00
Bananymous e7e1dd91c7 Kernel: Implement ACPI reset 2024-04-22 21:12:13 +03:00
Bananymous 195c5e92a4 Kernel: Add floating bus detection for ATA Bus 2024-04-22 21:12:13 +03:00
Bananymous 26922ebb51 Kernel: Remove stack size check for keyboard layout initialization
Keyboard layout loading can take around 1 KB of stack for i686 target
2024-04-22 21:11:04 +03:00
Bananymous 693f90449f Kernel: Rework AML package and implement indexing in to packages 2024-04-19 11:26:48 +03:00
Bananymous 34b10f61ce Kernel: Make PIT reserve its IRQ
PIT did not reserve IRQ leading to kernel panic if it was being
initialized.
2024-04-18 13:34:28 +03:00
Bananymous 1479b42112 Kernel: Don't even loop over processor when system has only BSP 2024-04-18 13:33:52 +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 a698f91db4 Kernel: Fix PriorityMutex::try_lock()
Forgot to check this when I updated Mutex::try_lock()
2024-04-18 01:36:15 +03:00
Bananymous 30d12a76bc Kernel: Fix 32 bit compilation 2024-04-18 01:35:56 +03:00
Bananymous 687fa44eff Kernel: Add support for ACPI general purpose events 2024-04-17 21:51:03 +03:00
Bananymous aefb33efff Kernel: Implement dummy AML NotifyOp 2024-04-17 15:40:11 +03:00
Bananymous da0c45b7ee Kernel: Cleanup AML debug dump output 2024-04-17 15:35:42 +03:00
Bananymous 956335e844 Kernel: Implement AML WhileOp 2024-04-17 15:00:14 +03:00
Bananymous 701fc600cd Kernel: Implement evaluate and store for BankFieldElement 2024-04-17 14:59:51 +03:00
Bananymous e38b2cff4f Kernel: Implement proper synchronization for AML opregions 2024-04-17 14:59:26 +03:00
Bananymous b268293402 Kernel: Fix Buffer evaluate and store for sizes >= byte
All reads and writes were to the first byte. This patch adds the
correct offset for reading and writing.
2024-04-17 14:57:13 +03:00
Bananymous 45b9dc8be9 Kernel: Make ACPI \\_OSI return true for Linux 2024-04-17 02:19:35 +03:00
Bananymous 0ad7025a17 Kernel: Actually map FACS (and global lock) 2024-04-17 02:14:56 +03:00
Bananymous 49b7467840 Kernel: Simplify AML method invocation API 2024-04-17 01:20:58 +03:00
Bananymous a40ef610a2 Kernel: Allow demand paging only for userspace threads 2024-04-17 01:16:43 +03:00
Bananymous f9943b60e4 Kernel: Fix mutex try_lock return value
WHY IS GCC NOT COMPLAINING FROM HEADERS... I used almost 2 hours
trying to locate why AML was broken
2024-04-17 01:16:43 +03:00
Bananymous f97fb1b35d Kernel: Evaluate _REG on devices for embedded controller if needed 2024-04-17 01:16:43 +03:00
Bananymous b959181afd Kernel: Remove ACPI namespace from itself
This removes unnecessary cyclic reference
2024-04-17 00:52:05 +03:00
Bananymous cbc27a94ac Kernel: AML cleanup IfElse code 2024-04-17 00:49:07 +03:00
Bananymous 6a4f999b88 Kernel: Cleanup AML code and add evaluate for string 2024-04-16 17:39:16 +03:00
Bananymous 7707e01352 Kernel: AML add flag to force absolute lookup for ACPI namespace 2024-04-16 17:38:23 +03:00
Bananymous e667326df5 Kernel: Fix AML if parsing
Parse else case unconditionally, even if _if_ case evaluates to true
2024-04-16 17:36:04 +03:00
Bananymous f1b2d7530d Kernel: Rework AML namespace and object hierarchy
Remove tree-like structure from AML. This allows more spec compliant
parsing of named objects inside not yet declared devices.

This also allows AML to be run thread safely. All object adds/removes
are now guarded by a mutex.
2024-04-16 16:47:45 +03:00
Bananymous b6587b32b9 Kernel: ACPI ignore events from non-existent ports 2024-04-16 00:00:07 +03:00
Bananymous b89bafa165 Kernel: Add support for power button shutdown
This patch implements basic support for power button using ACPI
fixed events. I still need to implement general purpose events
and embedded controller for full power button support.
2024-04-15 23:55:25 +03:00
Bananymous 9fac5f94ba Kernel: Fix entering ACPI mode
My condition to check wheter to enter ACPI mode was incorrect.
I only entered ACPI mode if I already was in ACPI mode :DD
2024-04-15 15:05:48 +03:00
Bananymous 5affc73ee6 Kernel: Parse ACPI namespace only after TTY is initialized
This allows better debugging when there is no serial port available.
2024-04-12 16:47:17 +03:00
Bananymous 027016ddae Kernel: Load all SSDTs and PSDTs
Spec says to load all tables with unique OEM table IDs but that seem
wrong.
2024-04-12 16:45:00 +03:00
Bananymous 8f2f98b7b4 Kernel: AML implement SleepOp 2024-04-12 16:17:14 +03:00
Bananymous 6b43d12469 Kernel: AML package doesn't mark ZeroOp as NullName reference 2024-04-12 16:10:16 +03:00
Bananymous 74940ed33c Kernel: Cleanup AML code and fix bugs
I can enter ACPI mode on my own laptop!
2024-04-12 16:03:14 +03:00
Bananymous 17871bb3ca Kernel: Fix ACPI namespace initialization
ACPI spec says that only SSDTS with unique OEM table IDs are to be
loaded.

Add loading of ACPI 1.0 PSDTs
2024-04-12 12:41:30 +03:00
Bananymous 89c4abc07a Kernel: Cleanup AML device initialization
_STA and _INI are now properly called on call devices
2024-04-12 02:00:30 +03:00
Bananymous 46b5a7697c Kernel: Implement dummy \_OSI method for AML
This always returns Zero (not supported)
2024-04-12 01:49:54 +03:00
Bananymous dd8060d64f Kernel: Add FieldElement access attribute for AML interpreter 2024-04-12 01:49:15 +03:00
Bananymous afb1d7ef0c Kernel: Implement more features for AML parser/interpreter
Added
   - BankField
   - BufferField
   - PowerResource
   - ThermalZone
   - Reference
   - Package element forward declare
2024-04-12 01:47:40 +03:00
Bananymous 93ddee5956 Kernel: Implement locking for AML
Now global lock uses the actual global lock. Currenly if no lock
can be acquired, we just panic the kernel so that I remember to
implement it properly once AML is running concurrently.
2024-04-11 01:48:46 +03:00