[Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-05-30 Thread Shannon Zhao
From: Shannon Zhao 

Add ACPI tables relevant definitions for generating ACPI tables for ARM
guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables will
be used.

Signed-off-by: Shannon Zhao 
---
 tools/libxc/include/acpi_defs.h | 277 
 1 file changed, 277 insertions(+)
 create mode 100644 tools/libxc/include/acpi_defs.h

diff --git a/tools/libxc/include/acpi_defs.h b/tools/libxc/include/acpi_defs.h
new file mode 100644
index 000..9389a96
--- /dev/null
+++ b/tools/libxc/include/acpi_defs.h
@@ -0,0 +1,277 @@
+#ifndef _ACPI_DEFS_H_
+#define _ACPI_DEFS_H_
+
+#define ACPI_BUILD_APPNAME6 "XenARM"
+#define ACPI_BUILD_APPNAME4 "Xen "
+
+#pragma pack (1)
+
+/* Root System Description Pointer Structure. */
+struct acpi_rsdp_descriptor {/* Root System Descriptor Pointer */
+uint64_t signature;  /* ACPI signature, contains "RSD PTR " */
+uint8_t  checksum;   /* To make sum of struct == 0 */
+uint8_t  oem_id[6]; /* OEM identification */
+uint8_t  revision;   /* Must be 0 for 1.0, 2 for 2.0 */
+uint32_t rsdt_physical_address;  /* 32-bit physical address of RSDT */
+uint32_t length; /* XSDT Length in bytes including hdr */
+uint64_t xsdt_physical_address;  /* 64-bit physical address of XSDT */
+uint8_t  extended_checksum;  /* Checksum of entire table */
+uint8_t  reserved[3];   /* Reserved field must be 0 */
+};
+
+/* ACPI common table header. */
+struct acpi_table_header {
+uint32_t signature;  /* ACPI signature (4 ASCII characters) */ \
+uint32_t length; /* Length of table, in bytes, including 
header */ \
+uint8_t  revision;   /* ACPI Specification minor version # */ \
+uint8_t  checksum;   /* To make sum of entire table == 0 */ \
+uint8_t  oem_id[6]; /* OEM identification */ \
+uint8_t  oem_table_id[8];   /* OEM table identification */ \
+uint32_t oem_revision;   /* OEM revision number */ \
+uint8_t  asl_compiler_id[4];/* ASL compiler vendor ID */ \
+uint32_t asl_compiler_revision;  /* ASL compiler revision number */
+};
+
+/* Extended System Description Table (XSDT). */
+struct acpi_xsdt_descriptor {
+struct acpi_table_header header;
+uint64_t entry[0];
+};
+
+/* Generic Timer Description Table (GTDT). */
+#define ACPI_GTDT_INTERRUPT_MODE0
+#define ACPI_GTDT_INTERRUPT_POLARITY1
+#define ACPI_GTDT_ALWAYS_ON 2
+
+/* Triggering */
+#define ACPI_LEVEL_SENSITIVE((uint8_t) 0x00)
+#define ACPI_EDGE_SENSITIVE ((uint8_t) 0x01)
+
+/* Polarity */
+#define ACPI_ACTIVE_HIGH((uint8_t) 0x00)
+#define ACPI_ACTIVE_LOW ((uint8_t) 0x01)
+
+struct acpi_gtdt_descriptor {
+struct acpi_table_header header;
+uint64_t counter_block_addresss;
+uint32_t reserved;
+uint32_t secure_el1_interrupt;
+uint32_t secure_el1_flags;
+uint32_t non_secure_el1_interrupt;
+uint32_t non_secure_el1_flags;
+uint32_t virtual_timer_interrupt;
+uint32_t virtual_timer_flags;
+uint32_t non_secure_el2_interrupt;
+uint32_t non_secure_el2_flags;
+uint64_t counter_read_block_address;
+uint32_t platform_timer_count;
+uint32_t platform_timer_offset;
+};
+
+/* Multiple APIC Description Table header definition (MADT). */
+struct acpi_madt_descriptor
+{
+struct acpi_table_header header; /* ACPI common table header */
+uint32_t local_apic_address; /* Physical address of local APIC */
+uint32_t flags;
+};
+
+/* Values for Type in APIC sub-headers. */
+
+#define ACPI_APIC_PROCESSOR  0
+#define ACPI_APIC_IO 1
+#define ACPI_APIC_XRUPT_OVERRIDE 2
+#define ACPI_APIC_NMI3
+#define ACPI_APIC_LOCAL_NMI  4
+#define ACPI_APIC_ADDRESS_OVERRIDE   5
+#define ACPI_APIC_IO_SAPIC   6
+#define ACPI_APIC_LOCAL_SAPIC7
+#define ACPI_APIC_XRUPT_SOURCE   8
+#define ACPI_APIC_LOCAL_X2APIC   9
+#define ACPI_APIC_LOCAL_X2APIC_NMI  10
+#define ACPI_APIC_GENERIC_INTERRUPT 11
+#define ACPI_APIC_GENERIC_DISTRIBUTOR   12
+#define ACPI_APIC_GENERIC_MSI_FRAME 13
+#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14
+#define ACPI_APIC_RESERVED  15   /* 15 and greater are reserved */
+
+/*
+ * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE).
+ */
+#define ACPI_SUB_HEADER_DEF   /* Common ACPI sub-structure header */\
+uint8_t  type;   \
+uint8_t  length;
+
+/* Sub-structures for MADT */
+
+struct acpi_madt_generic_interrupt {
+ACPI_SUB_HEADER_DEF
+uint16_t reserved;
+uint32_t cpu_interface_number;
+uint32_t uid;
+uint32_t flags;
+uint32_t parking_version;
+uint32_t performance_interrupt;
+uint64_t parked_address;
+uint64_t base_address;
+uint64_t gicv_base_address;
+uint64_t gich_base_

Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-06 Thread Stefano Stabellini
On Tue, 31 May 2016, Shannon Zhao wrote:
> From: Shannon Zhao 
> 
> Add ACPI tables relevant definitions for generating ACPI tables for ARM
> guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables will
> be used.
> 
> Signed-off-by: Shannon Zhao 
> ---
>  tools/libxc/include/acpi_defs.h | 277 
> 
>  1 file changed, 277 insertions(+)
>  create mode 100644 tools/libxc/include/acpi_defs.h
> 
> diff --git a/tools/libxc/include/acpi_defs.h b/tools/libxc/include/acpi_defs.h
> new file mode 100644
> index 000..9389a96
> --- /dev/null
> +++ b/tools/libxc/include/acpi_defs.h
> @@ -0,0 +1,277 @@
> +#ifndef _ACPI_DEFS_H_
> +#define _ACPI_DEFS_H_
> +
> +#define ACPI_BUILD_APPNAME6 "XenARM"
> +#define ACPI_BUILD_APPNAME4 "Xen "

This header is actually ARM specific (also see the gic stuff below). It
is probably best to rename it to acpi_arm_defs.h.


> +#pragma pack (1)
> +
> +/* Root System Description Pointer Structure. */
> +struct acpi_rsdp_descriptor {/* Root System Descriptor Pointer */
> +uint64_t signature;  /* ACPI signature, contains "RSD PTR " 
> */
> +uint8_t  checksum;   /* To make sum of struct == 0 */
> +uint8_t  oem_id[6]; /* OEM identification */
> +uint8_t  revision;   /* Must be 0 for 1.0, 2 for 2.0 */
> +uint32_t rsdt_physical_address;  /* 32-bit physical address of RSDT */
> +uint32_t length; /* XSDT Length in bytes including hdr */
> +uint64_t xsdt_physical_address;  /* 64-bit physical address of XSDT */
> +uint8_t  extended_checksum;  /* Checksum of entire table */
> +uint8_t  reserved[3];   /* Reserved field must be 0 */
> +};
> +
> +/* ACPI common table header. */
> +struct acpi_table_header {
> +uint32_t signature;  /* ACPI signature (4 ASCII characters) */ \
> +uint32_t length; /* Length of table, in bytes, including 
> header */ \
> +uint8_t  revision;   /* ACPI Specification minor version # 
> */ \
> +uint8_t  checksum;   /* To make sum of entire table == 0 */ \
> +uint8_t  oem_id[6]; /* OEM identification */ \
> +uint8_t  oem_table_id[8];   /* OEM table identification */ \
> +uint32_t oem_revision;   /* OEM revision number */ \
> +uint8_t  asl_compiler_id[4];/* ASL compiler vendor ID */ \
> +uint32_t asl_compiler_revision;  /* ASL compiler revision number */
> +};
> +
> +/* Extended System Description Table (XSDT). */
> +struct acpi_xsdt_descriptor {
> +struct acpi_table_header header;
> +uint64_t entry[0];
> +};
> +
> +/* Generic Timer Description Table (GTDT). */
> +#define ACPI_GTDT_INTERRUPT_MODE0
> +#define ACPI_GTDT_INTERRUPT_POLARITY1
> +#define ACPI_GTDT_ALWAYS_ON 2
> +
> +/* Triggering */
> +#define ACPI_LEVEL_SENSITIVE((uint8_t) 0x00)
> +#define ACPI_EDGE_SENSITIVE ((uint8_t) 0x01)
> +
> +/* Polarity */
> +#define ACPI_ACTIVE_HIGH((uint8_t) 0x00)
> +#define ACPI_ACTIVE_LOW ((uint8_t) 0x01)
> +
> +struct acpi_gtdt_descriptor {
> +struct acpi_table_header header;
> +uint64_t counter_block_addresss;
> +uint32_t reserved;
> +uint32_t secure_el1_interrupt;
> +uint32_t secure_el1_flags;
> +uint32_t non_secure_el1_interrupt;
> +uint32_t non_secure_el1_flags;
> +uint32_t virtual_timer_interrupt;
> +uint32_t virtual_timer_flags;
> +uint32_t non_secure_el2_interrupt;
> +uint32_t non_secure_el2_flags;
> +uint64_t counter_read_block_address;
> +uint32_t platform_timer_count;
> +uint32_t platform_timer_offset;
> +};
> +
> +/* Multiple APIC Description Table header definition (MADT). */
> +struct acpi_madt_descriptor
> +{
> +struct acpi_table_header header; /* ACPI common table header */
> +uint32_t local_apic_address; /* Physical address of local APIC */
> +uint32_t flags;
> +};
> +
> +/* Values for Type in APIC sub-headers. */
> +
> +#define ACPI_APIC_PROCESSOR  0
> +#define ACPI_APIC_IO 1
> +#define ACPI_APIC_XRUPT_OVERRIDE 2
> +#define ACPI_APIC_NMI3
> +#define ACPI_APIC_LOCAL_NMI  4
> +#define ACPI_APIC_ADDRESS_OVERRIDE   5
> +#define ACPI_APIC_IO_SAPIC   6
> +#define ACPI_APIC_LOCAL_SAPIC7
> +#define ACPI_APIC_XRUPT_SOURCE   8
> +#define ACPI_APIC_LOCAL_X2APIC   9
> +#define ACPI_APIC_LOCAL_X2APIC_NMI  10
> +#define ACPI_APIC_GENERIC_INTERRUPT 11
> +#define ACPI_APIC_GENERIC_DISTRIBUTOR   12
> +#define ACPI_APIC_GENERIC_MSI_FRAME 13
> +#define ACPI_APIC_GENERIC_REDISTRIBUTOR 14
> +#define ACPI_APIC_RESERVED  15   /* 15 and greater are reserved 
> */
> +
> +/*
> + * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE).
> + */
> +#define ACPI_SUB_HEADER_DEF   /* Common ACPI sub-structure header */\
> +uint8_t  type;

Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-06 Thread Julien Grall

Hi Stefano,

On 06/06/2016 11:04, Stefano Stabellini wrote:

On Tue, 31 May 2016, Shannon Zhao wrote:

From: Shannon Zhao 

Add ACPI tables relevant definitions for generating ACPI tables for ARM
guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables will
be used.

Signed-off-by: Shannon Zhao 
---
 tools/libxc/include/acpi_defs.h | 277 
 1 file changed, 277 insertions(+)
 create mode 100644 tools/libxc/include/acpi_defs.h

diff --git a/tools/libxc/include/acpi_defs.h b/tools/libxc/include/acpi_defs.h
new file mode 100644
index 000..9389a96
--- /dev/null
+++ b/tools/libxc/include/acpi_defs.h
@@ -0,0 +1,277 @@
+#ifndef _ACPI_DEFS_H_
+#define _ACPI_DEFS_H_
+
+#define ACPI_BUILD_APPNAME6 "XenARM"
+#define ACPI_BUILD_APPNAME4 "Xen "


This header is actually ARM specific (also see the gic stuff below). It
is probably best to rename it to acpi_arm_defs.h.


Should not just we re-use the ACPI headers from xen/include/acpi/ ?

Regards,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-06 Thread Shannon Zhao


On 2016/6/6 18:11, Julien Grall wrote:
> Hi Stefano,
> 
> On 06/06/2016 11:04, Stefano Stabellini wrote:
>> On Tue, 31 May 2016, Shannon Zhao wrote:
>>> From: Shannon Zhao 
>>>
>>> Add ACPI tables relevant definitions for generating ACPI tables for ARM
>>> guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables will
>>> be used.
>>>
>>> Signed-off-by: Shannon Zhao 
>>> ---
>>>  tools/libxc/include/acpi_defs.h | 277
>>> 
>>>  1 file changed, 277 insertions(+)
>>>  create mode 100644 tools/libxc/include/acpi_defs.h
>>>
>>> diff --git a/tools/libxc/include/acpi_defs.h
>>> b/tools/libxc/include/acpi_defs.h
>>> new file mode 100644
>>> index 000..9389a96
>>> --- /dev/null
>>> +++ b/tools/libxc/include/acpi_defs.h
>>> @@ -0,0 +1,277 @@
>>> +#ifndef _ACPI_DEFS_H_
>>> +#define _ACPI_DEFS_H_
>>> +
>>> +#define ACPI_BUILD_APPNAME6 "XenARM"
>>> +#define ACPI_BUILD_APPNAME4 "Xen "
>>
>> This header is actually ARM specific (also see the gic stuff below). It
>> is probably best to rename it to acpi_arm_defs.h.
> 
> Should not just we re-use the ACPI headers from xen/include/acpi/ ?
So how to include those headers in tools/libxl/libxl_arm.c ?

Thanks,
-- 
Shannon


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-06 Thread Wei Liu
On Mon, Jun 06, 2016 at 06:27:25PM +0800, Shannon Zhao wrote:
> 
> 
> On 2016/6/6 18:11, Julien Grall wrote:
> > Hi Stefano,
> > 
> > On 06/06/2016 11:04, Stefano Stabellini wrote:
> >> On Tue, 31 May 2016, Shannon Zhao wrote:
> >>> From: Shannon Zhao 
> >>>
> >>> Add ACPI tables relevant definitions for generating ACPI tables for ARM
> >>> guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables will
> >>> be used.
> >>>
> >>> Signed-off-by: Shannon Zhao 
> >>> ---
> >>>  tools/libxc/include/acpi_defs.h | 277
> >>> 
> >>>  1 file changed, 277 insertions(+)
> >>>  create mode 100644 tools/libxc/include/acpi_defs.h
> >>>
> >>> diff --git a/tools/libxc/include/acpi_defs.h
> >>> b/tools/libxc/include/acpi_defs.h
> >>> new file mode 100644
> >>> index 000..9389a96
> >>> --- /dev/null
> >>> +++ b/tools/libxc/include/acpi_defs.h
> >>> @@ -0,0 +1,277 @@
> >>> +#ifndef _ACPI_DEFS_H_
> >>> +#define _ACPI_DEFS_H_
> >>> +
> >>> +#define ACPI_BUILD_APPNAME6 "XenARM"
> >>> +#define ACPI_BUILD_APPNAME4 "Xen "
> >>
> >> This header is actually ARM specific (also see the gic stuff below). It
> >> is probably best to rename it to acpi_arm_defs.h.
> > 
> > Should not just we re-use the ACPI headers from xen/include/acpi/ ?
> So how to include those headers in tools/libxl/libxl_arm.c ?
> 

Is it public headers? If so, it might already be available in
tools/include. If not, is it feasible to be made public?

If in the end the file you need can't end up as a public header, you
need to manipulate CFLAGS. There is one example in libxc's Makefile.
Search for libelf.

But please make sure the CFLAGS doesn't get modified when it is not
necessary.  I would expect the CFLAGS is explicitly altered for a list
of files.

Wei.

> Thanks,
> -- 
> Shannon
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-06 Thread Shannon Zhao
On 2016年06月06日 20:16, Wei Liu wrote:
> On Mon, Jun 06, 2016 at 06:27:25PM +0800, Shannon Zhao wrote:
>> > 
>> > 
>> > On 2016/6/6 18:11, Julien Grall wrote:
>>> > > Hi Stefano,
>>> > > 
>>> > > On 06/06/2016 11:04, Stefano Stabellini wrote:
 > >> On Tue, 31 May 2016, Shannon Zhao wrote:
> > >>> From: Shannon Zhao 
> > >>>
> > >>> Add ACPI tables relevant definitions for generating ACPI tables for 
> > >>> ARM
> > >>> guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables 
> > >>> will
> > >>> be used.
> > >>>
> > >>> Signed-off-by: Shannon Zhao 
> > >>> ---
> > >>>  tools/libxc/include/acpi_defs.h | 277
> > >>> 
> > >>>  1 file changed, 277 insertions(+)
> > >>>  create mode 100644 tools/libxc/include/acpi_defs.h
> > >>>
> > >>> diff --git a/tools/libxc/include/acpi_defs.h
> > >>> b/tools/libxc/include/acpi_defs.h
> > >>> new file mode 100644
> > >>> index 000..9389a96
> > >>> --- /dev/null
> > >>> +++ b/tools/libxc/include/acpi_defs.h
> > >>> @@ -0,0 +1,277 @@
> > >>> +#ifndef _ACPI_DEFS_H_
> > >>> +#define _ACPI_DEFS_H_
> > >>> +
> > >>> +#define ACPI_BUILD_APPNAME6 "XenARM"
> > >>> +#define ACPI_BUILD_APPNAME4 "Xen "
 > >>
 > >> This header is actually ARM specific (also see the gic stuff below). 
 > >> It
 > >> is probably best to rename it to acpi_arm_defs.h.
>>> > > 
>>> > > Should not just we re-use the ACPI headers from xen/include/acpi/ ?
>> > So how to include those headers in tools/libxl/libxl_arm.c ?
>> > 
> Is it public headers?
no, it's not public.

> If so, it might already be available in
> tools/include. If not, is it feasible to be made public?
> 
I'm not sure it's ok to make ACPI defs public since there are not xen
specific.

> If in the end the file you need can't end up as a public header, you
> need to manipulate CFLAGS. There is one example in libxc's Makefile.
> Search for libelf.
> 
> But please make sure the CFLAGS doesn't get modified when it is not
> necessary.  I would expect the CFLAGS is explicitly altered for a list
> of files.
Thanks, I'll have a look.

-- 
Shannon

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-21 Thread Shannon Zhao


On 2016/6/6 20:16, Wei Liu wrote:
> On Mon, Jun 06, 2016 at 06:27:25PM +0800, Shannon Zhao wrote:
>> > 
>> > 
>> > On 2016/6/6 18:11, Julien Grall wrote:
>>> > > Hi Stefano,
>>> > > 
>>> > > On 06/06/2016 11:04, Stefano Stabellini wrote:
 > >> On Tue, 31 May 2016, Shannon Zhao wrote:
> > >>> From: Shannon Zhao 
> > >>>
> > >>> Add ACPI tables relevant definitions for generating ACPI tables for 
> > >>> ARM
> > >>> guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables 
> > >>> will
> > >>> be used.
> > >>>
> > >>> Signed-off-by: Shannon Zhao 
> > >>> ---
> > >>>  tools/libxc/include/acpi_defs.h | 277
> > >>> 
> > >>>  1 file changed, 277 insertions(+)
> > >>>  create mode 100644 tools/libxc/include/acpi_defs.h
> > >>>
> > >>> diff --git a/tools/libxc/include/acpi_defs.h
> > >>> b/tools/libxc/include/acpi_defs.h
> > >>> new file mode 100644
> > >>> index 000..9389a96
> > >>> --- /dev/null
> > >>> +++ b/tools/libxc/include/acpi_defs.h
> > >>> @@ -0,0 +1,277 @@
> > >>> +#ifndef _ACPI_DEFS_H_
> > >>> +#define _ACPI_DEFS_H_
> > >>> +
> > >>> +#define ACPI_BUILD_APPNAME6 "XenARM"
> > >>> +#define ACPI_BUILD_APPNAME4 "Xen "
 > >>
 > >> This header is actually ARM specific (also see the gic stuff below). 
 > >> It
 > >> is probably best to rename it to acpi_arm_defs.h.
>>> > > 
>>> > > Should not just we re-use the ACPI headers from xen/include/acpi/ ?
>> > So how to include those headers in tools/libxl/libxl_arm.c ?
>> > 
> Is it public headers? If so, it might already be available in
> tools/include. If not, is it feasible to be made public?
> 
> If in the end the file you need can't end up as a public header, you
> need to manipulate CFLAGS. There is one example in libxc's Makefile.
> Search for libelf.
> 
> But please make sure the CFLAGS doesn't get modified when it is not
> necessary.  I would expect the CFLAGS is explicitly altered for a list
> of files.
I'm trying to do this. Make the libxl acpi codes compile like below in
Makefile:

+libxl_arm_acpi.o: libxl_arm_acpi.c
+   $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c

Add #include  which includes the tables definitions in
libxl_arm_acpi.c. But there are a lot of compiling errors like below:
error: unknown type name 'u8'
error: unknown type name 'u32'
Looks like these types are defined in xen/include/asm-arm/types.h. I add
#include  in libxl_arm_acpi.c but it still compiles failed.
In file included from ../../xen/include/asm-arm/types.h:6:0,
 from libxl_arm_acpi.c:30:
../../xen/include/xen/config.h:10:32: fatal error: generated/autoconf.h:
No such file or directory
 #include 

Looks like if we try to use the acpi headers under xen/include/acpi like
this way, tools compilation will depends on hypervisor compilation. I
think this is not what we want, right?

Any suggestion?

Thanks,
-- 
Shannon


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-22 Thread Julien Grall

Hi Shannon,

On 22/06/2016 04:24, Shannon Zhao wrote:

On 2016/6/6 20:16, Wei Liu wrote:

On Mon, Jun 06, 2016 at 06:27:25PM +0800, Shannon Zhao wrote:



On 2016/6/6 18:11, Julien Grall wrote:

Hi Stefano,

On 06/06/2016 11:04, Stefano Stabellini wrote:

On Tue, 31 May 2016, Shannon Zhao wrote:

From: Shannon Zhao 

Add ACPI tables relevant definitions for generating ACPI tables for ARM
guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT tables will
be used.

Signed-off-by: Shannon Zhao 
---
 tools/libxc/include/acpi_defs.h | 277

 1 file changed, 277 insertions(+)
 create mode 100644 tools/libxc/include/acpi_defs.h

diff --git a/tools/libxc/include/acpi_defs.h
b/tools/libxc/include/acpi_defs.h
new file mode 100644
index 000..9389a96
--- /dev/null
+++ b/tools/libxc/include/acpi_defs.h
@@ -0,0 +1,277 @@
+#ifndef _ACPI_DEFS_H_
+#define _ACPI_DEFS_H_
+
+#define ACPI_BUILD_APPNAME6 "XenARM"
+#define ACPI_BUILD_APPNAME4 "Xen "


This header is actually ARM specific (also see the gic stuff below). It
is probably best to rename it to acpi_arm_defs.h.


Should not just we re-use the ACPI headers from xen/include/acpi/ ?

So how to include those headers in tools/libxl/libxl_arm.c ?


Is it public headers? If so, it might already be available in
tools/include. If not, is it feasible to be made public?

If in the end the file you need can't end up as a public header, you
need to manipulate CFLAGS. There is one example in libxc's Makefile.
Search for libelf.

But please make sure the CFLAGS doesn't get modified when it is not
necessary.  I would expect the CFLAGS is explicitly altered for a list
of files.

I'm trying to do this. Make the libxl acpi codes compile like below in
Makefile:

+libxl_arm_acpi.o: libxl_arm_acpi.c
+   $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c

Add #include  which includes the tables definitions in
libxl_arm_acpi.c. But there are a lot of compiling errors like below:
error: unknown type name 'u8'
error: unknown type name 'u32'
Looks like these types are defined in xen/include/asm-arm/types.h. I add
#include  in libxl_arm_acpi.c but it still compiles failed.
In file included from ../../xen/include/asm-arm/types.h:6:0,
 from libxl_arm_acpi.c:30:
../../xen/include/xen/config.h:10:32: fatal error: generated/autoconf.h:
No such file or directory
 #include 

Looks like if we try to use the acpi headers under xen/include/acpi like
this way, tools compilation will depends on hypervisor compilation. I
think this is not what we want, right?


You could define our own u8, u32 types in libxc. They are just aliased 
to uint8_t, uint32_t.


Regards,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-22 Thread Shannon Zhao


On 2016/6/22 16:35, Julien Grall wrote:
> Hi Shannon,
> 
> On 22/06/2016 04:24, Shannon Zhao wrote:
>> On 2016/6/6 20:16, Wei Liu wrote:
>>> On Mon, Jun 06, 2016 at 06:27:25PM +0800, Shannon Zhao wrote:
>
>
> On 2016/6/6 18:11, Julien Grall wrote:
>>> Hi Stefano,
>>>
>>> On 06/06/2016 11:04, Stefano Stabellini wrote:
> On Tue, 31 May 2016, Shannon Zhao wrote:
>>> From: Shannon Zhao 
>>>
>>> Add ACPI tables relevant definitions for generating ACPI
>>> tables for ARM
>>> guest later. Currently RSDP, XSDT, GTDT, MADT, FADT and DSDT
>>> tables will
>>> be used.
>>>
>>> Signed-off-by: Shannon Zhao 
>>> ---
>>>  tools/libxc/include/acpi_defs.h | 277
>>> 
>>>  1 file changed, 277 insertions(+)
>>>  create mode 100644 tools/libxc/include/acpi_defs.h
>>>
>>> diff --git a/tools/libxc/include/acpi_defs.h
>>> b/tools/libxc/include/acpi_defs.h
>>> new file mode 100644
>>> index 000..9389a96
>>> --- /dev/null
>>> +++ b/tools/libxc/include/acpi_defs.h
>>> @@ -0,0 +1,277 @@
>>> +#ifndef _ACPI_DEFS_H_
>>> +#define _ACPI_DEFS_H_
>>> +
>>> +#define ACPI_BUILD_APPNAME6 "XenARM"
>>> +#define ACPI_BUILD_APPNAME4 "Xen "
>
> This header is actually ARM specific (also see the gic stuff
> below). It
> is probably best to rename it to acpi_arm_defs.h.
>>>
>>> Should not just we re-use the ACPI headers from xen/include/acpi/ ?
> So how to include those headers in tools/libxl/libxl_arm.c ?
>
>>> Is it public headers? If so, it might already be available in
>>> tools/include. If not, is it feasible to be made public?
>>>
>>> If in the end the file you need can't end up as a public header, you
>>> need to manipulate CFLAGS. There is one example in libxc's Makefile.
>>> Search for libelf.
>>>
>>> But please make sure the CFLAGS doesn't get modified when it is not
>>> necessary.  I would expect the CFLAGS is explicitly altered for a list
>>> of files.
>> I'm trying to do this. Make the libxl acpi codes compile like below in
>> Makefile:
>>
>> +libxl_arm_acpi.o: libxl_arm_acpi.c
>> +   $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
>>
>> Add #include  which includes the tables definitions in
>> libxl_arm_acpi.c. But there are a lot of compiling errors like below:
>> error: unknown type name 'u8'
>> error: unknown type name 'u32'
>> Looks like these types are defined in xen/include/asm-arm/types.h. I add
>> #include  in libxl_arm_acpi.c but it still compiles
>> failed.
>> In file included from ../../xen/include/asm-arm/types.h:6:0,
>>  from libxl_arm_acpi.c:30:
>> ../../xen/include/xen/config.h:10:32: fatal error: generated/autoconf.h:
>> No such file or directory
>>  #include 
>>
>> Looks like if we try to use the acpi headers under xen/include/acpi like
>> this way, tools compilation will depends on hypervisor compilation. I
>> think this is not what we want, right?
> 
> You could define our own u8, u32 types in libxc. They are just aliased
> to uint8_t, uint32_t.
Ah, right. But looking at the types.h it defines u64 differently for
ARM_32 and ARM_64. Do we need to do that? If so, how could we get the
CONFIG_ARM_32 and CONFIG_ARM_64 since they are dynamically generated?

Or since we only generate ACPI tables for 64bit domain, could we just
assume it's ARM64 for ACPI?

Thanks?
-- 
Shannon


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions

2016-06-22 Thread Julien Grall

Hi Shannon,

On 22/06/2016 09:50, Shannon Zhao wrote:

You could define our own u8, u32 types in libxc. They are just aliased
to uint8_t, uint32_t.

Ah, right. But looking at the types.h it defines u64 differently for
ARM_32 and ARM_64. Do we need to do that? If so, how could we get the
CONFIG_ARM_32 and CONFIG_ARM_64 since they are dynamically generated?


You can use the type uint64_t which is defined by stdint.h.


Or since we only generate ACPI tables for 64bit domain, could we just
assume it's ARM64 for ACPI?


The toolstack may run in a 32-bit domain even on top of a 64-bit Xen ARM.

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions (and more)

2016-06-22 Thread Wei Liu
On Wed, Jun 22, 2016 at 11:24:07AM +0800, Shannon Zhao wrote:
[...]
> > But please make sure the CFLAGS doesn't get modified when it is not
> > necessary.  I would expect the CFLAGS is explicitly altered for a list
> > of files.
> I'm trying to do this. Make the libxl acpi codes compile like below in
> Makefile:
> 
> +libxl_arm_acpi.o: libxl_arm_acpi.c
> +   $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
> 
> Add #include  which includes the tables definitions in
> libxl_arm_acpi.c. But there are a lot of compiling errors like below:
> error: unknown type name 'u8'
> error: unknown type name 'u32'
> Looks like these types are defined in xen/include/asm-arm/types.h. I add
> #include  in libxl_arm_acpi.c but it still compiles failed.
> In file included from ../../xen/include/asm-arm/types.h:6:0,
>  from libxl_arm_acpi.c:30:
> ../../xen/include/xen/config.h:10:32: fatal error: generated/autoconf.h:
> No such file or directory
>  #include 
> 
> Looks like if we try to use the acpi headers under xen/include/acpi like
> this way, tools compilation will depends on hypervisor compilation. I
> think this is not what we want, right?
> 

Hmm... I thought all the ACPI headers are self-contained, but they are
actually not from your description.

But, we do have one precedent -- the libelf header. If you look at
xen/include/xen/libelf.h, the header itself contains define guards to
include the right header. Can you do the same for ACPI header?

Julien wrote:
> You could define our own u8, u32 types in libxc. They are just aliased
> to uint8_t, uint32_t.

I would avoid doing that. I would rather you confine what is necessary
in acpi headers.

Feel free to ask more questions if you're in doubt.

Wei.

> Any suggestion?
> 
> Thanks,
> -- 
> Shannon
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND 04/14] tools: add ACPI tables relevant definitions (and more)

2016-06-22 Thread Shannon Zhao


On 2016/6/22 17:38, Wei Liu wrote:
> On Wed, Jun 22, 2016 at 11:24:07AM +0800, Shannon Zhao wrote:
> [...]
>>> > > But please make sure the CFLAGS doesn't get modified when it is not
>>> > > necessary.  I would expect the CFLAGS is explicitly altered for a list
>>> > > of files.
>> > I'm trying to do this. Make the libxl acpi codes compile like below in
>> > Makefile:
>> > 
>> > +libxl_arm_acpi.o: libxl_arm_acpi.c
>> > +   $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c
>> > 
>> > Add #include  which includes the tables definitions in
>> > libxl_arm_acpi.c. But there are a lot of compiling errors like below:
>> > error: unknown type name 'u8'
>> > error: unknown type name 'u32'
>> > Looks like these types are defined in xen/include/asm-arm/types.h. I add
>> > #include  in libxl_arm_acpi.c but it still compiles 
>> > failed.
>> > In file included from ../../xen/include/asm-arm/types.h:6:0,
>> >  from libxl_arm_acpi.c:30:
>> > ../../xen/include/xen/config.h:10:32: fatal error: generated/autoconf.h:
>> > No such file or directory
>> >  #include 
>> > 
>> > Looks like if we try to use the acpi headers under xen/include/acpi like
>> > this way, tools compilation will depends on hypervisor compilation. I
>> > think this is not what we want, right?
>> > 
> Hmm... I thought all the ACPI headers are self-contained, but they are
> actually not from your description.
> 
> But, we do have one precedent -- the libelf header. If you look at
> xen/include/xen/libelf.h, the header itself contains define guards to
> include the right header. Can you do the same for ACPI header?
> 
> Julien wrote:
>> > You could define our own u8, u32 types in libxc. They are just aliased
>> > to uint8_t, uint32_t.
> I would avoid doing that. I would rather you confine what is necessary
> in acpi headers.

Yeah, we needs the contents of the actbl.h but it relies on the
definition of u8, u32, etc.

Thanks,
-- 
Shannon


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel