How to use ACPICA

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
devc1
Member
Member
Posts: 436
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

How to use ACPICA

Post by devc1 »

I want to integrate acpica into my new OS, i will use it in a separate driver.

How can I compile it ? It gives me tons of errors (I don't bother using gcc)

OS : https://github.com/NXTdevosc1/New-Operating-System
devc1
Member
Member
Posts: 436
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: How to use ACPICA

Post by devc1 »

I opened the acpi solution in generate/msvc and it generated all the executables, but only AcpiExec and AcpiSubsystem have no executable so I think they are the ones which I should link to. So now I should implement a copy of the imported win32 functions. But after linking both to my main.c the linker gives an "symbol already defined error".

From the wiki I know now that I only need the AcpiSubsystem object files, and it works.

It only gives me most unresolved externals from the OS layer functions.
But now there is functions such as "unresolved external symbol __acrt_iob_func, __imp_GetCurrentProcess" which I don't know how to handle those. I think they try to use kernel32.dll

Edit:
The AcpiSubsystem was not successfully compiled, it generates the error "__asm keyword not usable on x64 architecture" but if I compile it in x86 it works and it generates AcpiSubsystem.lib.

Now it somehow compiles my x64 executable with the library generated in x64 configuration but win32 platform, this is weird.
devc1
Member
Member
Posts: 436
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: How to use ACPICA

Post by devc1 »

I finally succeeded in the compilation process (compiling my driver with the acpica lib), I did not tested because I still don't provide the full required os layer, but here is how I did it in windows in case you wonder (using msvc compiler):

- I opened up the solution in generate/msvc2017
I changed the build configuration from win32 to x64
I gone to AcpiSubsystem build config and created a new config (it shows 2 options either arm64 or x64 so I chose x64).
- In the AcpiSubsystem project configuration, I disabled security checks, enabled intrinsic functions and changed the WIN32 define to WIN64 in the compiler settings, then added 2 other defines.
- When it compiles it will generate a .lib file which I linked to my driver, now it gives unresolved externals to some stdlib functions like (strstr, nstrcmp...) which I copied from gcc library, then you remain with some other unresolved externs which you simply fix by including all the files from each directory in the project (you can find the file to include just by searching in the solution for the function which gives unresolved extern error).

- Then you copy all the oslayer from acpiosxf.h to an osl.c file or whatever you want to name, now you just fill the functions with a bunch of return 0; it should fix the other unresolved externals.
- I recommend running the vcvars64.bat before compiling.

Now the driver compiles finely and it's almost 700kb.
Post Reply