Re: [PATCH v1 1/1] BaseTools: Build ASL files before C files


PierreGondois
 

Hello Liming,
Please find my answers marked [PIERRE] inline.

>> Can you give the whole solution for this usage model?
[Pierre]
We are planning to modify specific values in pre-compiled AML definition blocks at run-time, and then install these AML definition blocks as SSDT tables.
Instead of having multiple ASL describing the same kind of device (e.g.: a serial port), we would have one template describing this kind of device (e.g.: an ASL description of a serial port).
This template would be generic for the type of device it is describing, and compiled as one standalone AML definition block.
Platform specific values of this template would then be modified at run-time.

>> Does it mean C source file depends on ASL file?
[Pierre]
Yes. To do this, we need to embed these pre-compiled AML definition blocks. The .c file doing the fix-up needs to include this template. Thus this template needs to be compiled first.

The '.inf' file responsible of the fix-up looks like:
[SOURCES]
  SsdtSerialPortTemplate.asl
  SerialPortFixup.c

Compilation of 'SsdtSerialPortTemplate.asl' with the '-tc' option outputs a 'SsdtSerialPortTemplate.hex' file. '.hex' file's content looks like:
unsigned char ssdtserialtemplate_aml_code[] =
{
    0x53,0x53,0x44,0x54,0xC8,0x00,0x00,0x00,  /* 00000000    "SSDT...." */
    ...
}

The 'SerialPortFixup.c' includes the '.hex' file as shown below:
#include "SsdtSerialPortTemplate.hex"

>> This is related to the priority of source file type.
[Pierre]
Yes, the 'SsdtSerialPortTemplate.asl' needs to be compiled (so that the 'SsdtSerialPortTemplate.hex' is generated) prior to the compilation of 'SerialPortFixup.c'.

>> Now, there is no method to let user configure them. I suggest to introduce the generic way instead of the specific handle.
[Pierre]
I agree that we should have a generic way to configure the order in which the files should be compiled.
A new "SourceOrder" section could be introduced. This section would describe file extensions to compile first, and their order. Unreferenced file extensions would be compiled at the end, unordered.
e.g.:
  [SourceOrder]
    asl
    c

Here, '.asl' files would be compiled first, then '.c' files. '.asl' files would remain unordered in among all '.asl' files. '.c' files would remain unordered in among all '.c' files. Any remaining files in the "Sources" section would be compiled at the end, unordered.

Regards,
Pierre

Join devel@edk2.groups.io to automatically receive all group messages.