18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy
38c2ecf20Sopenharmony_ci * of this software and associated documentation files (the "Software"), to
48c2ecf20Sopenharmony_ci * deal in the Software without restriction, including without limitation the
58c2ecf20Sopenharmony_ci * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
68c2ecf20Sopenharmony_ci * sell copies of the Software, and to permit persons to whom the Software is
78c2ecf20Sopenharmony_ci * furnished to do so, subject to the following conditions:
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
108c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
138c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
148c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
158c2ecf20Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
168c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
178c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
188c2ecf20Sopenharmony_ci * DEALINGS IN THE SOFTWARE.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * Copyright (c) 2016, Citrix Systems, Inc.
218c2ecf20Sopenharmony_ci */
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
248c2ecf20Sopenharmony_ci#define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/*
278c2ecf20Sopenharmony_ci * Start of day structure passed to PVH guests and to HVM guests in %ebx.
288c2ecf20Sopenharmony_ci *
298c2ecf20Sopenharmony_ci * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
308c2ecf20Sopenharmony_ci * of the address fields should be treated as not present.
318c2ecf20Sopenharmony_ci *
328c2ecf20Sopenharmony_ci *  0 +----------------+
338c2ecf20Sopenharmony_ci *    | magic          | Contains the magic value XEN_HVM_START_MAGIC_VALUE
348c2ecf20Sopenharmony_ci *    |                | ("xEn3" with the 0x80 bit of the "E" set).
358c2ecf20Sopenharmony_ci *  4 +----------------+
368c2ecf20Sopenharmony_ci *    | version        | Version of this structure. Current version is 1. New
378c2ecf20Sopenharmony_ci *    |                | versions are guaranteed to be backwards-compatible.
388c2ecf20Sopenharmony_ci *  8 +----------------+
398c2ecf20Sopenharmony_ci *    | flags          | SIF_xxx flags.
408c2ecf20Sopenharmony_ci * 12 +----------------+
418c2ecf20Sopenharmony_ci *    | nr_modules     | Number of modules passed to the kernel.
428c2ecf20Sopenharmony_ci * 16 +----------------+
438c2ecf20Sopenharmony_ci *    | modlist_paddr  | Physical address of an array of modules
448c2ecf20Sopenharmony_ci *    |                | (layout of the structure below).
458c2ecf20Sopenharmony_ci * 24 +----------------+
468c2ecf20Sopenharmony_ci *    | cmdline_paddr  | Physical address of the command line,
478c2ecf20Sopenharmony_ci *    |                | a zero-terminated ASCII string.
488c2ecf20Sopenharmony_ci * 32 +----------------+
498c2ecf20Sopenharmony_ci *    | rsdp_paddr     | Physical address of the RSDP ACPI data structure.
508c2ecf20Sopenharmony_ci * 40 +----------------+
518c2ecf20Sopenharmony_ci *    | memmap_paddr   | Physical address of the (optional) memory map. Only
528c2ecf20Sopenharmony_ci *    |                | present in version 1 and newer of the structure.
538c2ecf20Sopenharmony_ci * 48 +----------------+
548c2ecf20Sopenharmony_ci *    | memmap_entries | Number of entries in the memory map table. Zero
558c2ecf20Sopenharmony_ci *    |                | if there is no memory map being provided. Only
568c2ecf20Sopenharmony_ci *    |                | present in version 1 and newer of the structure.
578c2ecf20Sopenharmony_ci * 52 +----------------+
588c2ecf20Sopenharmony_ci *    | reserved       | Version 1 and newer only.
598c2ecf20Sopenharmony_ci * 56 +----------------+
608c2ecf20Sopenharmony_ci *
618c2ecf20Sopenharmony_ci * The layout of each entry in the module structure is the following:
628c2ecf20Sopenharmony_ci *
638c2ecf20Sopenharmony_ci *  0 +----------------+
648c2ecf20Sopenharmony_ci *    | paddr          | Physical address of the module.
658c2ecf20Sopenharmony_ci *  8 +----------------+
668c2ecf20Sopenharmony_ci *    | size           | Size of the module in bytes.
678c2ecf20Sopenharmony_ci * 16 +----------------+
688c2ecf20Sopenharmony_ci *    | cmdline_paddr  | Physical address of the command line,
698c2ecf20Sopenharmony_ci *    |                | a zero-terminated ASCII string.
708c2ecf20Sopenharmony_ci * 24 +----------------+
718c2ecf20Sopenharmony_ci *    | reserved       |
728c2ecf20Sopenharmony_ci * 32 +----------------+
738c2ecf20Sopenharmony_ci *
748c2ecf20Sopenharmony_ci * The layout of each entry in the memory map table is as follows:
758c2ecf20Sopenharmony_ci *
768c2ecf20Sopenharmony_ci *  0 +----------------+
778c2ecf20Sopenharmony_ci *    | addr           | Base address
788c2ecf20Sopenharmony_ci *  8 +----------------+
798c2ecf20Sopenharmony_ci *    | size           | Size of mapping in bytes
808c2ecf20Sopenharmony_ci * 16 +----------------+
818c2ecf20Sopenharmony_ci *    | type           | Type of mapping as defined between the hypervisor
828c2ecf20Sopenharmony_ci *    |                | and guest. See XEN_HVM_MEMMAP_TYPE_* values below.
838c2ecf20Sopenharmony_ci * 20 +----------------|
848c2ecf20Sopenharmony_ci *    | reserved       |
858c2ecf20Sopenharmony_ci * 24 +----------------+
868c2ecf20Sopenharmony_ci *
878c2ecf20Sopenharmony_ci * The address and sizes are always a 64bit little endian unsigned integer.
888c2ecf20Sopenharmony_ci *
898c2ecf20Sopenharmony_ci * NB: Xen on x86 will always try to place all the data below the 4GiB
908c2ecf20Sopenharmony_ci * boundary.
918c2ecf20Sopenharmony_ci *
928c2ecf20Sopenharmony_ci * Version numbers of the hvm_start_info structure have evolved like this:
938c2ecf20Sopenharmony_ci *
948c2ecf20Sopenharmony_ci * Version 0:  Initial implementation.
958c2ecf20Sopenharmony_ci *
968c2ecf20Sopenharmony_ci * Version 1:  Added the memmap_paddr/memmap_entries fields (plus 4 bytes of
978c2ecf20Sopenharmony_ci *             padding) to the end of the hvm_start_info struct. These new
988c2ecf20Sopenharmony_ci *             fields can be used to pass a memory map to the guest. The
998c2ecf20Sopenharmony_ci *             memory map is optional and so guests that understand version 1
1008c2ecf20Sopenharmony_ci *             of the structure must check that memmap_entries is non-zero
1018c2ecf20Sopenharmony_ci *             before trying to read the memory map.
1028c2ecf20Sopenharmony_ci */
1038c2ecf20Sopenharmony_ci#define XEN_HVM_START_MAGIC_VALUE 0x336ec578
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/*
1068c2ecf20Sopenharmony_ci * The values used in the type field of the memory map table entries are
1078c2ecf20Sopenharmony_ci * defined below and match the Address Range Types as defined in the "System
1088c2ecf20Sopenharmony_ci * Address Map Interfaces" section of the ACPI Specification. Please refer to
1098c2ecf20Sopenharmony_ci * section 15 in version 6.2 of the ACPI spec: http://uefi.org/specifications
1108c2ecf20Sopenharmony_ci */
1118c2ecf20Sopenharmony_ci#define XEN_HVM_MEMMAP_TYPE_RAM       1
1128c2ecf20Sopenharmony_ci#define XEN_HVM_MEMMAP_TYPE_RESERVED  2
1138c2ecf20Sopenharmony_ci#define XEN_HVM_MEMMAP_TYPE_ACPI      3
1148c2ecf20Sopenharmony_ci#define XEN_HVM_MEMMAP_TYPE_NVS       4
1158c2ecf20Sopenharmony_ci#define XEN_HVM_MEMMAP_TYPE_UNUSABLE  5
1168c2ecf20Sopenharmony_ci#define XEN_HVM_MEMMAP_TYPE_DISABLED  6
1178c2ecf20Sopenharmony_ci#define XEN_HVM_MEMMAP_TYPE_PMEM      7
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci/*
1208c2ecf20Sopenharmony_ci * C representation of the x86/HVM start info layout.
1218c2ecf20Sopenharmony_ci *
1228c2ecf20Sopenharmony_ci * The canonical definition of this layout is above, this is just a way to
1238c2ecf20Sopenharmony_ci * represent the layout described there using C types.
1248c2ecf20Sopenharmony_ci */
1258c2ecf20Sopenharmony_cistruct hvm_start_info {
1268c2ecf20Sopenharmony_ci    uint32_t magic;             /* Contains the magic value 0x336ec578       */
1278c2ecf20Sopenharmony_ci                                /* ("xEn3" with the 0x80 bit of the "E" set).*/
1288c2ecf20Sopenharmony_ci    uint32_t version;           /* Version of this structure.                */
1298c2ecf20Sopenharmony_ci    uint32_t flags;             /* SIF_xxx flags.                            */
1308c2ecf20Sopenharmony_ci    uint32_t nr_modules;        /* Number of modules passed to the kernel.   */
1318c2ecf20Sopenharmony_ci    uint64_t modlist_paddr;     /* Physical address of an array of           */
1328c2ecf20Sopenharmony_ci                                /* hvm_modlist_entry.                        */
1338c2ecf20Sopenharmony_ci    uint64_t cmdline_paddr;     /* Physical address of the command line.     */
1348c2ecf20Sopenharmony_ci    uint64_t rsdp_paddr;        /* Physical address of the RSDP ACPI data    */
1358c2ecf20Sopenharmony_ci                                /* structure.                                */
1368c2ecf20Sopenharmony_ci    /* All following fields only present in version 1 and newer */
1378c2ecf20Sopenharmony_ci    uint64_t memmap_paddr;      /* Physical address of an array of           */
1388c2ecf20Sopenharmony_ci                                /* hvm_memmap_table_entry.                   */
1398c2ecf20Sopenharmony_ci    uint32_t memmap_entries;    /* Number of entries in the memmap table.    */
1408c2ecf20Sopenharmony_ci                                /* Value will be zero if there is no memory  */
1418c2ecf20Sopenharmony_ci                                /* map being provided.                       */
1428c2ecf20Sopenharmony_ci    uint32_t reserved;          /* Must be zero.                             */
1438c2ecf20Sopenharmony_ci};
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_cistruct hvm_modlist_entry {
1468c2ecf20Sopenharmony_ci    uint64_t paddr;             /* Physical address of the module.           */
1478c2ecf20Sopenharmony_ci    uint64_t size;              /* Size of the module in bytes.              */
1488c2ecf20Sopenharmony_ci    uint64_t cmdline_paddr;     /* Physical address of the command line.     */
1498c2ecf20Sopenharmony_ci    uint64_t reserved;
1508c2ecf20Sopenharmony_ci};
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistruct hvm_memmap_table_entry {
1538c2ecf20Sopenharmony_ci    uint64_t addr;              /* Base address of the memory region         */
1548c2ecf20Sopenharmony_ci    uint64_t size;              /* Size of the memory region in bytes        */
1558c2ecf20Sopenharmony_ci    uint32_t type;              /* Mapping type                              */
1568c2ecf20Sopenharmony_ci    uint32_t reserved;          /* Must be zero for Version 1.               */
1578c2ecf20Sopenharmony_ci};
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */
160