#uACPI - a portable and easy-to-integrate ACPI implementation
1 messages Ā· Page 17 of 1
maybe there could be an environment variable that would allow overriding the flags (that the kernel would then set in eg. .cargo/config.toml if it wants to override them)
then if you want to use msvc for some reason you would set that to whatever flags you use for your kernel
thats the next step, i just want it to compile for now
so there is a /kernel flag for msvc
but thats for windows kernel modules so like idk
my recommendation is to just install mingw clang or llvm in general
and use that
depending on how fast i can find the flags msvc wants compared to the installation of clang for win11, it will decide if uacpi-rs will support msvc as a compiler
/link /NODEFAULTLIB outta be equiv-ish for nostdlib
general regs only is included in /kernel
3 flags to go
and i dont think the stack protector exists on the ms callconvs but im not 100% sure so still looking
also the /link stuff has to be at the end
/link means everything afterwards gets appended to the linker command line
ok yeah afaict the stack protector/red zone/whatever you call it isnt a thing on the windows calling convention so that flag isnt relevant
yea
so i think /kernel /link /NODEFAULTLIB oughtta work?
try it and let us know ig
as long as the link nodefaultlib part is at the end of the command line
there can be nothing after it
some things people recommend
unless you have a separate linker command line thing, in which case put /NODEFAULTLIB on the linker command line
GS- disables stack probing i think
Zi is debugging info
Oi generates intrinsics equiv to the __builtin stuff
the s after EH enables c++ throw/catch and the c after EH puts nothrow on extern "C" by default
yep /GS- is your -fno-stack-protector ig
and `/c compiles without linking
base is your base virt addr, entry is your entry point, and debug full is obvious on the linker command line there
so i geuss we need /GS- and /EHsh
and subsystem:native is "Kernel mode drivers for Windows NT" so yeah that one is right
idk about the EHsh tbh depends on if youve got c++ exceptions and stuff
also
the docs say that any EH option other than /EH- is incompatible with /kernel
(for reference the other SUBSYSTEM options are windows boot environment, four different efi variants, posix subsystem for windows nt, console where windows gives it a console when you run it, and windows where you dont get a console because you are supposed to be opening win32 windows)
also for reference, /kernel disables c++ exceptions, RTTI, and requires the new() and delete() operators to be defined explicitly, does #define _KERNEL_MODE 1, and prevents use of sse avx etc, and passes /KERNEL to the linker which prevents incremental compilation and issues a warning if you link it with an object that wasnt compiled with /kernel
interestingly on x86_64 youre allowed to use SSE and SSE2 but still not allowed to use AVX etc, but on 32-bit x86 you cant use any vectorized things
iirc nt has kernel api to use SSE
on 64-bit anyway
whether you use vectorization in the kernel really comes down to what registers youre willing to deal with saving on interrupts lmao
no what they do is like
xsave()
sse_stuff()
xrstor()
ah ok
comand line error: name of source file not found
now that i got no idea
I will try it with clang, if it works then msvc is not supported for now
no 
I'm not strongly tied to my vote there btw, and tbh I dont see myself having any use for the io port versions of thse functions. They're handy hooks to have for access to any resource though (I found the lack of them for pci accesses to be annoying, but possibly thats a design issue on my end) so I'm hesitant to vote for removing just because I dont see a use for them right now.
sorry for the late reply btw, crazy time of year 
im getting a shit ton of warnings from uacpi when compiling with clang and it aborts with errors even tho there are none in the log:
flags:
.no_default_flags(true)
.remove_flag("-Wall")
.remove_flag("-Wextra")
.flag("-fno-stack-protector")
.flag("-mgeneral-regs-only")
.flag("-nostdlib")
.flag("-ffreestanding");
cc.flag("-mno-red-zone");
missed those
125:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
149:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
173:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
197:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
221:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
245:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5: error: expected '}'
263:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5: error: expected '}'
281:warning: [email protected]: 7 errors generated.```
that's the log with numbers
line numbers
of where in the log it happened
I need to relearn english
now the question is are these errors caused by cc or did i use a broken commit?
did the CI pass on this commit?
also show the actual file it errors out on
maybe it's partially written or corrupted
Commit 55478816db3a4242d714538891a1842634c8ca33
https://github.com/UltraOS/uACPI/commit/55478816db3a4242d714538891a1842634c8ca33
It's the latest can't see if ci pass
Signed-off-by: Daniil Tatianin [email protected]
compiled for me
I will reclone the repository and try again once I'm back home
using clang-19, uacpi compiled
Well what clang do I get when installing it via vs22?
idk check
use the vs command prompt
and do clang --version
clang-19 is latest afaik
Are you aware of a clang version that will definitely not work with uacpi?
clang-20 hasn't been released afaict
nope
at least debian sid repos don't have it
llvm 20 isn't released yet
I used clang not clang-cl as clang-cl showed the same behavior to the c flags as msvc
Yup, on all platforms
basically clicking on green checkmark
Lmao sure that would be hilarious
Do you somehow route all gpes and stuff to windows 10 code as well or how do these bindings even work
Since its acpi driver probably has very specific APIs
Or e.g. _CRS
Thereās a massive private dispatch table between HAL,
The PPM part of Hal
And pci essentially
do you know how we describe windows as a hybrid kernel usually
This isnāt FULLY true
thereās a thing called NTOS CORE,
ACPI, PCI,
HAL, ntoskrnl are a ākernelā
It being separate files is only spelt of the story since a bunch of ACPI logic is shared between all 4 components, and vice Versa etc etc
So how does it interface with acpi.sys?
You have 3 parts to it Iāll see if I can get all of
Them into some links
Hang on..
Im curious how u can even convert uacpi specific structs to stuff it expects to get
itās not a super easy plug in
I suspected as much lol
https://www.vergiliusproject.com/kernels/x86/windows-10/22h2/HAL_PRIVATE_DISPATCH
https://www.vergiliusproject.com/kernels/x86/windows-10/22h2
Search ACPI on this site
These are like structs and exports it expects?
Interesting
So you implemented literally all of those to make uacpi work with windows 10?
A lot more than this
Iām just at fire stone
So I canāt show you my versions of the dispatch tables
But itās 10
Times bigger
Can it run with some of them unimplemeted?
yup it can
How does that work?
The what?
itās a tire store im getting an alignment done on my car
Ah
It depends on what it is
PPM -> okay if you ignore most of this you wonāt have cpu power states and Po will just ignore it
Does it need a way to evaluate arbitrary aml?
ACPI.sys is supposed to handled it all internally
Ohh I see
So all u get is abstracted away helpers?
Im curious about how it abstracts all resources that devices consume
yeah thatās how modern windows is architected atm
now this hasnāt ALWAYS been the case
Windows ACPI/Pci/hal has gone through a lot of changes
I basically am just choosing 2 versions for now and conforming to that
Vista and 10 1607
What are the differences between them?
And which will reactos ship with
And which one does it work with now
my plan currently is to make it act like vista OOTB and add some preprocessor options to enable the 1607 capabilitiy
thereās a few reasons for this
But mostly it comes down to us trying to move our kernel to act like vista, and I want to be able to inject our pci and ACPI into vista when needed
And then windows 10 is just better for.. many reasons
Just to be clear ACPI.sys and Hal have been rewritten like 16 times I think
May be more.. I counted at least 16
If I had to guess ACPI is written when engineers from bios vendors get contracted out to MS
Which happens every few years
anyway the other reason is vista ACPI is primitive as hell
Interesting
I wonder how it implements the ec driver for example
And device notifications
Po is what handles device notifications.
Given it has to be this abstraction
I can show you this actually
Are they propagated to the respective device driver?
Purpose
This PR is an attempt to resuscitate the Composite Battery driver which is broken, barely usable and it even asserts the kernel because it improperly uses a function with incorrect paramete...
Depends on the device but most of the time yeah
12k lines lol
You register a notification with Po and then you register a handler with either the device driver or generic
and yup thatās just the start
Thanks ill take a look
Our Po is being designed off modern windows so you can guarantee itās close to whatās happening now in win11 :)
Would be cool to have a full win10 compatible implementation for regression testing etc
Power management subsystem
shouldnt it be like Pwr
Portable headers and a cmake target can make that happen I think
I can live with that
nah this is back when all the subsystems were named objects
Power Object
Then I guess id have to load it as a driver somehow
ObO
ObO?
object management Object
this is shitty inconsistent naming schemes we shouldnāt be mimicking
but all of the functions are PoDoSomeShit
So this is what obos stands for @north holly
stdcall PoRegisterDeviceForIdleDetection(ptr long long long)
@ stdcall PoRegisterDeviceNotify(ptr long long long ptr ptr)
@ stdcall PoRegisterSystemState(ptr long)
@ stdcall PoRequestPowerIrp(ptr long long ptr ptr ptr)
@ stdcall PoRequestShutdownEvent(ptr)
not yet this is what Iāve been doing
Yes definitely
Iām rewriting a bunch of PCI HAL and all of ACPI
Po is getting stable
what syntax is that lol
Object management object system
you sure it stands for that?
no
it sounds like it should be POwer
I believe it
which is why pwr would make more sense
but otoh
they also have Zw
which doesnt stand for anything clearly
right?
no clue Iām not actually a big fan of Mimicking MS as much as the other devs
If Zw stands for something Iāll eat my shoe
Zebra Win
oh snap
Eat ur shoe now
ZwINeedANap
Yes sir
ZwFr
no NtINeedANap to match it
so its a fake api clearly
you lied
Exposed
Wait till the ROS prefix comes into play
I have tons of those in my modern video driver work
ZwIShouldNotBeThisTired
@fiery turtle is there a way to integrate uacpi in my brain so I can call _WAK and wake up
Ok
how good is your brains aml
lmao
I should see if uACPI blows up in my dell server
and get a dump from it and PR it to that repo
I'll reboot
And see if that fixes the buf
*bug
it runs quite a lot of server blobs during CI so probably not
but would be nice if u tried
very cool
big
I have 400 devices
I wonder how many I can add
Want to see my hardware testing cart
403/400
It crashes on all
inb4 it kills them all
We already know the answer
Well
Iām trying to fix reactos
Obos crashing in the EC driver on his hardware
And I work as a bios dev
Infy has said some stuff about firmware devs
Heās right
yeah as of a couple months ago
nice
#1217009725711847465 message
do u write aml at work 
I have like 6 of these carts
Only a tiny bit
#schedulers message
My position is a UEFI Innovation Engineer
lmao
I do a lot of things
yeah i remember that
so mostly uefi-related work?
This is true
yes
I have never seen anything conform to UEFI and ACPI spec perfectly
very true
driver#### is the most broken thing ever
what is that?
#1141057599584878645 message
do you know what boot#### is
nope
retarbios
Uh think of it like a list of allowed, and ordered boot options
Driver#### is that for driver options
is this like a spec, an app, or what?
ah that one
Each load option entry resides in a Boot####, Driver####, SysPrep####, OsRecovery#### or PlatformRecovery#### variable where #### is replaced by a unique option number in printable hexadecimal representation using the digits 0-9, and the upper case versions of the characters A-F (0000-FFFF).
why is it broken?
Well on Intel AMI bioses you can replace one of them with zeros and brick your system forever
im guessing people dont implement it correctly
š
most systems have it so it kills itself after the first boot of it existing
lmfao
I got a lot of horror stories
why does that happen
does a cmos reset not fix it?
holy shit
AMI thinks cmos is old people
letās store my uefi boot### into permissible storage
or wait hereās a good one
you mean this stuff?
yeah but you can still reset efivars i thought?
why does removing it brick the system?
dunno I work at phoenix not AMI I wonāt investigate it for them for free
spec claims yes
lol
Firmware vendors wipe ass with spec
wow even firmware devs hate firmware devs
I do hate firmware devs
Theyāre evil
Anyway insyde is the best bios
Phoenix is okay most of the time but the latest thinkpads suck
were you paid to say that or...
you guys admit your flaws inside of rocks /j
Only then will a true bios be made
once infy qwinci and I found a bug with seabios where they would restore ECAM with ECAM after resume from S3
lol
i got a samsung laptop (and qookie too) with the uefi brick bug
Thatās cute
Is it a book 3?
how
Or any of that stupid line
By hooking into the set up screen
not that I have an amd laptop
no fnuy command to do it?
series 5 from 2013
I canāt really tell you that
Iām sorry
šµļø
You should put it to rest
My contract super loose about what Iām allowed to talk about. Thatās why I can say these funny things.
But there are a few things I canāt say
use it as my server now, it did 10 years of honorable daily driving
Thatās insanely long for a bomb
had a tiny ass battery, like 46wh, for a 17.6 inch monster
I have a Samsung book 3
are you the guys who give lenovo their firmware?
phoneix
or wait
brain fart
I've an ideapad
Thatās not us
That has a secret menu by the way
With funny options
You should unlock it
acer has one too
how do I find it
quite hilarious as you have to press a konami code ass sequence to unlock it
and you need it to even enable svm on cpus that support it
No idea offhand
my laptop's bios is InsydeH20
yes insyde letās goooo
Managarm more advanced than reactos???????
but I can't for the life of me find the secret bios menu
Managarm crashes less
you sure
damn it
there is something I can run
but it's windows only
not that I trust it anyway
damn
we love that
lol
(I'll pass)
Itāll be fineeee
pBuffer = 1;
strcpy(Guid, "{6ACCE65D-DA35-4B39-B64B-5ED927A7DC7E}");
strcpy(Name, "cE!");
if ( GetFirmwareEnvironmentVariableA(Name, Guid, &pBuffer, 1u) )
{
sub_140001020("Locking\n");
v4 = 0;
}
else
{
pBuffer = 1;
sub_140001020("Unlocking\n");
v4 = 1;
}
if ( SetFirmwareEnvironmentVariableA(Name, Guid, &pBuffer, v4) )
{
sub_140001020("Success\n");
}```
decompiled
not sure how that works
If you can do it from windows itās probs pretty safe
but then again
Fw vendors are dumb
rm -rf /sys/firmware/efi/efivars
We take an ancient oath to never conform to the spec properly
go see if ur hw vendor is retarded
(dont, or do, but i am not responsible for ur hardware
)
I think doing that is retarted
it is
just modify the bios
oh yeah it absolutely is
uACPI become āfw-retardā channel
what's even more retarded is that there is a 50% chance that this will brick ur motherboard
I bet you itās more than 50%
and garbo laptops likely have no good way of emergency flashing a bios lol
Nothing made in the last 10 years will survive that
garbo=lenovo?
well jokes on you
this was made 11 years ago

spi flash that bitch
or whatever interface modern laptops use anyway
EC
I am financially obligated to question this statement
thankfully on desktop mobos its pretty common for them to have a dedicated flasher chip on-board that can flash the bios from an usb
(on decent ones at least)
I wonder what "reboot to setup mode" does
in my bios
it says it clears pk
disables secure boot
enters tpm setup mode?
and enters setup boot
no tpm here iirc
Probably bricks it too
randomly resetting shit has never gone wrong
also one thing I don't like is that fw vendors are always hiding the fun options
yeah
like the device mode usb controller toggle, random debug settings or some pci hw level things 
Steam deck definitely isnāt hiding funny things beneath surface
It is definitely not hiding the funniest thing ever
Zero funny things in steam deck
those who know
mango mango?
just throw your bios to uefi editor and look what menus they hide and make them accessible
Uefi easy patcher . Exe
thankfully its not exe lol
.EFI
Does Phoenix make firmware for acer
2013
I doubt it
my acer has insyde and its garbage
somehow the most uefi compliant machine i have is a lumia
same it serves nfs and acts as a wifi ap :^)
i use it to ssh into it since i only bring my tablet to uni
I'm surprised that you can set a laptop's wifi to ap mode
Iirc i tried it on the raspi4 and it didn't work
Although it works on some intel chipset that i have
works on all of my machines
Ah nvm the issue was not ap mode but attaching the wifi to a bridge
Some wifi firmware / hardware refuses to send packets with mac address != the wifi adapter's mac address
wait they're still around? I thought they vanished after fading into obscurity in the 2010s 
everything I've seen from the past 10 years is either AMI or Insyde
I think my parents' old laptop also has Phoenix
opcodes.c
14| static const struct uacpi_op_spec opcode_table[0x100] = {
15| UACPI_ENUMERATE_OPCODES //<<Erros on first char
16| };
18|static const struct uacpi_op_spec ext_opcode_table[] = {
19| UACPI_ENUMERATE_EXT_OPCODES //<<Erros on first char
20|};
lines 14-20
clang version is 18.1.8
@fiery turtle clang complains about this code with these error messages:
125:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
149:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
173:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
197:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
221:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:5: error: expected '}'
245:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5: error: expected '}'
263:warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5: error: expected '}'
281:warning: [email protected]: 7 errors generated.
can you post the preprocessed source code?
copy the clang command, add -E and change the -o ... to point to a different file
where do i have to add the -E?
to the clang command used to compile the opcodes.o file
Command "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\Llvm\\bin\\clang.exe" "-I" "C:\\Users\\juven\\SynologyDrive\\uacpi-rs\\uacpi-sys\\uacpi-src/include" "-Wall" "-Wextra" "-fno-stack-protector" "-mgeneral-regs-only" "-nostdlib" "-ffreestanding" "-mno-red-zone" "-DUACPI_SIZED_FREES=1" "-o" "C:\\Users\\juven\\Desktop\\9b5d1a837e7b6553-opcodes.o" "-c" "C:\\Users\\juven\\SynologyDrive\\uacpi-rs\\uacpi-sys\\uacpi-src/source/opcodes.c
where exactly do i need to add -E, or can i just append it?
it can go wherever, just change the path after -o to something else as well
i hate windows so much
cc can execute the compiler invocation command just fine but when i do it in powershell it breaks and complains about too many arguments
I mean I compiled it with so many compilers and never seen this error so no idea
If it works on MSVC no way it breaks on clang
try a batch file?
that worked even less
i now got it
.\clang.exe -I "C:\\Users\\juven\\SynologyDrive\\uacpi-rs\\uacpi-sys\\uacpi-src/include" -Wall -Wextra -fno-stack-protector -mgeneral-regs-only -E -nostdlib -ffreestanding -mno-red-zone -DUACPI_SIZED_FREES=1 -o "C:\\Users\\juven\\Desktop\\9b5d1a837e7b6553-opcodes.o" -c "C:\\Users\\juven\\SynologyDrive\\uacpi-rs\\uacpi-sys\\uacpi-src/source/opcodes.c"
msvc broke so bady that i resorted to giving cc clang manually
which didnt help much
well managarm's kernel is compiled with clang so
https://github.com/Shinribo/uacpi-rs/tree/1.0-dev this is the branch i am working on and where these errors happen
Uacpi compiles for me with clang
i hope you guys find the error, i will go to bed now and install clang standalone tomorrow if the error cant be found
and if that doesnt work i will compile uacpi by hand because apparently clang doesnt have a problem then
hmm i can reproduce this locally
```
qookie@selenium /tmp Ī» clang 9b5d1a837e7b6553-opcodes.c -c -o foo.o -m32 -std=c23 -target x86_64-win32
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:28656: error: expected '}'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:28543: note: to match this '{'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:29052: error: expected '}'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:28939: note: to match this '{'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:29448: error: expected '}'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:29335: note: to match this '{'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:29843: error: expected '}'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:29730: note: to match this '{'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:30490: error: expected '}'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:15:30377: note: to match this '{'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5193: error: expected '}'
C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5111: note: to match this '{'
7 errors generated.
Where -I?
the file is preprocessed
can you paste that file pls
same line nums?
yeah i didn't edit the file
a bunch of defines weren't replaced
these line nubers make 0 sense
static const struct uacpi_op_spec ext_opcode_table[] = {
{ "ReservedExtOp", .decode_ops = { UACPI_PARSE_OP_BAD_OPCODE, }
Thats one long line
UACPI_PARSE_OP_BAD_OPCODE should've been replaced by the define's value
is that not an enum
Why, itās an enum no?
oh is it?
uacpi_parse_op
fair enough
It's pretty common to use uppercase for enums as well
because the preprocessor directives change the file and line numbers
opcodes.c line 15 is at line 1366 in the preprocessed file
š
https://uwu.foundation/7p42VZs.png what line are we on? i dunno
forgor
!!!!!!!!!!!!!!!
Wait but how does it still compile
I think it got preprocessed incorrectly
Any chance its a FieldOp?
CreateDWordFieldOp
Yup
#define UACPI_DO_BUILD_BUFFER_FIELD_OP(type, code, node_idx, ...) \
UACPI_OP( \
type##FieldOp, code, \
{ \
UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
UACPI_PARSE_OP_TYPECHECK, UACPI_OBJECT_BUFFER, \
UACPI_PARSE_OP_OPERAND, \
__VA_ARGS__ \
UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, node_idx, \
UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER_FIELD, \
UACPI_PARSE_OP_INVOKE_HANDLER, \
UACPI_PARSE_OP_INSTALL_NAMESPACE_NODE, node_idx, \
} \
)
va args removes the comma
trolled
##__VA_ARGS__ 
__VA_OPT__(,) :^)
but its not optional in this case right
ah true
UACPI_DO_BUILD_BUFFER_FIELD_OP( \
Create, UACPI_EXT_OP(0x13), 3, \
UACPI_PARSE_OP_OPERAND, \
) \
one example
i guess that last comma gets stripped
is it possible c23 has something to do with that
add a comma after __VA_ARGS__?
that will break every other compiler no?
the file was preprocessed without any -std
and i only have the preprocessed one so
like that would fix your version of clang
but break other versions i guess
because it would be UACPI_PARSE_OP_OPERAND,,
how would you even use this?
is there something like negated __VA_OPT__? 
what specifically?
.
most field ops dont need anything in there
ah
but this one has an extra opcode inserted in the middle
just tested, this works
what does this do?
--- a/include/uacpi/internal/opcodes.h
+++ b/include/uacpi/internal/opcodes.h
@@ -396,7 +396,7 @@ UACPI_OP( \
UACPI_PARSE_OP_TERM_ARG_UNWRAP_INTERNAL, \
UACPI_PARSE_OP_TYPECHECK, UACPI_OBJECT_BUFFER, \
UACPI_PARSE_OP_OPERAND, \
- __VA_ARGS__ \
+ ##__VA_ARGS__, \
UACPI_PARSE_OP_CREATE_NAMESTRING_OR_NULL_IF_LOAD, \
UACPI_PARSE_OP_SKIP_WITH_WARN_IF_NULL, node_idx, \
UACPI_PARSE_OP_OBJECT_ALLOC_TYPED, UACPI_OBJECT_BUFFER_FIELD, \
@@ -1146,7 +1146,7 @@ UACPI_OP( \
) \
UACPI_DO_BUILD_BUFFER_FIELD_OP( \
Create, UACPI_EXT_OP(0x13), 3, \
- UACPI_PARSE_OP_OPERAND, \
+ UACPI_PARSE_OP_OPERAND \
) \
UACPI_OUT_OF_LINE_OP( \
LoadTableOp, UACPI_EXT_OP(0x1F), \
this seems to work on MSVC at least
god bless the c preprocessor
does it work for u as well qookie?
i mean i didn't have any issues either way
as i said, i'm only testing the preprocessed file Shinribo posted
ah
@rustic compass let me know if this fixes it
so stupid lmao
since it works in clang 19 i guess its a temporary regression they had?
seems so
it repros for u on clang 18 right
could probably dig through github issues to find out
managarm has clang 18.1.2 and that works
hmm
the failure was on 18.1.8
i guess it was very temporary then
i keep forgetting u ran an already preprocessed file
yeah u can try compiling the test runner with clang
doing that rn
thx
that compiles
i guess it was then
btw in other news, gcc 15 adds a new warning that triggers for uacpi: ```
/tmp/uACPI/source/namespace.c:24:56: error: initializer-string for array of ācharā is too long [-Werror=unterminated-string-initialization]
24 | [UACPI_PREDEFINED_NAMESPACE_GPE] = MAKE_PREDEFINED("_GPE"),
| ^~~~~~
/tmp/uACPI/source/namespace.c:17:22: note: in definition of macro āMAKE_PREDEFINEDā
17 | .name.text = name_str,
| ^~~~~~~~
PLS
it's crying because there is no space for the null terminator
š¤
leave me alone compilers 
i mean it's a good warning in general, uncovered some bugs in leenocks iirc
is this because an int cast of a string?
its a char[4]
šæ
assigned a char[5]
no, it's because text is char[4] but "_GPE" is char[5]
{'_', 'G', 'P', 'E'}
\0
or just make it a char[5]
it's a uacpi_object_name struct so i can quickly type pun to ints
aligned on a 32-bit boundary
#pragma GCC diagnostic ignored "-Wunterminated-string-initialization" 
why do you do that tho?
name.id == other_name.id
so u32 vs u32 cmp
instead of memcmp etc
union trolling {
char fuck[4];
uint32_t you;
};
pretty sure the compiler would optimize that out anyway
it cant unless there's an alignment guarantee
also not unless people define it to __builtin_memcmp
also memcmp is like harder to type out lol
bruh
if (uacpi_memcmp(node0.name, node1.name, sizeof(node0.name)) == 0)
repeat this every time
id rather do node0.name.id == node1.name.id
and i can quickly check agaisnt constants etc
anyway not that important tbh
that's not that bad imo
it does optimize it on arches that support unaligned loads tho
With built-in or without
I imagine that would depend on the march
well on arches like x86_64 that unconditionally support it it doesn't depend on march
and if the arch doesn't support it and you do it manually its going to be screwed that way too
Union forces the alignment
ah yeah
You sure? Last time I checked march has a bunch of cost factors for different operations, I'd imagine unaligned access being one
well at least when you don't pass any march it optimizes it to just a normal u32 load
or with march sandybridge/alderlake
And if u use a custom memcmp
well yeah if you'd not define uacpi memcmp to the builtin one and compile with ffreestanding then it would be slower
but there aren't really a lot of reasons to not define them to the builtin ones to let the compiler optimize calls to them
anyway I just wanted to see if the compiler would optimize it, you can ofc keep it how it is 
Not a lot of people are well versed in compiler internals
And know to use builtins unfortunately
Nyaux probably doesn't

lol
The shade
when you call the builtin it emits a call to mem* anyway 90% of the time
so it's not even like a "magic" fix, you still need to implement the function
Yeah but its IR so it can optimize cases like we've just discussed
And not actually emit a call
Yeah
I mean probably most small compares can be optimized to integer loads
So its about the size of the objects you're comparing
Don't compilers replace calls to those functions with builtins automatically?
not guaranteed
I had some fun where my libc would break because GCC would replace calloc with call to itself
Which would stack overflow
fun
Thats a different optimization
Recognizing a memcmp and just replacing it with that call
Builtins are the other way around, they try to avoid memcmp work entirely and do an ad hoc version
if they match the right signature, it probably does
yes but if you use ffreestanding then no
I don't
i would still expect that to happen even in freestanding given the signature is correct
And in freestanding you can tell compilers that the functions should be treated as builtins
ah
Like the printf attribute
Then watch your memcpy get optimized into itself 
I pass -fno-builtins to select c files in my libc
that only affects the format string part tho
it doesn't make it an actual builtin the compiler can optimize calls to
Or you can also do macros shit
yeah that works
You should yeah
Then there's also loop unrolling I would imagine
But idk how well that works
"I don't know what I'm doing"
I actually did the exact same thing for the table signatures in zig being able to treat the four byte string as an int is so nice
Yeah
plus i can make the cast an inline function and then itll evaluate at comptime to let me define actual enum constants
Nice
still dont know why ACPI only lets names be four characters long but it sure is convenient for exactly this reason lol
NEED
Thank you
Also...
;compile ```c
#include <stdio.h>
int main(int argc, char **argv) {
int value = '\x01\x02\x03\x04';
printf("%x\n", value);
}```
1020304
<source>: In function 'main':
<source>:4:15: warning: multi-character character constant [-Wmultichar]
4 | int value = '\x01\x02\x03\x04';
| ^~~~~~~~~~~~~~~~~~
Multi-character literals are a thing 
good and bad news, 5 error removed, 2 remaining
Will send the new error log in an hour
I pulled the latest uacpi and now it deadlocks after
[info] uacpi: enabled 2 GPEs in block _GPE@[0->64]
single thread
I don't believe it's an issue with my spinlock
previous clone was before the leaderboard
warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5: error: expected '}'
warning: [email protected]: 19 | UACPI_ENUMERATE_EXT_OPCODES
warning: [email protected]: | ^
warning: [email protected]: C:\Users\juven\SynologyDrive\uacpi-rs\uacpi-sys\uacpi-src/source/opcodes.c:19:5: error: expected '}'
warning: [email protected]: 19 | UACPI_ENUMERATE_EXT_OPCODES
warning: [email protected]: | ^
i rechecked the patch and its exactly what you send me
so i dont think i messed up
hopefully
Perhaps your get thread id is not good?
You always run uacpi on one thread?
well I don't have a scheduler yet lol
Sure
But I think it is an issue with your spinlocks or mutexes, currently I think managarm, pmos and obos all use the latest uacpi
What are your mutexes
spinlocks without disabling interrupts 
oh lol
How did u deduce that it deadlocks?
if I don't actually lock in my locks, it continues
It?
I mean the uacpi function returns and kernel continues fine
Ah so it never returns from that init?
I don't think so, I haven't checked which function it was, didn't have much time
BTW any way you can update your clang?
This version has some sort of regression in macros expansion
Or downgrade it works as well
apparently vs22 forces clang 18.1.8
how? i cant select the clang version in vs22
oh actually the latesat is 18.1.8, you are right
also, you can open the visual studio installer and click "update"
if there is a newer version it would be downloaded
Bruh did they put a shitty version of clang on purpose so people keep using MSVC
no
llvm has builds for windows
and they ship clang-cl
C:\Users\hacker>clang-cl --version
clang version 19.1.5
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin```
if you need this shit for whatever reason lol
Iāll see if there's a similar pattern anywhere in these macros...
i mean realistically the only reason visual studio ships clang-cl is because that's the only way to use an llvm toolchain within visual studio (without cmake), but if you're using rust why are you using visual studio??? and even disregarding that you aren't tied to msbuild, so you can use a proper llvm installation
In not using vs22 I'm just using clang from it
Is there a installer for clang on windows or do I have to compile it from source?
yeah of course
there should be an installer
llvm-19.1.6.exe
then just add <llvm install path>\bin to your path
so does proxima now and it works fine
Big
and imaginarium though my mutexes are still stubbed
fyi the installer asks if it should add the install to path
fair, that works too
you gonna be shitting me, same errors
clang version 19.1.6
its using clang.exe from the llvm install and it still breaks
is it by any means possible that a certain compile order has to maintained?
Hmm maybe its a windows specific clang bug then
Very interesting
I'll try to work around once I get to my pc
I think I'm technically compiling uacpi via clang on windows but I'm doing it by way of zig cc not directly and I'm not sure if zig includes its own llvm here

well llvm isnt bundled with zig
so yeah im technically compiling uacpi with clang on windows
wls2?
oh wait nvm again it might actually be linked into zig
nope, though that also works
ok yeah i was sorta wrong
zig does bundle its own clang/llvm
i didnt realise because there arent any big bundles of llvm files in zig's install dir
because it seems its statically linked
i think anyway, this is deeper into the zig source than ive gone before lol
anyway it is clang 19.1.0
idk if anyone sees anything i dont that might matter here but yeah
Because I develop on windows, but I'm used to linux tooling
what font is that
the one with english letters
I don't remember
the uacpi font
works now
now i get a billion rust errors caused by the new uacpi bindings
but it fucking works now
o boy time to write wrappers around 7kloc of bindgen
but we have progress
this was your fault?
no, i suggested the fix
may you have a long and healthy live
Nice
don't forget this
#1217009725711847465 message
@fiery turtle can you commit these fixes to github?
@fiery turtle this gets stuck, not namespace load
uacpi_install_fixed_event_handler(
UACPI_FIXED_EVENT_TIMER_STATUS,
[](uacpi_handle) -> uacpi_interrupt_ret
{
timers::acpipm::overflows++;
return UACPI_INTERRUPT_HANDLED;
}, nullptr
);
Look at the impl, its very very simple
Any chance u get an irq at the same time that tries to acquire the same lock
Yeah I will
no uacpi function is called from interrupt handlers
where exactly
got a rip at least?
it acquries a mutex, does two field writes, then releases it
yes in the spinlock while loop :(
which
which?
thats a mutex
event.c
yeah my mutex is a spinlock for now
can u use gdb at least
an interrupt
do your uacpi spinlocks disable interrupts?
yes
apparently not
or well
that shouldnt matter
that spinlock is released right away in that same function
but isn't a mutex locked in uacpi_install_fixed_event_handler
is your unlock_spinlock correct 
not spinlock
this is a spinlock
unrelated to event.c
uacpi_status uacpi_write_register_field(
enum uacpi_register_field field_enum, uacpi_u64 in_value
)
{
uacpi_status ret;
uacpi_u8 field_idx = field_enum;
const struct register_field *field;
const struct register_spec *reg;
uacpi_u64 data;
uacpi_cpu_flags flags;
if (uacpi_unlikely(field_idx > UACPI_REGISTER_FIELD_MAX))
return UACPI_STATUS_INVALID_ARGUMENT;
field = &fields[field_idx];
reg = ®isters[field->reg];
in_value = (in_value << field->offset) & field->mask;
flags = uacpi_kernel_lock_spinlock(g_reg_lock);
if (reg->kind == REGISTER_ACCESS_KIND_WRITE_TO_CLEAR) {
if (in_value == 0) {
ret = UACPI_STATUS_OK;
goto out;
}
ret = do_write_register(reg, in_value);
goto out;
}
ret = do_read_register(reg, &data);
if (uacpi_unlikely_error(ret))
goto out;
data &= ~field->mask;
data |= in_value;
ret = do_write_register(reg, data);
out:
uacpi_kernel_unlock_spinlock(g_reg_lock, flags);
return ret;
}
this is where u hang, and this is the only place this spinlock is referenced
i think it doesnt matter whether it does or not
auto ticket = _next_ticket.fetch_add(1, std::memory_order_relaxed); wait why is this relaxed
relaxed won't produce lock add
relaxed just means it guarantees no tearing
but two acquires can produce the same ticket in your case
i doubt thats the problem here but i think its still a bug
dump the lock state i guess, which ticket is it expecting, which is the current
what was it?
auto current = _serving_ticket.load(std::memory_order_relaxed);
_serving_ticket.store(current + 1, std::memory_order_release);
if constexpr (ints)
arch_unlock();
vs
if constexpr (ints)
arch_unlock();
auto current = _serving_ticket.load(std::memory_order_relaxed);
_serving_ticket.store(current + 1, std::memory_order_release);
I'm sorry
should fix this as well probably
or well its fine as long as you dont have smp
that's a ticket counter
doesn't matter if it's acquite or not
in your case two threads will end up with the same ticket
if i understand relaxed semantics correctly
hmmm are you sure
relaxed just means a thread wont end up with garbage ticket as a result of other thread doing a partial write
which isnt possible on x86
so its a no-op
objdump to be sure
because it's still atomic, thread one returns and increments while thread two waits for it to finish doing so
if it isnt a lock; inc then im right
sure
in this case i think its atomic in the sense that it will never be partially updated
cc @flat badge because this is the frigg ticket spinlock impl :^)
relaxed still generates lock xadd
hmm u sure?
i wonder why
relaxed doesn't mean that it's not atomic
just that it's not ordered with other non-atomic accesses
lol tysm
np
hmm well docs dont make it sound like that
only this operation's atomicity is guaranteed
yes, so u read 1 and write back 2, 2 is stored
no, that wouldn't be atomic
the whole fetch, modify, write is one atomic op
a relaxed atomic op is not the same as a non-atomic op
yes
non-atomic doesn't guarantee no tearing if an interrupt comes in the middle for example
a relaxed atomic does
fetch_add guarantees in any case:
Atomically replaces the current value with the result of arithmetic addition of the value and arg. That is, it performs atomic post-increment. The operation is a read-modify-write operation.
but apparently it also enforces lock in this case
the memory order is a guarantee on top of that
yeah i guess its just how fetch_add is to prevent foot shooting
if you want the op that you're describing, you need to do
just relaxed load and relaxed store
temp = x.load(std::memory_order_relaxed);
x.store(temp + 1, std::memory_order_relaxed);
yeah
which we actually do use sometimes in managarm
but in the context of a mutex, it's true that relaxed ordering would not be enough
the reason why it is enough here is that it's followed by a store-release
yea
Also, here you need to consider whether this can be nested in a region that already has interrupts disabled
Usually you want to restore to the previous state instead of re-enabling them unconditionally in unlock()
wait u dont do that?
the naive implementation will break if you take two spinlocks at the same time
yes arch_unlock does that
ah i see, then that should work
why not do the check locally instead of calling into arch-specific stuff
circular dependencies
like if (should_reenable) arch_really_unlock()
but u store previous state somewhere right
it's not arch specific, just in a separate source file
hmm
because arch.cppm -> lib.cppm -> lock.cppm
and arch specific functions are in arch.cppm
so lock.cpp imports it and calls those
I see
anyway I just realized uacpi has completely broken event initialization order
strange this never caused issues
or actually i guess its less bad than i thought but still
if there is a global firmware lock contention at namespace load time it will hang forever
because the SCI handler is not yet installed at that point
yeah
always spot random stuff when people report issues
I shall do it more often then
lmao
jk
if i discover a uacpi bug for every false uacpi bug report its good enough i guess
Could it be the cause for EC trouble on my PC?
The cosmetic issue
nah
what was the problem there exactly?
That it complains about some uninitialized variable
test obos on it lol
