#uACPI - a portable and easy-to-integrate ACPI implementation
1 messages · Page 8 of 1
maybe not thousands but hundreds definitely
tbh if uACPI proves itself worthy (for hobby osdev it already has) i don't see why they wouldn't consider it
yeah, maybe something simpler like reactos or some of the bsds could be a cool start
yeah
i've talked to the person from the reactos team before and they're interested in doing that
they are targeting XP-levels of compat right?
atm yes
they probably have weird machines it would be beneficial for uacpi as well
getting tested on xp-era real hardware
yeah
although just aml wise uacpi is tested against all publically available aml blobs atm
~350 machines
anyhow uACPI is so cool I will definitely consider contributing after I use it in my OS
well thank you
that's all the total public aml blobs?
What AML interpreter does reactos use?
350 dumps from pcs, but its a lot more tables ofc
would it help if I share my own devices AML
so like 350 * ~15 tables
ah
sure, acpidump > dump.txt
linux kernel has weird logs i don't understand at boot
ACPICA
ok will do so
Would be most appreciated if u PR that to this repo
https://github.com/UltraOS/ACPIDumps
oki
all of these blobs are fed to uacpi on every commit to the repo, so u will be part of the history forever
is upstream dead?
yeah, the source repo is dead unfortunately so i had to fork it
ah
if they do revive it i will pr my downstream changes
the beauty of the
🎉 *** U N I X P H I L O S O P H Y *** 🎉
hw-probe being a 20000 line perl script still triggers me 
I looked at the hw list and I found one of my test subjects on it
which is cool ig
how do I add my thing
acpidump > dump.txt and then just put it In the right location
Ikr
where to get that hwid
do you need .bin files or no
and how would i name the files?
Good question
i think i should upload to linux-hardware.org then download it off them
You could take a look at that probing script to figure out how it comes up with that id string
it gives a url no?
Hmm maybe
ccp
omg my laptop has the chinese communist party
no i can't find that
this is the probe
there is no hwid anywhere
WAIT
there's this hwid
F7FA2
but that's much shorter
i think their hwid stuff changed between the latest version of the acpidump repo
and the latest hw-probe
i wonder if it's some kind of hash
Honestly if it's impossible to tell what it is, u can just put whatever random hash u want
Sounds good to me
tho linux-hardware.org says it's generated from a hash that includes devices and a salt and mine isn't stock
i have a adata nvme ssd instead of whatever the default is
so literally only mine will generate this hwid
so it's absolutely useless
but anyhow
I mean you do put it under vendor/model thing though
ping me when you review the PR
i'm not sure i did it correctly
https://github.com/UltraOS/ACPIDumps/pull/1 wow 13k lines
Not sure how the HWIDs are generated, this HWID is taken from hw-probe results uploaded to linux-hardware.org
biggest PR i ever did 😳

now i wonder if it's possible to easily dump these from windows
or I can use a live usb ig
acpidump is available on windows as well
Thanks a lot, I will take a look
I wish there was a tool to extract the tables from BIOS update images.
Well they're generated at runtime soo
the name of the file should be <hash>.bin
just <hash> is the disassembled dump
just flash it and dump it then :^)
Well emulate in this case, specifically the machines with ACPI that 86box can emulate 
I’ve done a little work, which I’ve been meaning to continue at some point, to figure out the first machines/motherboards that shipped with ACPI
I figure those are likely to have eldritch horrors and would stress test uACPI nicely 
damn yeah that would be cool to know
it would be cool if uacpi supports a table dump to heap function
why do u want that?
it would aleviate the need to expose acpi data to other programms and could help in debugging if you can get the acpi data "early" in the boot process
just a idea
But u can just do that yourself, get the table, allocate a heap buffer, memcpy it?
does a acpi dump contain personal information of some kind?
yea, is the dump format specified somewhere?
There's a table which contains your OEM windows activation key
Other than that no
U can remove that
i was thinking about once my os gets somewhere to auto dump acpi on a new install and push it to the repo
Sure sounds cool if the user is okay with sharing that sort of data
does acpi contain hardware ids or other indentifications that can be used to reliably identify the origin?
Nah
Some kind of bootable image that dumped the tables would be nice, though you’d have to decide how/where to store the dump.
QR codes obviously 
Yea...
Serial might be doable for older machines
didnt someone accidentally send a dump with theirs here lmao
If it's a live usb dump to a folder there
Yeah lol
Does a efi exe has access to acpi data?
Then making a live usb would be relatively easy
Ofc
that was me
(whoops)
Also me, but I quickly realised
that might be me too idk
if the pr i sent has that it's yours idc
i will pirate windows if i ever install it on this machine
i thought this was the disassembled dump
the table that contains the oem key is actually pretty funny, the public ms spec for it says that it contains proprietary data after the standard acpi header yet its documented in an old non-accepted patent (well they did change some fields to 64-bit but other than that its still the same as far as I could tell)
Nop
how do I get the disassembled dump then?
i think there are other acpi* tools one of them should be it
It's not needed
Just rename the current file
Look at other examples named .bin in this repo and compare contents yours
ah
done
Thanks a lot, merged!
I created a pr for my laptop too
Merged as well, thanks for your contribution!
nice!
You talked about working together with some guy (from apica?) for developing acpi tests. What happened?
And did you guys start the test suite?
given intel right now they probably got laid off or demoted
after a long time of trying to understand how the link between PCI <-> ACPI <-> hal works in Windows 2003, vista and 10 and trying to fix some of the core issues there locally so i can even start this.
Time has begun to start this lol
wow, this is so cool
damn that is cool
Nice!
nice 👍
Good luck 🙏
i agree!
alright, thats enough time wasted on minecraft and cs2
time to get back to the thread safety pr
i just had an insanely annoying week at work so no mental capacity to do anything
do you want to waste more time on an osdev mc server?
minecraft seems to be many people in this server's way of procrastinating, myself included.
true
uacpi_status uacpi_rw_lock_read(struct uacpi_rw_lock *lock)
{
uacpi_status ret;
ret = uacpi_acquire_native_mutex(lock->read_mutex);
if (uacpi_unlikely_error(ret))
return ret;
if (lock->num_readers++ == 0) {
ret = uacpi_acquire_native_mutex(lock->write_mutex);
if (uacpi_unlikely_error(ret))
lock->num_readers = 0;
}
uacpi_kernel_release_mutex(lock->read_mutex);
return ret;
}
I think this should work
uacpi_status uacpi_eval(
uacpi_namespace_node *parent, const uacpi_char *path,
const uacpi_args *args, uacpi_object **out_obj
)
{
struct uacpi_namespace_node *node;
uacpi_object *obj;
uacpi_status ret = UACPI_STATUS_INVALID_ARGUMENT;
if (uacpi_unlikely(parent == UACPI_NULL && path == UACPI_NULL))
return ret;
ret = uacpi_namespace_read_lock();
if (uacpi_unlikely_error(ret))
return ret;
if (path != UACPI_NULL) {
ret = uacpi_namespace_node_find_permanent(parent, path, &node);
if (uacpi_unlikely_error(ret))
goto out;
} else {
node = parent;
}
obj = uacpi_namespace_node_get_object(node);
if (obj->type != UACPI_OBJECT_METHOD) {
if (uacpi_unlikely(out_obj == UACPI_NULL))
goto out;
*out_obj = uacpi_create_object(UACPI_OBJECT_UNINITIALIZED);
if (uacpi_unlikely(*out_obj == UACPI_NULL)) {
ret = UACPI_STATUS_OUT_OF_MEMORY;
goto out;
}
ret = uacpi_object_assign(
*out_obj, obj, UACPI_ASSIGN_BEHAVIOR_DEEP_COPY
);
} else {
uacpi_namespace_read_unlock();
uacpi_namespace_write_lock();
ret = uacpi_execute_control_method(node, obj->method, args, out_obj);
uacpi_namespace_write_unlock();
return ret;
}
out:
uacpi_namespace_read_unlock();
return ret;
}
Finally, fully thread safe uacpi_eval
actually there's still a race here between read_unlock and write_lock, if some other AML code manages to CopyObject to this node in between these two calls
so i guess eval has to take the write lock always
U CANNOT AVOID ADDICTION TO VIDEO GAMES NO MATTER HOW OLD U ARE 
nah you get less interested with age, trust me bro™️
it's the opposite for me
nuh uh
new PR dropped
I didn't know that uacpi_find_devices_at also checks against _CID, which is nice
and it wasn't immediately obvious without looking into the impl
yeah thanks for the changes
your pr died on this 
fucking ubuntu got upgraded i guess
ill merge without it
do uwanna fix it 
sure, can do
thanks!
i already had this for macos lol
i guess now its needed for ubuntu as well
how dare you break my packages!!!!!111!!
this is github CI
it creates a new vm for each run so i would only break my own packages in this case
alright new commit on the PR
based
daamn you made the 800th commit @kindred beacon
you get a medal now
🏅 ig this one
ngl I should set that up for obos (todo)
Yeah it is, well worth it too
okay uhh im back
i accidentally regressed ACPICA so gotta fix that first
wtf happened to my clion
yeah ikr, i noticed its really lacking in acpica so linux kernel has to make very awkward workarounds with global booleans
Since ACPI spec introduced CopyObject real AML thread safety is now insanely difficult
if u have a pointer to a namespace node and u want to have an object at it u must do
namespace_write_lock();
obj = namespace_node_get_object(node);
uacpi_object_ref(obj);
uacpi_namespace_write_unlock();
otherwise someone can do CopyObject to this node, which would overwrite the object stored at the node, and you're left with a dangling pointer
thats why public uACPI API will not expose get_object and force the host to obtain a deep copy via uacpi_eval
If CopyObject didnt exist namespace nodes become immutable
And any stores to them only implicit cast store to an already existing object
so its safe to just node->obj
and the funniest thing is basically very few aml blobs use CopyObject
but since it exists u must guard against this
Imagine if someone could CopyObject in python and transform a method into an integer, or transform a class into a method
seems insane doesnt it?
well aml doesnt think so
and a method can CopyObject into itself while its executing too
Method (FOO) {
CopyObject(123, FOO)
}
AML was insane from the start smh
FOO is now an integer 123 but its still being executed
This is what ACPICA thinks about this
ACPI Exec: Segmentation Fault
yeah it was actually
they had an Unload opcode
u can unload arbtirary shit form the namespace
it was removed because of complete insanity of that idea
Lovely
uACPI also doesnt like this
==379==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000000ec8 at pc 0x555e542f8e2e bp 0x7ffdbf417cc0 sp 0x7ffdbf417cb0
But in uACPI its an easy fix
in ACPCIA its impossible to fix because they dont separate the idea of an object and a namespace node
This makes me want to fuzz uacpi
it has been fuzzed by qookie quite extensively
but i guess the fuzzer is not smart enough to come up with this
0x603000000ec8 is located 24 bytes inside of 32-byte region [0x603000000eb0,0x603000000ed0)
freed by thread T0 here:
#0 0x7f4e4c7ba537 in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:127
#1 0x55b8c1817293 in uacpi_kernel_free /mnt/d/uACPI/tests/runner/interface_impl.cpp:253
#2 0x55b8c1896888 in free_method /mnt/d/uACPI/source/types.c:618
#3 0x55b8c18f5952 in uacpi_shareable_unref_and_delete_if_last /mnt/d/uACPI/source/shareable.c:58
#4 0x55b8c1896b91 in free_object_storage /mnt/d/uACPI/source/types.c:637
#5 0x55b8c1897029 in free_object /mnt/d/uACPI/source/types.c:678
#6 0x55b8c189746e in free_chain /mnt/d/uACPI/source/types.c:724
#7 0x55b8c18976b2 in uacpi_object_unref /mnt/d/uACPI/source/types.c:762
#8 0x55b8c189a072 in uacpi_object_detach_child /mnt/d/uACPI/source/types.c:957
#9 0x55b8c18c4aa9 in object_replace_child /mnt/d/uACPI/source/interpreter.c:2165
#10 0x55b8c18c4cba in copy_object_to_reference /mnt/d/uACPI/source/interpreter.c:2217
#11 0x55b8c18dde31 in handle_copy_object_or_store /mnt/d/uACPI/source/interpreter.c:4176
#12 0x55b8c18e6c70 in exec_op /mnt/d/uACPI/source/interpreter.c:5343
its funny u can see it being freed in CopyObject
handle_copy_object_or_store
and in ACPICA
i opened an issue there
@mortal yoke btw try this piece of code in your interpreter
DefinitionBlock ("", "SSDT", 1, "", "", 0)
{
Method (FOO) {
CopyObject(123, FOO)
Return (1)
}
Debug = FOO()
}
or do an atomic load
that doesnt help with a dangling pointer issue
rcu'd atomic load?
u atomically load a pointer that has been freed
hm?
put the load behind rcu
and the freeing is deferred by rcu
so that you can't get a stale pointer there
RCUs is probably not something i want to require from a kernel api
you can just do like
barely anyone has it
true
you can play lots of other clever games too
just ignore the issue like acpica 
yeah i guess
and the load isn't a gc safepoint
if u do a garbage collector
ACPICA segfaulting doesn't sound good ngl
i wonder what mlua does for this since it has to keep rust safety guarantees and lua can basically do this
I don't know how much of a security implication ACPI can play but rofl would be funny if literally allowed code causes a exploit
AML is supposed to be trusted code i guess
oh it already does
since it can already do arbitrary writes to any memory
yeah good question
Fair point
I'd still treat it as untrusted code on principle 
i try to do it for uacpi yeah
i dont allow edge cases to break anything
this one i discovered today while implementing thread safety
it literally doesn't do anything 
wdym lol
can it?
dont think it can
does it print 1?
no
no it doesn't hang anywhere either
what does CopyObject actually do?
is it just FOO = 123?
replace the object at the node
wdym? can lua replace a function with another value? yes
this implicit casts
what kind of drugs is aml on?
no thats not the thing here clearly
and if I add Debug = whatever before and after the Debug = FOO() both of those are printed but not the FOO
FOO = 123 would implicit cast 123 to whatever the type of FOO is
then store it there
not replace the object itself but its value
CopyObject replaces the object itself
very hard ones
guess i'd need to implement an interpreter to understand this crap
within lua it wouldn't be a huge issue but if you're interacting with it through the C api and you get a pointer to an object and the lua code sets it to something else and then the pointer would be dangling (if the GC triggers
uacpi uses reference counting atm yeah
which so far has allowed to sovle all edge cases
id need to look into it
GC is not that hard yeah
no idea how it works
you just do DFS over objects
but idk if it would help
the thing is acpica has existed for 20 years with this issue and no one complained
even though it segfaults if u blow on it
so idk if its worth investing that much into that
but probably
does acpi.sys handle this?
lmao
does code that does this exist in the wild?
well i only have access to 500 blobs
but id hope not
but its kinda silly to say well this turing complete language can segfault me but surely no one will write code like that
at least i want to try and solve most issues like that
oh right I don't print anything else than strings in aml debug 
yeah it just prints 1
im so confused what is an object in AML then?
and what is a method????
what is anything anymore
the thing behind a label
u can think of it like assembly labels
thats not very helpful
a method is just an object type
yeah with asan + ubsan ```
DefinitionBlock ("", "SSDT", 1, "", "", 0)
{
Method (FOO) {
CopyObject(123, FOO)
Return (1)
}
Debug = FOO()
Debug = FOO()
}
nice
ok let me try to explain
AML is similar to python in that u execute top-down and have a collection of named things, e.g. in python u would have
# printed right away
print("hello world")
# not printed right away
def foo():
print("foo")
this much u understand right?
yes
in aml the idea of a name and an object is slightly detached, an object can exist standalone and also a labeled thing:
// prints 123
Debug = 123
// Create a name FOO and attach an integer 123 to it
Name (FOO, 123)
// Prints 123
Debug = FOO
that's like any programming language i guess?
(also the syntax with Debug = FOO is cursed wtf)
you can also do Printf and the compiler will expand it to a series of stores to Debug
if i do
FOO = "hello"
this will do memcpy(&FOO.object.integer, "hello", min(FOO.sizeofstorage(), strlen("hello"))
so only the underlying contents of the integer stored at FOO change
in that sense objects in AML are immutable
e.g. strings and buffers stay the same length etc
but then they add CopyObject
Which breaks this paradigm and now u can replace the object stored at FOO entirely
huuuuh wtffff thats so cursed
yup
doesnt this mean that if you do Name(FOO, "Text") FOO = 123 Debug = FOO you print the string at address 123?
which is definitely garbage
that will memcpy a qword 123 to Text
ah okay
the first 4 bytes of it
stupid
yup
i have an example on my README
ACPICA does an even stupider thing that literally no one expects
they allow buffer size mutation
a pitust aml interpreter would be interesting to see 
with garbage collection and stuff
yeah it's an interesting idea
it would probably allow for proper JIT
and getting rid of the GIL
not that anyone needs that
ok i took a look at lua and mlua (rust bindings to lua, luajit and luau)
basically it forces you to store stuff in lua's ffi State, so the lua GC is still aware of it and the ""dangling"" thing will not be freed. in C i guess if you don't store it in the ffi State, then you can still cause a dangling pointer, but in rust mlua doesn't let you keep a strong reference to objects unless you store it in the ffi State
you can still keep a &Value weak reference
this also enables handles to scoped values to be trivially leaked from the given callback. This is not dangerous, though! After the callback returns, all scoped values are invalidated, which means that though references may exist, the Rust types backing them have dropped. Function types will error when called, and AnyUserData will be typeless. It would be impossible to prevent handles to scoped values from escaping anyway, since you would always be able to smuggle them through Lua state
so everything is either a Weak reference or a strong reference stored in the lua State
fuck, most of these are not thread safe
Say thank you it doesn't use the JVM
jvm is actually pretty nice except for some of the weird stuff like invokedynamic
I don't want jvm in my kernel
jvm in kernel is cursed but also has been done before iirc
Tbf idk anything about jvm only java
And about every decision they did was stupid
At least up to java 8 I stopped following after that :^)
aml shouldve been lua smh
yayy
aml should've been Fallout's papyrus
if i ever design hardware and decide to do smth other than ACPI
or just regular DTBs
i will consider lua
aml should've been x86 machine code
Tbh lua doesn't really fit with only having number and no builtin bitwise operations
Like AML is not that bad
It has a few retarded encoding and opcodes decisions
well then either the motherboard would need to include multiple copies of it for 32 bit and 64 bit oses or the os would need to change modes to call it
just ship an x86 interpreter instead of an AML one :^)
what about JS?
they arguably have ints
and they have bitops
and strings
and its a standard
wasm :^)
<insert any language>
C
++
aml shouldve been ia64 machine code on itanium systems
about to try out the new early table access api
lemme know how it goes!
it went well
yes, a new structure's beginning to emerge
principle is per-numa-loaclity-domain page queues/freelist, page writeback daemon, etc
first hobby os with numa support
Big
RicerCA might have gotten there first
never heard of it
infy i love u
unfortunately systemd is not fixable
I mean they're isnt really anything to fix, its just a firmware bug that generally shouldn't affect runtime
Although acpica probably aborts the entire namespace in that case, which would skip all other named objects that might be there, which might create even more problems
uACPI just skips the opcode in this case
yeah it doesn't affect anything other than my annoyance
haven't had any yet
Its probably somewhere closer to the end of the blob so ur lucky
Or your firmware has two identical ssdts with different names
I've already seen that before
Truly fucked firmware out there
my firmware has that on boot too
hp 255 g9
this shit is so truly fucked
like on display lid close, it sends hp-specific keycodes through the keyboard
one keycode for no wifi and one keycode for no bluetooth
but no such keycode on display lid open
so every time i closed the lid my laptop would be in airplane mode
i setkeycode'd it to nil
Cleaning up some table reference leaks, I think im going to go ahead and just store method aml in heap allocated buffers instead of having to keep all of the aml tables mapped at all times
This also protects the aml from insane firmware that might try to modify aml currently being executed via smm
how about aml trying to modify its own methods :^)
Ah yes, the well-known good practice called "self-modifying code"
Yeah its a thing unfortunately
Well technically possible via TableData opregions
I wonder how far you can get with aml, like could you make an operating system with it
You have dynamic table loading for programs
x86 -> aml jit for running user programs
Ohgod
hmm well
id say u can get very very far
u can even route interrupts as scis
yeah
You probably could
u can implement a cooperative scheduler based on events
well as a buffer that u could Load and then call
Ohgod
lmao
No easy indirect call would get annoying fast
I was just about to say let's modify the aml for the indirect call
But that won't work given you copy the aml
u could easily extend it to add a CallOp which could operate on anything
and then u could do stuff like Call PKG[123]
Yeah but that's no fun
at that point u can do anything
yeah
u can modify it in place for indirect call
Yeah that's what I meant, but given you copy it, it won't work anymore lol
u need a trampoline for calling into a method
that would just do XXXX()
in table data region u would overwrite XXXX with whtaever u want
then call into the trampoline
but u still can't do stuff like call-by-address etc
but with this approach u could have a function table at least
Maybe you can dynamically generate a switch case
So when you add another option for the abstraction, dynamically add to the method another case which does a call
true yeah
I'm really tempted to try lol
Aml itself doesn't have a way to iterate the namespace right?
nop
best thing u get is CondRefOf
DefinitionBlock ("", "SSDT", 1, "", "", 0)
{
Method (FOO) {
Return (1)
}
Method (BAR, 1) {
CopyObject (DerefOf (Arg0[0]), FOO)
}
Method (TST) {
Debug = "TST"
}
Method (ANOT) {
Debug = "ANOT"
}
Name (PKG, Package (1) {})
PKG[0] = RefOf (TST)
BAR (PKG)
Debug = "calling TST"
Debug = FOO ()
PKG[0] = RefOf (ANOT)
BAR (PKG)
Debug = "calling ANOT"
Debug = FOO ()
}
The only thing we can't do is isolation :^)
Wait that might work
oh yeah u can just abuse CopyObject to execute arbitrary shit lmao
That's genius
yeah
u cant modify cpu regs
You would want to synchronize the method cause namespace memes but yeah
I mean, bigger problem is anyone has access to physical memory lol
wdym?
had to try after you showed me that it can replace a method 
its pretty funny
i even do this in one of the test cases iirc
// Name: Copy a local method and execute it
// Expect: int => 3735928559
DefinitionBlock ("x.aml", "DSDT", 2, "uTEST", "TESTTABL", 0xF0F0F0F0)
{
Name (TEST, "Hello world!")
Method (GETX) {
Return (1)
}
Method (COPY) {
Method (GETX, 1, Serialized) {
Name (Y, 0xDEAD0000)
Y += Arg0
Return (Y)
}
Return (RefOf(GETX))
}
Method (COP1) {
Local0 = COPY()
Return (DerefOf(Local0))
}
Method (MAIN, 0, NotSerialized)
{
Local0 = COP1()
CopyObject(Local0, TEST)
Return (TEST(0xBEEF))
}
}
Like, if you have a call indirect it would have the lock around the copy object and the call
I guess you can generate new namespace objects on each indirect call, some kind of a macro
yeah
I might want to create a preprocessor anyways to allow me to have names bigger than 4 letters
And reg-alloc with the locals
Name (CALL, 0)
Mutex (LK, 0)
Acquire(LK, 0xFFFF)
CopyObject(PKG[X], CALL)
Release(LK)
CALL()
this is how u could dispatch arbitrary stuff
Yeah
Can't you mark the method as synchronized?
Instead of manually creating locks
Wait, won't this race possibly
CALL getting overwritten by a different thread is no different from CopyObject into yourself
an interpreter should support this
I mean, it could happen before the CALL is resolved no?
well
The Name is part of the namespace while executing the method
there's a race window here i guess
so yeah i guess u could just
wrap this in a serialized function
That is pretty sad tho
well
u can create a separate instance of the dispatch function
by doing a copyobject of it
Hmmm
i think acpi.sys BSODs if u CopyObject a serialized method
And each time you use one you copyobject
non serialized works tho
you can do that yeah
I'll just use the correct interpreter (uacpi)
well not like u could use acpi.sys for this tbh

and acpica would just segfault instantly on anything cursed like this
Yeah lmao
Is there some simple image that just runs uacpi? Like the old lai image?
Nononono
Ok
you could even run it in userspace
hmm
u can even use fw_cfg to retrieve the memory map and stuff
if you're on qemu
entirely in aml
I think the plan would be to run uacpi, and add another ssdt which is the kernel itself
Or well
as for simple image, probably the simplest to build is astral or obos maybe
Kernel is a big word
lmao
So you have both the dsdt and firmware stuff, and your own stuff to play with that
Hmmmm even tho there is no easy way to find objects by their cid/hid from aml
yeah but u can still use ecam for example
Yeah that would work
for other stuff u can cheat and make a syscall into C land layer
Use _OSI to find if the interface exists :^)
That might actually work lol
Wait, does uacpi expose a way to install a native aml method?
Like _OSI is technically a method no?
if u make the kernel call uacpi_install_interface for all of those pnp ids then yes
yeah
its a native method in uacpi
I could maybe make one for exposing the uacpi namespace search
there's osi.h to manipulate what it reports as supported
yeah
case UACPI_PREDEFINED_NAMESPACE_OSI:
obj = uacpi_create_object(UACPI_OBJECT_METHOD);
if (uacpi_unlikely(obj == UACPI_NULL))
return obj;
obj->method->native_call = UACPI_TRUE;
obj->method->handler = uacpi_osi;
obj->method->args = 1;
break;
This is how its created
the only issue is it takes in the interpreter context, which is defined in interpreter.c aka its sort of private to that
Yeah long aliases are first
would be funny if u actually manage to extend the iasl compiler to support compile time alises and upstream it
Oh god
I am not sure if I want to touch that lol
I might just actually write some python script to preprocess it
true well probably easier to treat it as a C file that can be run through a preprocessor before being fed to iasl
Yeah running cpp would also work well
I want 3 things to write code sanely, long names, locals dynamically allocated among the LocalX and if it runs out maybe a package to spill or something alike
And named arguments
damn
That would already make asl like 100x easier to write
if u actually implement that stuff that might even be unironically used internally by firmware writers
hell i might even use it for the uacpi test suite
:^)
i want a progress thread for that stuff 
I'll write something when I get home and open a progress thread :^)
thats big
ngl it sounds very interesting, even to get like a framebuffer logger working via aml
E9 is trivial too
yeah but thats kinda cheating
True
but yeah uacpi does log calls via Debug
there's even a Printf macro in asl
u can do stuff like Printf("Hello %o", "world") etc
I wonder, if you ipi the sci vector on another core, would that work?
sure
but u would also have to set the respective GPE status bit as 1
so that the aml handler is run
it depends as per usual
hmmm that might not work well then
well its write 1 to clear soo
yeah
ok how about, from the kernel, I call eval on some entry method from each of the cores
uacpi is thread safe right :^)
Write an aml interpreter in aml
uhhh
uAMLACPI
can aml allocate physical memory?
It can allocate memory and access arbitrary physical memory, but there isnt a native AddressOf type of interface
hmmmm so if we want anything to do dma we would need that
but I guess we can start with simple ide pio
ohgod
Or that
I mean, there is a kernel running under you, you can't just access physical memory as you want :^)
unless you wanna corrupt uacpi itself
Well as long as you have some sort of an Abi where the host kernel lives
E.g. 1..10MiB phys
ISA DMA time :^)
Or ask the host kernel via some interface or whatever
Lol
This is basically like a vm at this point
But honestly a bounce buffer of a few pages sounds fine
Just agree with the host kernel on some location, dma to that, then memcpy from aml
Or the cursed address of syscall
Or, manually probe memory until you locate yourself, then have some Noop area that you will be using as the bounce buffer
I wonder if one could exploit a vulnerability within a kernel's acpi interpreter
Actually no
Someone could probably just make a malicious aml blob
As a virus payload
Then since aml is trusted code
I mean, trusted is a big word
if you have the privs to register aml blobs you can probably make a better rootkit
or if you patch the bios, you already have a better rootkit
Iirc windows has aml blobs that it should load in the registry
Couldn't you leverage that to get that aml running
I mean, running what I wanna make and running windows at the same time wouldn't really work
I want to make actual drivers in aml
I want the kernel to only have the bare minimum required to run uacpi
ok I can do something really cursed
I can use port io to syscall into the kernel
given x86 only has 16bit, and acpi allows for port io of 64bit
I can have some custom port ios to communicate with the host
worst case if I can't find it some features won't be available
ok I got a tiny kernel that can just load uacpi and load all the limine modules given as aml blobs, now I just need to make a nice acpi buildsystem
(the 8 errors is because I was too lazy to implement pci read)
Nice
u can do a less cursed thing
and use some other unused address space type for this
e.g. IPMI
and then hook that up from the kernel via uacpi_install_address_space_handler
True
so I started writing python to parse asl, and I think this is not what I wanna do tbh
like, I have something basic working, but the grammar has soooo many random stuff in it
I think maybe I should use some parser generator and try to convert their grammar into that
why would you want to parse asl?
i'd think you want to parse a custom language then generate ASL out of that
so you dont have to deal with whatever the fuck asl is
I want to just add some small extensions
like long names and something to handle locals
it should just do minor transformations
I mean, the problem is that I will need to do cursed stuff to get some of this working, so I am not sure how better whatever I will do is going to be
And alot of stuff don't really fit into other Langs, unless it will look essentially like asl
Ok I can do something simpler maybe, I can just tokenize the asl, and heuristically replace long names with short ones
If it's a keyword don't replace it, otherwise assume it's a long name and replace it
Not that much, simple linear scan and if there are too many store it in package instead
Generating aml directly would be easier since ASL to aml is very easy to translate almost 1 for 1
Don't even need a real spill because accessing a package is not that much more expensive
its easier to debug text than binary
Disassemble via iasl 
that assumes you don't produce broken aml
which is the literal thing you'd want to debug
Lol ig
Whatever broken thing I create is just another test case for uacpi :^)
is there a way to compare references?
I have two locals, and I want to check if they both have the same package
by same I mean same ref
btw it seems your ConcatOp doesn't handle correctly non-integer/string/buffer types
Op 0x0073 ('ConcatOp'): invalid argument type: Package, expected a ComputationalData := ByteConst | WordConst | DWordConst ...
while the spec says
Nope
Spec is wrong
fuck
Aka my concat is the same as acpi.sys
Lool
like a cyclic one
Interesting
U cant have a null ref yeah
is there a try-catch :^)
I wish
I can add an entry that has some unique id for every object I create
and I can compare that
If u store them as packages yeah u can store like a tuple
lol
I forget the crap they have in the spec
packages are passed by ref right
You can think of it that way yeah
Modifying it from a dif place will be visible everywhere
ok I am really confused then
Same goes for buffers and strings
I have this code, next == 0, value == 3, Local0 is initialized to Package(3) and Local1 is initialized to Package(4)
and this is what I get ```
[AML DEBUG] Package @ffff80007fc8f0c8 (ffff80007fc8f088) (4 elements)
Element: Uninitialized
Element: Uninitialized
Element: Uninitialized
Element: Integer => 0x0000BABE
[AML DEBUG] Package @ffff80007fc6b008 (ffff80007fc6af08) (3 elements)
Element: Package @ffff80007fc6b0c8 (ffff80007fc8f148) (4 elements)
Element: Package @ffff80007fc8f9c8 (ffff80007fc7bd48) (3 elements)
Element: Integer => 0x00000001
[AML DEBUG] Package @ffff80007fc7bf48 (ffff80007fc7bdc8) (4 elements)
Element: Uninitialized
Element: Uninitialized
Element: Uninitialized
Element: Uninitialized
[AML DEBUG] Package @ffff80007fc6b008 (ffff80007fc6af08) (3 elements)
Element: Package @ffff80007fc6b0c8 (ffff80007fc8f148) (4 elements)
Element: Package @ffff80007fc8f9c8 (ffff80007fc7bd48) (3 elements)
Element: Integer => 0x00000001
do I need to keep the ref maybe?
and not deref
yeah that worked
Wdym
Local1 is completely uninitialized after the deref
while it was with stuff beforehand
yeah one second
the third debug is after doing the derefof on the package
you can see from the pointers that the first package is refed by the second one
this one
Right and
and then when printing the Local1 after the derefof(local0(next)) it is a package full of uninitialized
if it was a copy I would expect it to at least have something
Can you come up with a simplified example 
let me try :^)
ok I am really fucking confused
I might just wait till you have a computer because I have no idea what is going on lol
I have this code
this is the result
if I comment out the Local1 = Local0[0] it prints
Well I mean this one makes sense right
Because u deep copied an empty package
OH I see what you mean by deep copy
And the stored to it
so I need a RefOf?
Yeah
ok that makes sooooo much more sense
Lol
I am still a bit confused on why the Local1 = Local0[0] had the cast error
while the dereof worked
Id have to see once I get to my pc
btw it would be nice if when you have an invalid argument for an object it would say which argument
Wdym by that
so for example when it sasys invalid argument for Index, it would say if its the source or index that doesn't match
Ig I can infer that from what it expects tho
Oh, yeah ig those debug messages could be improved
Are u actually preprocessing it with cpp?
Oh thats a thing?
yeah it has stuff
but
it doesn't know how to do things like "[MACRO]"
you have to do [ MACRO ]
How does it work?
Oh interesting
Yeah ofc
ok so now it seems like I can't switch the reference inside of a package
wait, do I need to use CopyObject instead
this fails with an invalid implicit cast (Reference -> Package)
Ofc
AAAAAAAAAAAAAA AML IS SO DUMB
References are not refundable
Rebindable sorry
Lmao
Storing to a ref implicit casts
hmmm what
may i recommend writing your own aml generator
before that I need to figure the rules lol
I might do something with static types just so I can actually emit things correctly, like that copy object
😢
what is a namestring?
Its technically illegal
who comes up with this crap
Use -f
ill go insane by the end of it
A path
wait how would CopyObject(Local2, Local0[0]) work
Literal basically
Replace item at index 0
wait is it src, dst
src, dst
Yes
fucking what
Lol
may i guess that it is not in fact possible to do it without NT noncompliant magic?
does acpica agree with this particular nt misfeature
fucking what
Ye
am I really going to need an actual compiler this quickly
Aka it doesn't perform store to the referenced object
But rather to the ref container
Which is wrong ofc
Oof its one of those cases
I mean, thats what something sane would do
Yeah
Except it doesn't for Arg references
So for that it does mimic nt
But not for other stuff
.............................................
Lmao
ok a compiler it is ig
Its like walk over tokens and emit the respective aml op
yeah except I will want to support the symbolic expressions
True
and right now I just didn't do long names
so I might as well do it
ok i need a name for the project
right now I called it uacpios
Lmao
Like if u implement a syscall layer for stuff like hooking interrupts or context switching u can have a full blown kernel pretty much
I think my first goal is more of a dos like
Makes sense
like, what I was gonna do, is create some framework to patch aml from aml
so I can dynamically create Device objects for each PCI device
so I can use the AML OperationRegion PCI stuff
Oh interesting
and for that I figured I probably want a way to do dynamic lists
True
so I was gonna make a linked list and here we are
This one is probably a bug tho, as far as I can see from my phone anyway
Ill take a look

Copyobject where possible ftw
anyways any other name or do I keep uacpios
yasss I will make one to stop spamming this channel lel
An os entirely in aml
so that perf doesnt suck
That sound awful I love it
the true universal OS
can acpi emulate a uart?
You can start with a basic jit that just calls into C
now embed it in firmware, boom you made windows into an usable os :^)
Yes
if so you can literally just make /dev/ttySn be your custom os
Wdym exactly lol
I think he means actully defining a uart device that is uart
like write aml that can read and write characters
where it calls acpi methods to access it
and the os makes it look like serial
Yeah ofc
this means acpi.sys would essentially be WSL but for your OS!
like how you can make an rtc in pure aml
WSA (windows subsystem for acpios)
you can??? like natively?
windows subsystem for aml
Well not natively there's no such thing in Linux lol
ok yeah that is what I assumed lol
you can probably do it with weird SMM interactions on some chipsets
But u can define a device with a method that can be hooked up
but the os wont make it look like hardware uart?
And u can execute aml from Linux userspace via aml debugger
can WSL run AML?
the default kernel no, but if you build your own ofc


