Commit Graph

88 Commits

Author SHA1 Message Date
0bece8a54c Kernel: Add missing ACPI resource header 2025-08-19 16:23:30 +03:00
c2017a5181 Kernel: Allow looking up devices with multiple eisa ids
Also match against _CIDs in addition to _HID
2025-08-15 17:02:15 +03:00
58ad839136 Kernel: Add support for ACPI Embedded Controllers 2025-08-15 17:02:15 +03:00
3960687f9d Kernel: Parse PCIConfig opregion address on read/write
I was testing on some hardware and _ADR does not have to exist in the
namespace when opregion is parsed :)
2025-07-16 15:34:36 +03:00
995dfa1455 Kernel: Fix AML PCIConfig OpRegion accesses
Apparently I'm not supposted to calculate device/function from the
offset, but parse them from the acpi namespace :)

This allows PCI PIN interrupt routing actually work
2025-07-04 13:21:02 +03:00
27613da5ea Kernel: Route PCI Interrupt Link Device interrupts 2025-04-01 23:09:30 +03:00
0474ac4262 Kernel: Expose ACPI resolve_package_element to outside 2025-04-01 23:09:30 +03:00
aba49cc93f Kernel: Add API to get ACPI reference paths 2025-04-01 23:09:30 +03:00
0e085b30cc Kernel: ACPI add easier API for calling methods with arguments 2025-04-01 23:09:30 +03:00
35149b6960 Kernel: Add helper functions to create AML String and Buffer 2025-04-01 23:09:30 +03:00
3800d5420e Kernel: Collect created AML nodes in add_{named,alias}...
This makes it harder to miss adding scoped objects. Before I was not
deleting all types of nodes on method return
2025-04-01 23:09:25 +03:00
b145c1ab64 Kernel: Add easier api for evaluating ACPI nodes 2025-04-01 23:09:20 +03:00
b8a3439219 Kernel: Add getter for ACPI namespace 2025-04-01 23:09:15 +03:00
a5cf92b2ff Kernel: Use uint64_t instead of size_t for AML node conversion
This allows 32 bit to compile again :)
2024-12-30 06:27:49 +02:00
3a6cdfff45 Kernel: Fix ACPI namespace initialization
Now _REG, _STA, _INI are called in the order my laptop expects them to
be called. This was kinda weird because what uACPI was doing did not
work.

\_SB_.PCI0.LPC0.EC0_.BAT0._STA required \_SB_.PCI0.LPC0.EC0_._REG to be
called
\_SB_.PCI0.LPC0.EC0_._REG required \_SB_.PCI0._STA to be called

Now I call all the _REG methods of a device after calling _STA/_INI and
after performing the whole _STA/_INI sequence i call rest of missing
_REG functions
2024-12-18 18:30:45 +02:00
1b94957b07 Kernel: Copy AML NameString base when moving it :) 2024-12-18 18:28:16 +02:00
4e364bd2f6 Kernel: Add support for ACPI Control Method Batteries
The implementation is kinda weird but it exposes some battery
information to userspace!
2024-12-18 14:06:32 +02:00
437fa45ca2 Kernel: Add helper to find ACPI devices with EISA id 2024-12-18 01:45:00 +02:00
7eb186dad4 Kernel: Add to_sv() helper for AML String 2024-12-18 01:43:46 +02:00
2259614640 Kernel: Remove unused function from ACPI namespace 2024-12-18 01:43:04 +02:00
869f4011a1 Kernel: Replace the old AML interpreter by a new, better one
The old AML interpreter was trash and did not follow value/reference
semantics at all. It was also super slow, one of my machines taking over
7 seconds to parse ACPI namespace and call _INI and _STA.
2024-12-17 03:36:33 +02:00
4149748766 Kernel: Add missing include in ACPI headers 2024-12-01 21:32:34 +02:00
076001462e Kernel: Implement AML ConcatOp 2024-11-22 22:23:07 +02:00
d2e1d8ec13 Kernel: Implement AML NotOp 2024-11-22 22:22:44 +02:00
30ceaa6bef Kernel: Implement AML ToHexStringOp 2024-11-22 22:22:27 +02:00
b41738b47b Kernel: Fix ACPI name formatting functions 2024-09-14 19:39:13 +03:00
c65613901f Kernel: Fix AML aliases and package elements 2024-09-10 16:18:42 +03:00
40c6989374 Kernel: Implement AML ObjectTypeOp 2024-08-18 20:51:10 +03:00
0fa16cf982 Kernel: Fix and add some AML to_underlying functions 2024-08-18 20:44:51 +03:00
490a28ee7a Kernel/AML: General cleanup and compliance improvements 2024-08-15 23:14:13 +03:00
d729d7f570 Kernel: Implement AML storing to Buffer 2024-08-15 23:12:52 +03:00
6408bb2efa Kernel: Add AML API for getting underlying value of nodes 2024-08-15 23:11:59 +03:00
d8dabab4fb Kernel: Implement AML CopyObjectOp 2024-08-15 20:55:55 +03:00
4dc107f77a Kernel: Fix AML Register/Reference accesses 2024-08-15 20:55:18 +03:00
eaf06d239c Kernel: Cleanup and fix AML Method calls 2024-08-15 20:54:55 +03:00
d9b3a4bf77 Kernel: Add more conversions for AML Integer, Register, String 2024-08-15 20:51:04 +03:00
cf970d5914 Kernel: Add better conversion for AML Alias, Name and Reference 2024-08-15 20:48:35 +03:00
1cfe3dd4da Kernel: Implement AML BreakOp and ContinueOp 2024-08-15 19:08:00 +03:00
51d1e47bfe Kernel: Fix AML CreateFieldOp to take bit index instead of byte index 2024-08-15 19:05:58 +03:00
e0a447bfaf Kernel: Add _GL to ACPI root namespace 2024-08-15 02:28:22 +03:00
3f5ee6f414 Kernel: Rewrite the AML conversion API
This doesn't currently make the interpreter any better, but it will make
further implementation easier to be spec (or hardware...) compliant
2024-08-15 02:25:45 +03:00
44d5c8c4b4 Kernel: Implement AML To{Buffer,Integer,String}Op 2024-08-14 20:28:32 +03:00
17b7e9e772 Kernel: Allow all named objects to fail cleanly if name exists 2024-08-14 20:28:00 +03:00
37d5b60f5c Kernel: Implement AML {Event,Reset,Signal,Wait}Op 2024-08-14 11:59:34 +03:00
feadea0e91 Kernel: Fix AML unaligned integer reads and buffer shifts over 32 2024-08-13 23:44:17 +03:00
f71a29b6c4 Kernel: Implement AliasOp for AML interpreter 2024-08-13 22:42:37 +03:00
ec4cfdee23 Kernel: Fix and cleanup a lot of AML code
Node now have APIs to convert them to buffer, integer and string. This
allows possibility to handle methods that need explicitly use one of the
overloads instead of integer.

This patch also adds handling of DebugOp. This is used quite heavily in
uACPIs test suite.
2024-08-13 22:42:37 +03:00
dd79db6383 Kernel: AML implement CreateFieldOp 2024-08-13 18:52:48 +03:00
f8261c60c0 Kernel: Rewrite the whole scheduler and re-architecture SMP handling
Change Semaphore -> ThreadBlocker
  This was not a semaphore, I just named it one because I didn't know
  what semaphore was. I have meant to change this sooner, but it was in
  no way urgent :D

Implement SMP events. Processors can now be sent SMP events through
IPIs. SMP events can be sent either to a single processor or broadcasted
to every processor.

PageTable::{map_page,map_range,unmap_page,unmap_range}() now send SMP
event to invalidate TLB caches for the changed pages.

Scheduler no longer uses a global run queue. Each processor has its own
scheduler that keeps track of the load on the processor. Once every
second schedulers do load balancing. Schedulers have no access to other
processors' schedulers, they just see approximate loads. If scheduler
decides that it has too much load, it will send a thread to another
processor through a SMP event.

Schedulers are currently run using the timer interrupt on BSB. This
should be not the case, and each processor should use its LAPIC timer
for interrupts. There is no reason to broadcast SMP event to all
processors when BSB gets timer interrupt.

Old scheduler only achieved 20% idle load on qemu. That was probably a
very inefficient implementation. This new scheduler seems to average
around 1% idle load. This is much closer to what I would expect. On my
own laptop idle load seems to be only around 0.5% on each processor.
2024-07-22 00:33:50 +03:00
60a05412c9 Kernel: ACPI implement SizeOf 2024-06-25 23:24:51 +03:00