#pmOS - microkernel OS for RISC-V, x86, and LoongArch

1 messages · Page 2 of 1

carmine nacelle
twilit talon
#

lol

#

thats with no strict mode?

carmine nacelle
#

With both of them

twilit talon
#

F

carmine nacelle
#

Yeah this is a modern standby laptop

twilit talon
#

does dmesg without strict mode still contain that error?

carmine nacelle
#

I think some of them don't even have S3

#

With default boot options on fedora

twilit talon
#

i see

#

i still dont understand this whatsoever

#

how its not failing on that _STA call with strict mode

carmine nacelle
#

I can't find EC chapter in ACPI spec

#

I this I need to sleep

#

I've been looking at SDM of cource I couldn't find it

twilit talon
#

im retarded

#

acpica has an optimization

#

if there's no _INI it doesnt walk down that subtree

#

so it never calls that _BAT's _STA

#

ok case closed at least

carmine nacelle
#

So a fat bug

twilit talon
#

not a bug in this case, just a cosmetic log spam that uacpi does

#

as for the strict-mode error message, it is some ACPICA's bug

#

no one really tests the strict mode

#

i guess

carmine nacelle
#

Pressing random buttons on keyboard

#

Fn

#

And the power button doesn't work

twilit talon
#

btw try closing/opening the lid

#

and plugging/unplugging AC

carmine nacelle
#

It spammed a bunch of stuff

twilit talon
#

it should try to Notify(AC)

#

if it does then your thing is at least vaguely correct

carmine nacelle
#

I'm gonna remove pritnfs

twilit talon
#

the text is kinda unreadable at that res

carmine nacelle
#

Yeah I need to fix scaling

twilit talon
#

no like

#

its discord video quality

carmine nacelle
#

But it's sending a bunch of events working from battery

twilit talon
#

which Notify is it saying it gets

carmine nacelle
#

Even connecting/disconnecting USB sends notifications

twilit talon
#

or power rather

carmine nacelle
twilit talon
#

which ones do u get when u connect power

carmine nacelle
#

Just unplugging it and leaving on battery

#

Wait a minute I'm gonna remove logs

#

Pritnfs*

#

Since it doesn't hang anymore

twilit talon
#

sure

twilit talon
carmine nacelle
#

What is this

#

Medium long story?

twilit talon
#

Windows Management Instrumentation Device

#

Basically firmware talking to windows at runtime

#

for device specific events & configuration

carmine nacelle
#

Fun

#

This laptop has a bunch of sensors

twilit talon
carmine nacelle
#

Like for ambient light level and presence detection

#

Could it be that?

twilit talon
#

some examples of what your aml has that is configurable via WMI

twilit talon
carmine nacelle
#

Is this normal?

twilit talon
#

oh yeah looks correct, u get a notify for ADP0 (power adapter) status change, and the battery

carmine nacelle
#

It's spamming a bunch of this

twilit talon
carmine nacelle
#

If I disconnect it from the wall

twilit talon
#

WMID or battery

carmine nacelle
#

This is what I get if I disconnect the USB hub

twilit talon
#

yeah wait a sec

#

your firmware might be truly fucked

#

ill see where it has a stray embedded control opregion

carmine nacelle
#

This is what i get conencting the charger

twilit talon
#

looks correct

#

ADP0 status change and BAT0 status change

#

0x80 means status change

#

if you install notify handlers to these devices u would get them called by uacpi prompting you to re-read their status

#

btw power button does nothing? @carmine nacelle

carmine nacelle
#

Nothing

twilit talon
#

interesting, could be a uacpi skill issue or could be something else

#

ok so

#

your firmware is basically

#

fucked

#

or rather

carmine nacelle
#

But I've only added the old way of power button handling I think

twilit talon
#

the new way is hooking up a Notify handler to the power button device

#

but u dont even get that Notify

#

So basically

#

your firmware just creates an entirely new EmbeddeControl opregion

#

that has no _REG method or anything

#

and assumes its accessible if the main opregion is available

#

acpica has a special workaround for this which i've ignored because i never saw a real life example

#

but now i do lmao

carmine nacelle
#

Will it be fixed by uACPI?

#

Or like does it have to be my OS's quirk

mellow sleet
#

uacpi probably

twilit talon
#

nah ill fix it ofc

mellow sleet
#

sinec acpicia works around it

twilit talon
#

basically yeah

#

@carmine nacelle u can fix it right now by installing the EmbeddedControl handler to root

#

instead of the EC node

carmine nacelle
#

Meh I'll wait I guess

#

Or not...

#

address space handler?

twilit talon
#

ohh

#

nvm

#

i was thiking of a different workaround

#

linux does this

#
        acpi_handle scope_handle = ec == first_ec ? ACPI_ROOT_OBJECT : ec->handle;

        acpi_ec_enter_noirq(ec);
        status = acpi_install_address_space_handler_no_reg(scope_handle,
                                   ACPI_ADR_SPACE_EC,
                                   &acpi_ec_space_handler,
                                   NULL, ec);
#

if its the first EC being created the handlers are installed to root

#

otherwise to EC scope

carmine nacelle
#

So this is what I have to do?

twilit talon
#

yup

#

i was initially thiking of this workaround:

/*******************************************************************************
 *
 * FUNCTION:    AcpiEvExecuteOrphanRegMethod
 *
 * PARAMETERS:  DeviceNode          - Namespace node for an ACPI device
 *              SpaceId             - The address space ID
 *
 * RETURN:      None
 *
 * DESCRIPTION: Execute an "orphan" _REG method that appears under an ACPI
 *              device. This is a _REG method that has no corresponding region
 *              within the device's scope. ACPI tables depending on these
 *              "orphan" _REG methods have been seen for both EC and GPIO
 *              Operation Regions. Presumably the Windows ACPI implementation
 *              always calls the _REG method independent of the presence of
 *              an actual Operation Region with the correct address space ID.
 *
 *  MUTEX:      Assumes the namespace is locked
 *
 ******************************************************************************/

static void
AcpiEvExecuteOrphanRegMethod (
carmine nacelle
#

And it's not gonna be fixed by uACPI

twilit talon
#

but this isnt your case

twilit talon
#

i just misunderstood

carmine nacelle
#

ok

twilit talon
#

_REG methods that are orphans

#

what linux does makes a lot of sense actually

#

if its the only EC u can handle all opregions of this type with it

#

if there are multiple all other ones will be region-local

carmine nacelle
#

stupid question but how do I pass root to uacpi_install_address_space_handler?

twilit talon
#

uacpi_namespace_root()

carmine nacelle
#

Is UBTC USB type c?

twilit talon
#

yup

#

works fine now i guess?

carmine nacelle
#

Yep

twilit talon
#
Device (UBTC)
{
    Name (_HID, EisaId ("USBC000"))  // _HID: Hardware ID
    Name (_CID, EisaId ("PNP0CA0"))  // _CID: Compatible ID
    Name (_UID, Zero)  // _UID: Unique ID
    Name (_DDN, "USB Type C")  // _DDN: DOS Device Name
#

do u get this notify when attaching something to port?

carmine nacelle
#

Yes

#

Or a charger

#

This laptop has 3 USB C ports

#

And that's it

#

(also USB 4)

#

(and I have a thunderbolt 3 laptop)

twilit talon
#

nice

carmine nacelle
#

(so it could be something to try to implement)

twilit talon
#

fuck i wannna know why power button doesnt do anything

carmine nacelle
#

Lid also works I think

twilit talon
#

you're supposed to be getting _Q35 but you arent for some reason

carmine nacelle
twilit talon
#

nice, LID status change

#

at least your ec driver is good now

#

the power button thing bothers me because qookie had the exact same issue

carmine nacelle
#

Keyboard backlight

twilit talon
#

i wonder if firmware expects you to run some extra methods for this to work

carmine nacelle
#

Where do I put the printfs

twilit talon
#

wdym?

carmine nacelle
#

To debug it

twilit talon
#

let me see

#

like basically what happens is probably the EC has some sort of an if (should_generate_event(...))

#

that we're failing

#

idk why

#

but like it has no problem generating e.g. lid status changes

#

which is strange

#

like i would imagine maybe it checks the os version to decide, but then again uacpi responds yes to all modern windows versions

#

@carmine nacelle are your timed mutex acquires implemented correctly?

carmine nacelle
#

I ignore timeouts

twilit talon
#

just unconditional forever wait?

carmine nacelle
carmine nacelle
twilit talon
#

ok that should be fine then

carmine nacelle
#

And it's the same mutex as usual

#

Which should be working

#

Or assert fail if it doesn't

twilit talon
#

what are we fucking up hmm

#

you install after namespace initialize right?

twilit talon
carmine nacelle
#

I'll look at it later

twilit talon
#

same thing but u dont have to manually create these structs

#

and free

carmine nacelle
#

Something might be hanging and we might not be seeing it

twilit talon
#

i doubt its hanging because ive seen the exact same behavior on mammogram on qookies laptop

#

all notifies coming it but the power button

#

i dont fucking understand

#

skill issue, but where

#

@carmine nacelle just for funsies, can u try uacpi_uninstall_interface("Windows 2015") before loading the namespace

#

lets pretend we're windows 7 and not 10

#

who knows

carmine nacelle
#

Does this laptop even support Windows 7

#

And it shipped with windows 11

twilit talon
#

well aml does

carmine nacelle
#

(I'll check it once I come back)

twilit talon
#

it queries for all windows versions up to 10

carmine nacelle
#

Linux meme

twilit talon
#

the TLDR is every linux now responds false to it

carmine nacelle
#

Yes

#

2006 is Vista?

twilit talon
#

ye

carmine nacelle
#

Could interrupts somehow be broken?

#

Or does EC use the same line?

twilit talon
#

its the same line for all notifications

#

all ACPI notifications use IRQ 9

twilit talon
#

i wonder what we're doing wrong

#

like we know the order is correct here, I've verified against linux

#

and they do react to the power button

#

right?

carmine nacelle
#

could this be related?

carmine nacelle
twilit talon
#

yeah all your logs are correct

carmine nacelle
#

Some of the FN buttons are also broken

#

But maybe it's sent to PS/2

#

Like lock, calculator and some other things

#

Sound controls

#

I can try managram...

#

Could there be some other mechanism?

#

For the power button

twilit talon
#

maybe

twilit talon
twilit talon
#

there are two possibilities

#
  1. since you don't have any sort of power management you don't call any methods that do stuff related to that, perhaps power button is initialized as part of that
  2. uacpi does some IO incorrectly which leads to incorrectly initialized state of something
#

if you're feeling brave u can try porting ACPICA

carmine nacelle
#

Keyronex has acpica, right?

twilit talon
#

and see if we can exclude case 2

#

keyronex is uacpi

carmine nacelle
#

Who had it then

twilit talon
#

nobody

carmine nacelle
#

Bruh

twilit talon
#

but u can try porting it LULW

carmine nacelle
#

I don't want to

#

I have better things to do

twilit talon
#

tbh its public api is similar to uacpi's so u wont struggle too much, but its very hard to port because there isnt a clear interface for stdlib

carmine nacelle
#

Does Linux have some sort of debug mode for acpi?

twilit talon
#

like yes but it has so many acpi-related drivers

#

its impossible to tell which one could affect this

carmine nacelle
#

Which was the other laptop where power button wasn't working?

#

Maybe there's something in common

twilit talon
hexed acorn
#

i think the model goes something like hp laptop 15s-eq1124nw

#

i havent tried managarm on it recently so maybe it works now

carmine nacelle
#

Chatgpt says this

#

The issue that I'm having is that everything works but the power button

twilit talon
#

like u dont get any irq at all

#

so that means something isnt configured correctly

#

whos skill issue that is remains unknown

twilit talon
carmine nacelle
#

How do I see AML?

hoary moat
#

When looking at managarm code, they do register some gpe events after finalizing gpe init

#

Which sounds wrong

carmine nacelle
twilit talon
#

EC init happens in _REG

#

but it's really hard to tell what it does exactly because obv its chipset specific

hoary moat
#

Might be a problem

#

I register all my GPEs before finalizing init

#

So does Linux I think

twilit talon
#

yeah managarm only does it because uacpi didnt have thread safety

#

so it would crash during ns init

#

because it would get an irq

carmine nacelle
#

PNP0C0C?

twilit talon
carmine nacelle
#

Could I need to be registering it explicitly?

twilit talon
#

if we configured EC correctly you would get a query which would result in Notify(PWRB)

twilit talon
#

from the software standpoint you're doing everything correctly

twilit talon
#

because he calls all power-related methods

#

or at least some of them

carmine nacelle
#

Linux does this

static bool acpi_wakeup_gpe_init(struct acpi_device *device)
{
    static const struct acpi_device_id button_device_ids[] = {
        {"PNP0C0C", 0},                /* Power button */
        {"PNP0C0D", ACPI_AVOID_WAKE_FROM_S5},    /* Lid */
        {"PNP0C0E", ACPI_AVOID_WAKE_FROM_S5},    /* Sleep button */
        {"", 0},
    };
    struct acpi_device_wakeup *wakeup = &device->wakeup;
    const struct acpi_device_id *match;
    acpi_status status;

    wakeup->flags.notifier_present = 0;

    /* Power button, Lid switch always enable wakeup */
    match = acpi_match_acpi_device(button_device_ids, device);
    if (match) {
        if ((match->driver_data & ACPI_AVOID_WAKE_FROM_S5) &&
            wakeup->sleep_state == ACPI_STATE_S5)
            wakeup->sleep_state = ACPI_STATE_S4;
        acpi_mark_gpe_for_wake(wakeup->gpe_device, wakeup->gpe_number);
        device_set_wakeup_capable(&device->dev, true);
        return true;
    }

    status = acpi_setup_gpe_for_wake(device->handle, wakeup->gpe_device,
                     wakeup->gpe_number);
    return ACPI_SUCCESS(status);
}
hoary moat
#

And is also for wake from suspend

#

Iirc

twilit talon
#

runtime notifications are done via EC

carmine nacelle
#

So not what I want

twilit talon
#

basically yeah

hoary moat
#

Yeah

#

Daily obos shilling

#

There is obos' code for enabling wake gpes

twilit talon
#

like the simplest way to debug it would be trying to make an acpica driver that does the exact same thing u do with uacpi

#

if u do get a power button notifcation with it then its a uacpi bug

#

otherwise its u not calling some configuration method or ordering

carmine nacelle
#

The spec says this

The power button programming model can also use the generic hardware programming model. This allows the power
button to reside in any of the generic hardware address spaces (for example, the embedded controller) instead of fixed
space. If the power button is implemented using generic hardware, then the OEM needs to define the power button as
a device with an _HID object value of “PNP0C0C,” which then identifies this device as the power button to OSPM.
The AML event handler then generates a Notify command to notify OSPM that a power button event was generated.
While the system is in the working state, a power button press is a user request to transition the system into either the
sleeping (G1) or soft-off state (G2). In these cases, the power button event handler issues the Notify command with
the device specific code of 0x80. This indicates to OSPM to pass control to the power button driver (PNP0C0C) with
the knowledge that a transition out of the G0 state is being requested. Upon waking from a G1 sleeping state, the AML
event handler generates a notify command with the code of 0x2 to indicate it was responsible for waking the system.

#

Could it be sent by HID?

twilit talon
#

_HID is just a string object

#

In these cases, the power button event handler issues the Notify command with
the device specific code of 0x80.

#

this is what u dont get

carmine nacelle
#

I think I'll try to fix my PS/2 driver

#

I don't think I'm doing that

In order to hook that up you will need to:

Write an embedded controller driver
Find the EC device in the AML namespace (PNP ID "PNP0C09" or ECDT table), attach an address space handler
Find a power button object in the namespace, attach a notify handler
Detect the general purpose event number used by the embedded controller (_GPE method), install a handler for it
In the event handler, execute the QR_EC command to find out the index of the query requested by the EC
Run the requested query by executing the corresponding "EC._QXX" control method in AML
If this query was for a power button press, you will receive a notifications with value 0x80 (S0 Power Button Pressed)
#

Wait, no, I do

#

nevermind

#

Imma try managram

twilit talon
#

try it but i doubt anything is going to change

vale hazel
#

TESTING IT NOW

twilit talon
#

im really curious what we're doing wrong for the power button but thats currently too much work to debug

vale hazel
#

power button works

#

just fine

#

wyall mean

twilit talon
#

is your power button routed via EC?

#

show us the kernel output

carmine nacelle
vale hazel
#

because its on my mani system

#

it did say some errors

#

though

twilit talon
#

wdym

carmine nacelle
#

If it's assert fail that's fine

twilit talon
#

does it shutdown instantly?

carmine nacelle
#

My shutdown has a 3 seconds timer

vale hazel
#

power button pressed

#

shutting down in 3 seconds...

twilit talon
#

then its a fixed event

#

not an EC query

vale hazel
#

okay i see

twilit talon
#

he doesnt have power button notify handlers hooked up

#

so we would see log spam

carmine nacelle
#

I have an old macbook at home, which was also not shutting down without EC driver

#

I'm coming there this weekend and can try to test it

#

(also I finish classes this week, so disregarding exams I'll have a lot of time for osdev spun)

twilit talon
#

macs do have ECs i think

#

albeit quirky ones

carmine nacelle
#

It's 2012 mac so that's gonna be fun

carmine nacelle
twilit talon
#

i wish we could easily test acpica

#

@carmine nacelle if u could build a custom linux to run on your hw we could also add prints or trace io done by acpica or something

carmine nacelle
#

Ok

#

What do I need to do

twilit talon
#

build linux

#

ill tell u where to add printfs

carmine nacelle
#

Ok

#

I might do that in a couple of hours

twilit talon
#

nice

#

first thing we're gonna trace EC queries that it receives

carmine nacelle
#

I need to finish some stuff

#

Still, can power button somehow be wired to keyboard or something weird?

twilit talon
#

i have a suspicion it requires advanced platform power capabilities that are configured via _OSC

carmine nacelle
#

I might as well implement that if it's not too difficult

twilit talon
#

anyway we're gonna find out what it requires

#

by commenting stuff out or adding printfs

carmine nacelle
#

Fun

#

Linux dualboot time

#

Although I think I can just boot life cd with custom kernel

twilit talon
#

u can just make a live usb or something

#

yeah

carmine nacelle
#

Like it's a grub option away

#

I've built lfs once...

#

Anyway

#

I could also try bsds

twilit talon
#

there's already this as a start

carmine nacelle
#

I think I really need to learn about Linux internals one day...

twilit talon
#

idk how to enable this print so its easier for us to add our own lmao

carmine nacelle
#

Like it's just C

twilit talon
#

probably some log level we need to set

twilit talon
#

u can go to implementation and find all users of a function

carmine nacelle
#

I think you need to compile linux with DEBUG?

twilit talon
#

nah

carmine nacelle
#

Then it starts to printk

twilit talon
#

just replace those with pr_info

carmine nacelle
#

following the macros

twilit talon
#

yeah but we dont care

#

we dont want all spam just this

carmine nacelle
#

Ok I'm getting distracted

#

I need to turn a lab report in in 2 hours

twilit talon
#

yeye

carmine nacelle
#

Ok, time for Linux

#

@twilit talon what do I patch

twilit talon
#

for starters

carmine nacelle
#

Do I replace everything?

twilit talon
#

no just started tbh

#

just to see if linux gets it at least

carmine nacelle
#

What kernel options do I need

#

I can't find AMDGPU...

#

Ok i'm compiling it

#

Never compiled linux on this laptop

#

bruh

kernel/sys.c:1307:21: error: ‘LINUX_VERSION_PATCHLEVEL’ undeclared (first use in this function); did you mean ‘LINUX_VERSION_CODE’?
 1307 |                 v = LINUX_VERSION_PATCHLEVEL + 60;
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~
      |                     LINUX_VERSION_CODE
twilit talon
carmine nacelle
#

I've enabled amdgpu and my wifi card

#

As built in

#

It should boot if I just use the new kernel, right?

#

Like without modules and stuff

#

(idk why it wouldn't)

twilit talon
#

yes

carmine nacelle
#

Why am I getting this ```
drivers/usb/core/hcd.c:115:33: error: ‘LINUX_VERSION_PATCHLEVEL’ undeclared here (not in a function); did you mean ‘LINUX_VERSION_CODE’?
115 | #define KERNEL_VER bin2bcd(LINUX_VERSION_PATCHLEVEL)

#

I've checked out to v6.13

#

It shouldn't be broken

twilit talon
#

how do u configure it

carmine nacelle
#

make menuconfig

twilit talon
#

ah

#

yeah idk, linux surely doesnt have any broken commits

#

so its some skill issue on your part i believe

carmine nacelle
#

I'll redownload it

#

Idk

#

I'm too stupid

#

How do I write linux to drive

#

(i mead dd)

#

I'm gonna try rufus again

#

because with dd windows can't read the partitions

#

skill issue ratified

twilit talon
#

nice

carmine nacelle
#

What am I doing wrong why does it hang after this

#

@twilit talon ?

twilit talon
#

i dont even know what that means

#

not sure

#

this doesnt look like a dmesg

carmine nacelle
#

It's grub

#

I'm gonna try USB 3 port...

twilit talon
#

very strange

#

does it boot in qemu?

carmine nacelle
#

Idk

#

I'm supposed to be using bzImage instead of vmlinuz, right?

#

I'm too tired for this

twilit talon
#

one is deprecated

#

i dont remember which one lmao

carmine nacelle
#
twilit talon
#

bruh

#

linux is kinda annoying

carmine nacelle
#

Btw I think this laptop doesn't even have CSM

#

I'll try fedora instead of Ubuntu...

#

I'm hoping Linus' favourite is gonna do better

twilit talon
#

try it

carmine nacelle
#

It turns off after a bit

twilit talon
#

F

carmine nacelle
#

Idk what am I supposed to do

#

I think I'll dualboot fedora finally

#

One small problem

twilit talon
#

Time to get a separate nvme for linux

carmine nacelle
carmine nacelle
#

I've installed fedora

#

@twilit talon this laptop can't suspend with Linux

twilit talon
#

thats a separate bug albeit also important

#

if you want it fixed u can write an email to power management maintiners

carmine nacelle
#

this doesn't look out of place i'd suppose

#

anyways

#

I'm trying to compile linux again

#

Wow, this laptop flies with linux

twilit talon
#

it says s2idle

#

thats kind of a fake suspend

#

should be using s3

carmine nacelle
#

It's a modern standby laptop

#

So it might not have s3

twilit talon
#

grep dmesg

twilit talon
#

S3

#

dmesg has all available modes

carmine nacelle
twilit talon
#

to verify, is there s5?

carmine nacelle
#
misha@fedora:~/linux-6.12.5$ sudo cat /sys/power/mem_sleep 
[s2idle]
twilit talon
#

not this

#

btw

#

did u add that patch?

carmine nacelle
#

No

#

I'm trying to install vscode

twilit talon
#

vim

carmine nacelle
#

meh

#

I'm not profficient enough in it

#

Idk if it's bios stupidity, but this laptop is refusing to speed up fans to decent rpm

#

With Linux

twilit talon
#

fans are aml controlled

#

or via other drivers

carmine nacelle
#

it's almost compiled

#

I'm booting mainline kernel...

#

Omg it worked ```
[ 70.413998] ACPI: EC: Query(0x11) started
[ 70.414243] ACPI: EC: Query(0x11) stopped
[ 70.576168] ACPI: EC: Query(0x11) started
[ 70.576375] ACPI: EC: Query(0x11) stopped
[ 71.055577] ACPI: EC: Query(0x12) started
[ 71.055719] ACPI: EC: Query(0x12) stopped
[ 71.181797] ACPI: EC: Query(0x12) started

carmine nacelle
twilit talon
#

ok thats an amazing find

carmine nacelle
#

What do we do now lol

twilit talon
#

u get these queries as well right?

#

the ones its getting

carmine nacelle
#

Which ones

#

I think so

twilit talon
#

0x12 etc

carmine nacelle
#

Like if I connect and disconnect the battery I also get a bunch queries

twilit talon
#

no missing queries that happen for linux but not for u?

carmine nacelle
#

It's the other way around

twilit talon
#

wdym

carmine nacelle
#

Like disconnecting a charger pmOS would receive a query every few seconds or so

#

And I haven't noticed that on Linux

#

Although that might be from AML

twilit talon
#

possible because linux actually reacts to those queries and u do nothing

#

lmao

carmine nacelle
#

But yeah in general I think I have the same

#

Stuff

#

Where could the power button be coming from then?

twilit talon
carmine nacelle
#

Bruh Linux is so fucked it doesn't even turn the screen off when closing the lid

twilit talon
#

hmm i wonder how we can find that out

#

let see

#

add printfs here

#

if this is called when u press the power button we'll panic to dump the backtrace

carmine nacelle
#

Do I remove other printfs?

#

no

twilit talon
#

keep them its fine

twilit talon
#

we added printfs to linux on his laptop

#

@carmine nacelle whats the laptop brand again

carmine nacelle
#

acpi shouldn't be a module, right?

carmine nacelle
twilit talon
#

no

carmine nacelle
#

Yoga slim 7 8th gen

#

amd

twilit talon
#

hmm i wonder if thinkpad_acpi.c is applicable to you

carmine nacelle
#

@twilit talon ```
[ 61.668168] ACPI: button: acpi_button_notify handle 00000000c935dbe2 event 128 device 000000004764d9ce
[ 61.668199] ACPI: button: acpi_button_notify: power

carmine nacelle
twilit talon
#

ok

#

now we need to panic

carmine nacelle
#

I was between this laptop and a similar thinkpad when buying it

carmine nacelle
twilit talon
#

or actually

carmine nacelle
#

how do I extract the stuff from handle

twilit talon
#

u dont

#

dump_backtrace() or something

#

there should be a function like that

#

or do WARN_ON(1)

#

where u have that printf

carmine nacelle
#

Why does it take like half an hour to compile a single c file

twilit talon
#

lol

carmine nacelle
#

and link the kernel

#

anyway

twilit talon
#

we're about to find out where its called from i guess

#

becaues its definitely not the ec

#

actually we might not

#

because it will be dispatched from the work queue

carmine nacelle
#

rebooting...

twilit talon
#

we need to catch it when it gets scheduled

carmine nacelle
#

maybe not yet

twilit talon
#

well try it anyway maybe we'll see something

carmine nacelle
#

INSTALL /boot also takes like half an hour

#

on PM971

#

anyway

twilit talon
#

im gonna need u to do more complex hacking

carmine nacelle
twilit talon
#

lol

carmine nacelle
#

And it's taking its time...

twilit talon
#

@carmine nacelle u do install a fixed event handler for it right?

carmine nacelle
#

Idr

twilit talon
#

please dont tell me u dont

twilit talon
#

ok yeah u do

carmine nacelle
#

And it worked on linuxmaster's laptop

twilit talon
#

next time

#

did it finish updating?

carmine nacelle
#

bruh it did but it booted into the wrong kernel

twilit talon
carmine nacelle
#

Since the update was for the kernel

#

Lol

twilit talon
#

bruyh

carmine nacelle
#
[   34.567108] Call Trace:
[   34.567112]  <TASK>
[   34.567115]  ? acpi_button_notify+0x28/0x140
[   34.567119]  ? __warn.cold+0x93/0xfa
[   34.567124]  ? acpi_button_notify+0x28/0x140
[   34.567134]  ? report_bug+0xff/0x140
[   34.567142]  ? handle_bug+0x58/0x90
[   34.567148]  ? exc_invalid_op+0x17/0x70
[   34.567153]  ? asm_exc_invalid_op+0x1a/0x20
[   34.567164]  ? acpi_button_notify+0x28/0x140
[   34.567170]  acpi_ev_notify_dispatch+0x48/0x80
[   34.567179]  acpi_os_execute_deferred+0x17/0x30
[   34.567184]  process_one_work+0x176/0x330
[   34.567193]  worker_thread+0x252/0x390
[   34.567201]  ? __pfx_worker_thread+0x10/0x10
[   34.567207]  kthread+0xcf/0x100
[   34.567212]  ? __pfx_kthread+0x10/0x10
[   34.567217]  ret_from_fork+0x31/0x50
[   34.567223]  ? __pfx_kthread+0x10/0x10
[   34.567228]  ret_from_fork_asm+0x1a/0x30
[   34.567239]  </TASK>
[   34.567242] ---[ end trace 0000000000000000 ]---
#

Yep it's from queue

twilit talon
#

okay so

#

more advanced hacking

carmine nacelle
#

printfs with if statements?

twilit talon
#

or actually

#

we can simplify it

#

i want u do add a WARN_ON(1) to acpi_os_execute if the work is of type OSL_NOTIFY_HANDLER

#

acpi/osl.c

carmine nacelle
#

osunixxf.c?

twilit talon
#

acpi/osl.c

#

very curious what we're about to discover

carmine nacelle
#

compiling...

twilit talon
#

and will have some extra stuff because of other notifies

carmine nacelle
#

wait, I forgor about the other printf

twilit talon
#

its fine but u can add it if its not too late

carmine nacelle
#

it's linking the kernel

twilit talon
#

there may be one extra layer of abstraction but we'll see

carmine nacelle
#
[   50.757662] Call Trace:
[   50.757665]  <TASK>
[   50.757669]  ? acpi_os_execute+0xf5/0x110
[   50.757676]  ? __warn.cold+0x93/0xfa
[   50.757682]  ? acpi_os_execute+0xf5/0x110
[   50.757699]  ? report_bug+0xff/0x140
[   50.757708]  ? handle_bug+0x58/0x90
[   50.757716]  ? exc_invalid_op+0x17/0x70
[   50.757723]  ? asm_exc_invalid_op+0x1a/0x20
[   50.757738]  ? __pfx_acpi_ev_notify_dispatch+0x10/0x10
[   50.757758]  ? __pfx_acpi_ev_notify_dispatch+0x10/0x10
[   50.757765]  ? acpi_os_execute+0xf5/0x110
[   50.757773]  acpi_ev_queue_notify_request+0xb2/0x110
[   50.757783]  acpi_ds_exec_end_op+0x19c/0x560
[   50.757791]  acpi_ps_parse_loop+0x100/0x6b0
[   50.757801]  acpi_ps_parse_aml+0x80/0x3c0
[   50.757809]  acpi_ps_execute_method+0x13f/0x270
[   50.757818]  acpi_ns_evaluate+0x13e/0x2d0
[   50.757832]  acpi_evaluate_object+0x182/0x340
[   50.757840]  acpi_execute_simple_method+0x60/0x80
[   50.757851]  acpi_gpio_irq_handler_evt+0x17/0x30
[   50.757855]  irq_thread_fn+0x20/0x60
[   50.757861]  irq_thread+0x1b0/0x2f0
[   50.757866]  ? __pfx_irq_thread_fn+0x10/0x10
[   50.757871]  ? __pfx_irq_thread_dtor+0x10/0x10
[   50.757874]  ? __pfx_irq_thread+0x10/0x10
[   50.757877]  kthread+0xcf/0x100
[   50.757881]  ? __pfx_kthread+0x10/0x10
[   50.757883]  ret_from_fork+0x31/0x50
[   50.757888]  ? __pfx_kthread+0x10/0x10
[   50.757890]  ret_from_fork_asm+0x1a/0x30
[   50.757897]  </TASK>
[   50.757899] ---[ end trace 0000000000000000 ]---
#

I think this is the right one

twilit talon
#

jesus

#

ok we uncovered the secret

carmine nacelle
#

gpio

twilit talon
#

yup

carmine nacelle
#

@hexed acorn ?

twilit talon
#

i guess qookie's stuff is also routed via GPIO

#

let me see which driver is responsible for it

carmine nacelle
#

do you want full dmesg?

twilit talon
#

and fucking bootlin is 503'ing me

twilit talon
#

im glad its not a uacpi skill issue

carmine nacelle
#
/**
 * acpi_gpiochip_request_interrupts() - Register isr for gpio chip ACPI events
 * @chip:      GPIO chip
 *
 * ACPI5 platforms can use GPIO signaled ACPI events. These GPIO interrupts are
 * handled by ACPI event methods which need to be called from the GPIO
 * chip's interrupt handler. acpi_gpiochip_request_interrupts() finds out which
 * GPIO pins have ACPI event methods and assigns interrupt handlers that calls
 * the ACPI event methods for those pins.
 */
twilit talon
#

which file is this

carmine nacelle
#

drivers/gpio/gpiolib-acpi.c:523

#

How does gpio even work on PC?

twilit talon
#

omg i completely missed it

#

because its in SSDT20

carmine nacelle
#

so old windows would have no power button?

twilit talon
#

yeah

#

well we can try

#

it might

#

if u disable windows 2015 & vista

carmine nacelle
twilit talon
#

this is the method

#

thats called by linux on your laptop

#

Notify (\_SB.PWRB, 0x80) // Status Change

#
Name (BUF0, ResourceTemplate ()
{
    GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullDefault, 0x1388,
        "\\_SB.GPIO", 0x00, ResourceConsumer, ,
        )
        {   // Pin list
            0x0000
        }
    GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
        "\\_SB.GPIO", 0x00, ResourceConsumer, ,
        )
        {   // Pin list
            0x003D
        }
    GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
        "\\_SB.GPIO", 0x00, ResourceConsumer, ,
        )
        {   // Pin list
            0x003E
        }
    GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
        "\\_SB.GPIO", 0x00, ResourceConsumer, ,
        )
        {   // Pin list
            0x003A
        }
    GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
        "\\_SB.GPIO", 0x00, ResourceConsumer, ,
        )
        {   // Pin list
            0x003B
        }
    GpioInt (Edge, ActiveLow, ExclusiveAndWake, PullNone, 0x0000,
        "\\_SB.GPIO", 0x00, ResourceConsumer, ,
        )
        {   // Pin list
            0x0012
        }
})
#

and these are the possible event indices

carmine nacelle
#

wait

carmine nacelle
#

sb is south bridge?

twilit talon
#

system bus

carmine nacelle
#

On Hardware-reduced ACPI platforms
definetely my laptop

twilit talon
#

yeah thats why i didnt even consider this option

#

because its a normal x86 laptop

carmine nacelle
#

no, it's an x86 laptop with fucked firmware

twilit talon
#

nah just very overcomplicated modern hw

carmine nacelle
#

Ok I'm rebootig to windows

twilit talon
#
Device (GPIO)
{
    Name (_HID, "AMDI0030")  // _HID: Hardware ID
    Name (_CID, "AMDI0030")  // _CID: Compatible ID
    Name (_UID, 0x00)  // _UID: Unique ID
    Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
    {
        Name (RBUF, ResourceTemplate ()
        {
            Interrupt (ResourceConsumer, Level, ActiveLow, Shared, ,, )
            {
                0x00000007,
            }
            Memory32Fixed (ReadWrite,
                0xFED81500,         // Address Base
                0x00000400,         // Address Length
                )
        })
        Return (RBUF) /* \_SB_.GPIO._CRS.RBUF */
    }

    Method (_STA, 0, NotSerialized)  // _STA: Status
    {
        If ((TSOS >= 0x70))
        {
            Return (0x0F)
        }
        Else
        {
            Return (0x00)
        }
    }
}

You're gonna have to write a driver for this

#

its a controller at 0xFED81500 with IRQ 7

carmine nacelle
#

Where do I look for documentation

#

LPT1 / Unreliable "spurious" interrupt (usually)

#

(from osdev wiki)

twilit talon
#

its an amd gpio controller

#

so i guess google amd gpio controller specification

carmine nacelle
#

no that's not what I want

twilit talon
#

yeah no

#

you will be the first with such a driver

#

drivers/pinctrl/pinctrl-amd.c @carmine nacelle

#

its a tiny driver

carmine nacelle
#

qookie also has AMD

twilit talon
#

yeah

#

i would see who calls acpi_gpiochip_request_interrupts but bootlin is fucking dead

#

maybe u dont even need a special driver for this specific gpio controller

#

id have to read the acpi spec to figure out how tf this is routed

twilit talon
#

otherwise it says device doesnt exist

#

lol

twilit talon
#

hmm u sure thats the one?

#

gpio/gpiolib.c#L2021

#

yeah idk its a whole gpio subsystem

#

no idea how any of this works

#

you will be a pioneer here

carmine nacelle
#

How can I know which devices I have?

twilit talon
#

call _HID and _CID methods of every device node

#

or uacpi_namespace_node_info

carmine nacelle
twilit talon
#

no like

#

u sure the spec refers to this

#

for your driver u can just use uacpi_find_devices("AMDI0030", ...)

#

or find_devices_at which supports multiple hids

carmine nacelle
twilit talon
#

oh cool

carmine nacelle
twilit talon
#

yeah

carmine nacelle
#

what's fch

#

Oh it's amd's chipset

#

according to chatgpt

#

Can WDT be used as another time source? ultrameme

#

Wait does amd have a separate PIC?

#

wtf is this

twilit talon
#
2.17.16.1 Interrupt GPIO
All the configuration bits (Bit[x]) used in the following steps come from GPIOx[0F8:000:step4],
GPIOx[1FC:100:step4] and GPIOx[2DC:200:step4] if the pin is used as an interrupt:
1. The driver should program the DebounceTmrOut/DebounceTmrOutUnit/DebounceCntrl bits according to
the data passed by BIOS through ASL code.
2. Configure Bit[8], Bit[9] and Bit[10] (See GPIOx[0F8:000:step4]) according to the data passed by BIOS
through ASL code.
3. Set Bit[11] = 1 and Bit[12] = 1 (See GPIOx[0F8:000:step4]) to enable interrupt delivery and interrupt status then its interrupt status is at Bit[28] when the GPIO input is asserted.
4. Configure the GPIO controller interrupt, configure as an active low, level interrupt, reference Bit[10:8]
(See GPIOx[0F8:000:step4]).
5. The driver should clear the interrupt status Bit[28] (See GPIOx[0F8:000:step4]), then set GPIOxFC[EOI]
= 1 to deassert interrupt request after acknowledging the interrupt.
#

Basically u need this

#

parse the _AEI and configure thie respective pins

#

then when u get the interrupt for the respective pin call _EVT(pin_idx)

#

In your case these:

Method (_AEI, 0, NotSerialized)  // _AEI: ACPI Event Interrupts
{
    Name (BUF0, ResourceTemplate ()
    {
        GpioInt (Edge, ActiveHigh, ExclusiveAndWake, PullDefault, 0x1388,
            "\\_SB.GPIO", 0x00, ResourceConsumer, ,
            )
            {   // Pin list
                0x0000
            }
        GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
            "\\_SB.GPIO", 0x00, ResourceConsumer, ,
            )
            {   // Pin list
                0x003D
            }
        GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
            "\\_SB.GPIO", 0x00, ResourceConsumer, ,
            )
            {   // Pin list
                0x003E
            }
        GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
            "\\_SB.GPIO", 0x00, ResourceConsumer, ,
            )
            {   // Pin list
                0x003A
            }
        GpioInt (Level, ActiveHigh, ExclusiveAndWake, PullNone, 0x0000,
            "\\_SB.GPIO", 0x00, ResourceConsumer, ,
            )
            {   // Pin list
                0x003B
            }
        GpioInt (Edge, ActiveLow, ExclusiveAndWake, PullNone, 0x0000,
            "\\_SB.GPIO", 0x00, ResourceConsumer, ,
            )
            {   // Pin list
                0x0012
            }
    })
    M460 ("  OEM-ASL-\\_SB.GPIO._AEI\n", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
    Return (BUF0) /* \_SB_.GPIO._AEI.BUF0 */
}
#

uacpi_for_each_device_resource(gpio, "_AEI", do_configure_pin)

#

it even tells u 2. Configure Bit[8], Bit[9] and Bit[10] (See GPIOx[0F8:000:step4]) according to the data passed by BIOS through ASL code.

carmine nacelle
#

so it's not even amd specific?

twilit talon
#

But technically yes

carmine nacelle
#

Thonk This is my b550 desktop

#

Cool, I think I have 3 PCs to test this on...

twilit talon
#

anyway should be easy to do

hexed acorn
hexed acorn
#

i decompiled it with iasl -e ssd* -d dsdt.dat

twilit talon
#

do i have your dump?

hexed acorn
#

you should

twilit talon
#

hmm

#

can u resend it

carmine nacelle
#

How do I extract this with uACPI?

Name (RBUF, ResourceTemplate ()
{
    Interrupt (ResourceConsumer, Level, ActiveLow, Shared, ,, )
    {
        0x00000007,
    }
    Memory32Fixed (ReadWrite,
        0xFED81500,         // Address Base
        0x00000400,         // Address Length
        )
})
Return (RBUF) /* \_SB_.GPIO._CRS.RBUF */```
twilit talon
hexed acorn
#

are there any sensitive tables other than the one with the windows key

twilit talon
#

or uacpi_get_current_resources

carmine nacelle
#

Yes, and then

carmine nacelle
#

Wait

twilit talon
carmine nacelle
#

I have similar code in interrupts routing stuff

twilit talon
#

yes

#

and EC

#

its all the same code, just different resource types

hexed acorn
twilit talon
#

lets see

carmine nacelle
#

Fun, my PCI routing code was leaking memory

twilit talon
#

exact same thing as his pc

#

ssdt15

#

Notify (\_SB.PWRB, 0x80)

#

and u have a GPIO device with AMDI0030

#

okay nice case closed

carmine nacelle
#

I'm trying to write the driver

twilit talon
#

would be nice to have this driver for managarm as well

#

if u manage to get it working ill try to steal your code

carmine nacelle
#

Oh I'm dumb I didn't read the headers

hexed acorn
twilit talon
#

never used -e

hexed acorn
#

iasl -da dsdt.dat ssdt* also doesn't work because it cries about stuff getting redefined

twilit talon
#

GPIO driver for managarm when

#

i just do iasl *.dat

hexed acorn
#

yeah but that yields multiple source files right

twilit talon
#

yeah

hexed acorn
#

i was thinking of decompiling it such that you get one combined source file

twilit talon
#

but it doesnt really matter

#

ssdt* will incorrectly sort ssdt1 ssdt10 etc

hexed acorn
#

true

twilit talon
#

your gpio has two memory regions for some reason

#
Memory32Fixed (ReadWrite,
    0xFED81500,         // Address Base
    0x00000400,         // Address Length
    )
Memory32Fixed (ReadWrite,
    0xFED81200,         // Address Base
    0x00000100,         // Address Length
    )
})
hexed acorn
#

looks like iasl goes through arguments in reverse order as well :^)

twilit talon
#

lmao

carmine nacelle
#

Wtf is UACPI_POLARITY_ACTIVE_BOTH?

twilit talon
#

Some resource types allow Both

#

i didnt invent these types lol

#
ActiveLevel can be one of ActiveHigh, ActiveLow or ActiveBoth. ActiveBoth can be specified only if EdgeLevel is Edge. The bit field name _POL is automatically created to refer to this portion of the resource descriptor.
carmine nacelle
carmine nacelle
twilit talon
#

use it?

carmine nacelle
#

Mine has 1

twilit talon
#

this is qookie's

#

you dont care about that

carmine nacelle
#

Just the first one

twilit talon
#

yeah

carmine nacelle
twilit talon
#

id look how linux deals with it

hexed acorn
#

i do not see any redefinition errors in dmesg

carmine nacelle
#

My friend has a ryzen laptop

#

and my sister

twilit talon
carmine nacelle
#

Maybe I can convence them to dump their aml as well

twilit talon
#

AML often has shit like

if (REG == 123) { Device (IDK) {} }

#

so some devices are only instantiated if some platform state says they exist etc

hexed acorn
#

iasl option to accept a log of all mmio/pio to decompile correctly when

twilit talon
#

could be nice

#

So strange like they route a lot of things via EC but then the fucking power button requires a separate driver lmao

hexed acorn
#

ran out of pins on the ec :^)

twilit talon
#

lmao

#

had to dump linux backtraces to figure out how the fuck it gets that button press LULW

#

apparently all modern AMD is this way

hexed acorn
#

okay but this is gonna be kinda annoying to handle

#

i don't really want the gpio driver in the kernel

twilit talon
#

we dont really need the full gpio driver tbh, could just have a stub that configures interrupts

#

but yeah

#

ideally its somehow configured via userspace

#

by listening to acpi devices on mbus

carmine nacelle
#

GPIO is mmio registers

#

What do I do with 2 memory regions?

twilit talon
#

its the mmio address?

hexed acorn
hexed acorn
#

and the kernel would just look for the gpio device ig

twilit talon
#

yeah maybe

hexed acorn
#

lunix seems to ignore the second mmio region?

twilit talon
#

did u find the code for when it checks that?

#

i cant seem to find it

carmine nacelle
#

What does windows say in device manager?

#

About memory

hexed acorn
#
    gpio_dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
    if (IS_ERR(gpio_dev->base)) {
        dev_err(&pdev->dev, "Failed to get gpio io resource.\n");
        return PTR_ERR(gpio_dev->base);
    }
#

i assume the 0 means 0-th resource

carmine nacelle
#

Like mine is this

#

What's on my desktop though? Thonk

hexed acorn
#

i do still have the win10 install around

twilit talon
#

well windows displaying that resource type doesnt mean it uses it for anything

hexed acorn
#

that's also true

twilit talon
#

it reserves it to prevent conflicts

twilit talon
#

resource 0 is irq tho

carmine nacelle
#

What does it mean per ACPI spec?

hexed acorn
#

considering ioremap maybe it means first mem/port resource?

carmine nacelle
#

Like if the device has 2 memory ranges

#

(I'm kinda talking to myself)

twilit talon
#

these resource lists are not regulated by the spec

#

its device specific

twilit talon
#

i will check if bootlin loads

carmine nacelle
#

So just throw my hands in the air and ignore it?

twilit talon
#

doesnt mean you have to do anything about it

twilit talon
carmine nacelle
#

But what if some hardware swaps the order around

twilit talon
#

its always the same for each device type

carmine nacelle
twilit talon
#

so in your case u ignore it yes

carmine nacelle
#

So doesn't matter for now I guess...

vale hazel
#

i wanna mess around with aml

#

language seems cool

#

af

twilit talon
#

i mean idk look at examples

#

its pretty easy

#

U have methods, they have Local variables, and Args

#

Its like python

vale hazel
#

ah kk

#

what about getting something to execute it tho

twilit talon
#

u can have the uacpi test runner to execute it

vale hazel
#

alr

carmine nacelle
#

Btw @twilit talon does uacpi have macros for uacpi_resource_fixed_memory32::write_status bits?

twilit talon
#

yes

vale hazel
#

when online uacpi aml interpreter

twilit talon
twilit talon
hexed acorn
# twilit talon perhaps

seems to be the case because the code just below does platform_get_irq with an index of 0 as well

twilit talon
#

lets see...

hexed acorn
#
void __iomem *
devm_platform_get_and_ioremap_resource(struct platform_device *pdev,
                unsigned int index, struct resource **res)
{
    struct resource *r;

    r = platform_get_resource(pdev, IORESOURCE_MEM, index);
    if (res)
        *res = r;
    return devm_ioremap_resource(&pdev->dev, r);
}```
twilit talon
#

yeah ur right

#

so even the order doesnt matter

carmine nacelle
#

Or does it only take these values

twilit talon
#

only those

carmine nacelle
#

I mean realistically I can assert it

hexed acorn
#

now i want to know what the second entry is referring to, but i can't seem to find chipset docs, and ig i won't find out from linux

carmine nacelle
#

Wth would write only resource be doing there

twilit talon
#
static const struct uacpi_resource_convert_instruction convert_memory32[] = {
    OP(BIT_FIELD_1, AML_F(memory32, information),
                    NATIVE_F(memory32, write_status), IMM(0)),
    OP(FIELD_32, AML_F(memory32, minimum), NATIVE_F(memory32, minimum), IMM(4)),
    END(),
};
#

its very simple

#

just that bit

#

the rest is zeroed

hexed acorn
carmine nacelle
twilit talon
carmine nacelle
#

Everything is open source if you have IDA?

hexed acorn
hexed acorn
twilit talon
#

which spec is this?

carmine nacelle
hexed acorn
#

the one mishakov linked

twilit talon
#

ah

#

i guess yours is more modern so u have other crap there

hexed acorn
#

i guess

#

but i really want to know what it is

carmine nacelle
#

Mine is Zen 4

twilit talon
#

time to find your platforms spec

carmine nacelle
#

Like last year's

#

And it doesn't have that

hexed acorn
#

maybe it's a register containing the seed for a bitcoin wallet with 10mil in it

carmine nacelle
#

best place to hide that

hexed acorn
#

the seed is a bunch of words from a predetermined dictionary

twilit talon
#

if there are docs for his platform only from last year surely u can find docs for yours

hexed acorn
#

family 15h is pre-zen

twilit talon
#

ah damn

hexed acorn
#

if the 2 reddit posts on r/amd with a combined 11 comments hasn't pushed them to do so, i don't know what will

twilit talon
#

well linux does work on your pc right

hexed acorn
#

yeah

twilit talon
#

so nothing of importance probably

hexed acorn
#

i mean yeah that much i figured, it's just sheer curiosity at this point

twilit talon
#

ida time

#

are you going to try to implement this for managarm btw?

hexed acorn
#

could certainly try later yeah

#

i'll need gpio for my touchpad later anyway

twilit talon
#

should be basically walk over the pins, configure them according to what aml wants, then call _EVT on irq if pin status is set

hexed acorn
#

in addition to i2c

twilit talon
#

yeah

vale hazel
hexed acorn
twilit talon
vale hazel
hexed acorn
#

god bless they have debug prints

twilit talon
#

lol

hexed acorn
#

hmm ghidra's output looks pretty fugly

carmine nacelle
hexed acorn
#

hmmm i think amdgpio2.sys also only looks at the first memory resource

carmine nacelle
#

I kinda have everything but this

carmine nacelle
#

Like I could have this driver by the end of today

hexed acorn
#

i see a loop in which it goes through all resources (?), calls MmMapIoSpace for one type, saves another for later (and complains that no proper irq resource was found if that's missing)

twilit talon
hexed acorn
#

unfortunately there's a virtual function call that i can't figure out what it is (i'm guessing it's a vtable provided by windows?)

twilit talon
#

I dont remember, look at the enum

hexed acorn
#

if it is, i can't see where it's being set

twilit talon
#

Hmm

carmine nacelle
#

oh it's gpio connector...

twilit talon
#

I can check later if you cant figure it out

hexed acorn
#

please

twilit talon
#

lol

twilit talon
#

it has 3 sub-types

#

or 2 rather

#
#define UACPI_GPIO_CONNECTION_INTERRUPT 0x00
#define UACPI_GPIO_CONNECTION_IO 0x01
hexed acorn
#

but i think it also just looks at the first memory resource

twilit talon
#

so it ignores the second one?

hexed acorn
#

i think so

twilit talon
#

lol

#

is your driver also possibly too old

hexed acorn
#

well i last booted into the install a few months ago

#

but the resources for the gpio controllers haven't changed since i got the laptop

#

(even after a bios update)

twilit talon
#

no i mean like

#

perhaps the new driver ships with like early access windows 11

#

and yours is the stable old version

hexed acorn
#

ah

#

hmm there is this condition in the loop ```
else if ( *(_BYTE )v15 == 3 && (((_DWORD *)(v15 + 12) - 768) & 0xFFFFFEFF) == 0 )

#

byte at v15 is the type (checks for 2 for the irq resource), v15 + 4 is the address, so what's at v15 + 12

#

hmm is it size

#

4 + 8 = 12

#

ohhhh

#

this is size == 0x400?

#

so it explicitly ignores the smaller memory resource

twilit talon
#

ah

#

is it shown under resource manager?

#

like in windows

hexed acorn
#

i could quickly reboot and check ig

twilit talon
#

although that might be handled by a different subsystem

#

aka the driver doesnt decide

#

all _CRS stuff is unconditionally stored there

hexed acorn
#

the fact that the driver has an explicit size check makes this even weirder

twilit talon
#

just sanity checking maybe

hexed acorn
#

windows shows both memory resources in device manager

#

and also, apparently next to all the other amd system devices, there's AMD Crash Defender

twilit talon
#

lol

#

wtf is that

carmine nacelle
#

ok I'm back

carmine nacelle
twilit talon
#

it works if u refresh enough

carmine nacelle
#

in uacpi_resource_gpio_connection

#

source??

twilit talon
carmine nacelle
#

// Pin list

twilit talon
#

pin_table

carmine nacelle
#

Yeah

#

I'm dumb

twilit talon
#

lol

carmine nacelle
#

mircosoft trying to make people buy new PCs?

#

Ok, time for hardcore printf'ing

twilit talon
#

it tells u which ones are good which ones are not

carmine nacelle
#

Idk if I'm being flat-brained, but it's not finding gpio

twilit talon
#

show code

carmine nacelle
#

Passing Windows 2015 doesn't show it

twilit talon
#

show code x2

#

if u disable windows 2015 its not shown yes

#

u have to pretend to be > windows 10

carmine nacelle
#

Brut it's passing extended irq resource

#

instead of normal irq

twilit talon
#

looks like it

carmine nacelle
#

I'm extra flat brained

#

I've been editing pci code instead of gpio for some reason

twilit talon
#

lmao

carmine nacelle
#

1, 12, 29

twilit talon
#

29 is the end tag

#

every resource list has one

carmine nacelle
#

Oh

#

I didn't know that

#

cool

#

Ok, I need to figure out how to get interrupts out of this thing

#

(as in which register am I supposed to be reading)

#

Linux is doing some weirdness

#

Wait what am I seeing