# acpi_call



## gelraen (Oct 14, 2011)

Recently I've implemented acpi_call module https://gitorious.org/acpi_call-freebsd

Installation (requires kernel sources):

```
$ git clone git://gitorious.org/acpi_call-freebsd/acpi_call-freebsd.git acpi_call
 $ cd acpi_call
 $ make && make util
 # kldload ./acpi_call.ko
```

Basic usage:

```
# ./acpi_call -p '\_OS'
 Microsoft Windows NT
 # ./acpi_call -p '\_OSI' -s 'Windows'
 0
 # ./acpi_call -p '\_OSI' -s 'Windows 2000'
 4294967295
 # ./acpi_call -p '\_OSI' -s 'Windows 2000' -v
 Path: \_OSI
 Number of arguments: 1
 Argument 1 type: String
 Argument 1 value: Windows 2000
 Status: 0
 Result: 4294967295
```

Soon I will make port for it, but there is one issue: when the module is loaded from loader.conf it crashes the system early in boot process: http://i.imgur.com/fLPen.png (I've added some printf's in acpi.c)
Can someone help me with this issue?


----------



## SirDice (Oct 14, 2011)

This might help: Handbook: 12.16 Using and Debugging FreeBSD ACPI


----------



## gelraen (Oct 14, 2011)

SirDice said:
			
		

> This might help: Handbook: 12.16 Using and Debugging FreeBSD ACPI



AFAIK, it's related to general locking and modules init order (it crashes on acquiring mutex lock), not to ACPI directly.


----------



## SirDice (Oct 14, 2011)

In that case you probably need this: Developers Handbook: Chapter 10 Kernel Debugging


----------



## nirnr00t (Oct 14, 2011)

Module is useful for nvidia ion videocards switch: needs grab arguments for your hardware in github forks of linux acpi-call. 

For example, commands to disable ion chip on asus eee pc 1215N (based on http://github.com/peberlein/acpi_call.git)

```
./acpi_call -p "\\_SB.PCI0.P0P4.GFX0._DSM" -b "F8D886A4DA0B1B47A72B6042A6B5BEE0" -i 256 -i 26 -b "01000003" -v 
./acpi_call -p "\\_SB.PCI0.P0P4.GFX0._PS3" -v
```
Test it:

```
./acpi_call -p "\_SB.PCI0.P0P4.GFX0.P3MO" -v
./acpi_call -p "\_SB.PCI0.P0P4.GFX0.DGPS" -v
./acpi_call -p "\_SB.PCI0.P0P4.GFX0._PSC" -v
```
Last method should return 0x03 for disabled chip. Also, *acpiconf -i0* should show lowest discharging.

2 SirDice:
gelraen knows why module crashes, he needs a pile to fix this.


----------



## PseudoCylon (Oct 15, 2011)

Try DRIVER_MODULE(9) instead of DECLARE_MODULE(9).

acpi uses DRIVER_MODULE
http://fxr.watson.org/fxr/source/dev/acpica/acpi.c?im=bigexcerpts#L229
so that, sysinit_sub_id is SI_SUB_DRIVERS
http://fxr.watson.org/fxr/source/sys/bus.h?im=10#L615
You use SI_SUB_KLD.
SI_SUB_DRIVERS=0x3100000
SI_SUB_KLD=0x2000000
http://fxr.watson.org/fxr/source/sys/kernel.h#L70
Your module will be loaded before freebsd acip and before acpi_mutex being initialized. (yet acpi_mutex is defined http://fxr.watson.org/fxr/source/dev/acpica/acpi.c?im=bigexcerpts#L95, fault address isn't NULL. It is most likely leftover garbage bits.)

I'm not acpi expert, but USB drivers use DRIVER_MODULE, i.e.
http://fxr.watson.org/fxr/source/dev/usb/usb_hub.c#L172
http://fxr.watson.org/fxr/source/dev/usb/wlan/if_run.c?im=10#L4949
So, uhub will be loaded before usb dangle drivers.


----------



## gelraen (Oct 15, 2011)

Thanks. Sergey Kandaurov already replied in -hackers@ http://lists.freebsd.org/pipermail/freebsd-hackers/2011-October/036633.html


----------



## gelraen (Oct 15, 2011)

http://www.freebsd.org/cgi/query-pr.cgi?pr=161678


----------



## pbp_jackd (Aug 19, 2018)

Did someone tested with acpi_call recently. Let's say against 11.2 ?

I'm trying to make use of acpi_call to disable my Optimus Nvidia card in my laptop.
So I issued a call as root:
`acpi_call "\\134_SB.PCI0.RP01.PXSX._DSM"`

Above command leads to an instant reboot.
If I check the crash dump, I can find:


```
ACPI Warning: \134_SB.PCI0.RP01.PXSX._DSM: Insufficient arguments - Caller passed 0, ACPI requires 4 (20180629/nsarguments-414)
```

@*nirnr00t* How did you figure out the arguments you have to pass in ?

Just out of curiosity I issued as mentioned above by @*gelraen*:
`acpi_call -p '\_OS'`
This also leads to an instant reboot. Unfortunately I can"t find any related log line in /var/crash/core.txt.x this time.

So I'm wondering. Are these crashes only happening because of the way I use acpi_call, not passing the right arguments ?


----------



## JohnnySorocil (Feb 10, 2019)

pbp_jackd said:


> Did someone tested with acpi_call recently. Let's say against 11.2 ?



Yes, I am using acpi_call with 12.0 with custom BIOS & ACPI tables and it works without reboot.



> ```
> ACPI Warning: \134_SB.PCI0.RP01.PXSX._DSM: Insufficient arguments - Caller passed 0, ACPI requires 4 (20180629/nsarguments-414)
> ```
> 
> @*nirnr00t* How did you figure out the arguments you have to pass in ?



Maybe this will be helpful:

```
pkg install -y acpica-tools
mkdir acpi-dump
cd acpi-dump
/usr/local/bin/acpidump -b
iasl -d dsdt.dat
$EDITOR dsdt.asl
```


----------



## pbp_jackd (Feb 14, 2019)

Maybe worth to add that the current port of acpi_call works for me for 12-Release. There has been an update to the port which fixed the reboot issue I had.


----------

