1cee2cfb7SBoris Ostrovsky /*
2cee2cfb7SBoris Ostrovsky  * Permission is hereby granted, free of charge, to any person obtaining a copy
3cee2cfb7SBoris Ostrovsky  * of this software and associated documentation files (the "Software"), to
4cee2cfb7SBoris Ostrovsky  * deal in the Software without restriction, including without limitation the
5cee2cfb7SBoris Ostrovsky  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
6cee2cfb7SBoris Ostrovsky  * sell copies of the Software, and to permit persons to whom the Software is
7cee2cfb7SBoris Ostrovsky  * furnished to do so, subject to the following conditions:
8cee2cfb7SBoris Ostrovsky  *
9cee2cfb7SBoris Ostrovsky  * The above copyright notice and this permission notice shall be included in
10cee2cfb7SBoris Ostrovsky  * all copies or substantial portions of the Software.
11cee2cfb7SBoris Ostrovsky  *
12cee2cfb7SBoris Ostrovsky  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13cee2cfb7SBoris Ostrovsky  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14cee2cfb7SBoris Ostrovsky  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15cee2cfb7SBoris Ostrovsky  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16cee2cfb7SBoris Ostrovsky  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17cee2cfb7SBoris Ostrovsky  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18cee2cfb7SBoris Ostrovsky  * DEALINGS IN THE SOFTWARE.
19cee2cfb7SBoris Ostrovsky  *
20cee2cfb7SBoris Ostrovsky  * Copyright (c) 2016, Citrix Systems, Inc.
21cee2cfb7SBoris Ostrovsky  */
22cee2cfb7SBoris Ostrovsky 
23cee2cfb7SBoris Ostrovsky #ifndef __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
24cee2cfb7SBoris Ostrovsky #define __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__
25cee2cfb7SBoris Ostrovsky 
26cee2cfb7SBoris Ostrovsky /*
27cee2cfb7SBoris Ostrovsky  * Start of day structure passed to PVH guests and to HVM guests in %ebx.
28cee2cfb7SBoris Ostrovsky  *
29cee2cfb7SBoris Ostrovsky  * NOTE: nothing will be loaded at physical address 0, so a 0 value in any
30cee2cfb7SBoris Ostrovsky  * of the address fields should be treated as not present.
31cee2cfb7SBoris Ostrovsky  *
32cee2cfb7SBoris Ostrovsky  *  0 +----------------+
33cee2cfb7SBoris Ostrovsky  *    | magic          | Contains the magic value XEN_HVM_START_MAGIC_VALUE
34cee2cfb7SBoris Ostrovsky  *    |                | ("xEn3" with the 0x80 bit of the "E" set).
35cee2cfb7SBoris Ostrovsky  *  4 +----------------+
36d907be2bSMaran Wilson  *    | version        | Version of this structure. Current version is 1. New
37cee2cfb7SBoris Ostrovsky  *    |                | versions are guaranteed to be backwards-compatible.
38cee2cfb7SBoris Ostrovsky  *  8 +----------------+
39cee2cfb7SBoris Ostrovsky  *    | flags          | SIF_xxx flags.
40cee2cfb7SBoris Ostrovsky  * 12 +----------------+
41cee2cfb7SBoris Ostrovsky  *    | nr_modules     | Number of modules passed to the kernel.
42cee2cfb7SBoris Ostrovsky  * 16 +----------------+
43cee2cfb7SBoris Ostrovsky  *    | modlist_paddr  | Physical address of an array of modules
44cee2cfb7SBoris Ostrovsky  *    |                | (layout of the structure below).
45cee2cfb7SBoris Ostrovsky  * 24 +----------------+
46cee2cfb7SBoris Ostrovsky  *    | cmdline_paddr  | Physical address of the command line,
47cee2cfb7SBoris Ostrovsky  *    |                | a zero-terminated ASCII string.
48cee2cfb7SBoris Ostrovsky  * 32 +----------------+
49cee2cfb7SBoris Ostrovsky  *    | rsdp_paddr     | Physical address of the RSDP ACPI data structure.
50cee2cfb7SBoris Ostrovsky  * 40 +----------------+
51d907be2bSMaran Wilson  *    | memmap_paddr   | Physical address of the (optional) memory map. Only
52d907be2bSMaran Wilson  *    |                | present in version 1 and newer of the structure.
53d907be2bSMaran Wilson  * 48 +----------------+
54d907be2bSMaran Wilson  *    | memmap_entries | Number of entries in the memory map table. Zero
55d907be2bSMaran Wilson  *    |                | if there is no memory map being provided. Only
56d907be2bSMaran Wilson  *    |                | present in version 1 and newer of the structure.
57d907be2bSMaran Wilson  * 52 +----------------+
58d907be2bSMaran Wilson  *    | reserved       | Version 1 and newer only.
59d907be2bSMaran Wilson  * 56 +----------------+
60cee2cfb7SBoris Ostrovsky  *
61cee2cfb7SBoris Ostrovsky  * The layout of each entry in the module structure is the following:
62cee2cfb7SBoris Ostrovsky  *
63cee2cfb7SBoris Ostrovsky  *  0 +----------------+
64cee2cfb7SBoris Ostrovsky  *    | paddr          | Physical address of the module.
65cee2cfb7SBoris Ostrovsky  *  8 +----------------+
66cee2cfb7SBoris Ostrovsky  *    | size           | Size of the module in bytes.
67cee2cfb7SBoris Ostrovsky  * 16 +----------------+
68cee2cfb7SBoris Ostrovsky  *    | cmdline_paddr  | Physical address of the command line,
69cee2cfb7SBoris Ostrovsky  *    |                | a zero-terminated ASCII string.
70cee2cfb7SBoris Ostrovsky  * 24 +----------------+
71cee2cfb7SBoris Ostrovsky  *    | reserved       |
72cee2cfb7SBoris Ostrovsky  * 32 +----------------+
73cee2cfb7SBoris Ostrovsky  *
74d907be2bSMaran Wilson  * The layout of each entry in the memory map table is as follows:
75d907be2bSMaran Wilson  *
76d907be2bSMaran Wilson  *  0 +----------------+
77d907be2bSMaran Wilson  *    | addr           | Base address
78d907be2bSMaran Wilson  *  8 +----------------+
79d907be2bSMaran Wilson  *    | size           | Size of mapping in bytes
80d907be2bSMaran Wilson  * 16 +----------------+
81d907be2bSMaran Wilson  *    | type           | Type of mapping as defined between the hypervisor
82d907be2bSMaran Wilson  *    |                | and guest. See XEN_HVM_MEMMAP_TYPE_* values below.
83d907be2bSMaran Wilson  * 20 +----------------|
84d907be2bSMaran Wilson  *    | reserved       |
85d907be2bSMaran Wilson  * 24 +----------------+
86d907be2bSMaran Wilson  *
87cee2cfb7SBoris Ostrovsky  * The address and sizes are always a 64bit little endian unsigned integer.
88cee2cfb7SBoris Ostrovsky  *
89cee2cfb7SBoris Ostrovsky  * NB: Xen on x86 will always try to place all the data below the 4GiB
90cee2cfb7SBoris Ostrovsky  * boundary.
91d907be2bSMaran Wilson  *
92d907be2bSMaran Wilson  * Version numbers of the hvm_start_info structure have evolved like this:
93d907be2bSMaran Wilson  *
94d907be2bSMaran Wilson  * Version 0:  Initial implementation.
95d907be2bSMaran Wilson  *
96d907be2bSMaran Wilson  * Version 1:  Added the memmap_paddr/memmap_entries fields (plus 4 bytes of
97d907be2bSMaran Wilson  *             padding) to the end of the hvm_start_info struct. These new
98d907be2bSMaran Wilson  *             fields can be used to pass a memory map to the guest. The
99d907be2bSMaran Wilson  *             memory map is optional and so guests that understand version 1
100d907be2bSMaran Wilson  *             of the structure must check that memmap_entries is non-zero
101d907be2bSMaran Wilson  *             before trying to read the memory map.
102cee2cfb7SBoris Ostrovsky  */
103cee2cfb7SBoris Ostrovsky #define XEN_HVM_START_MAGIC_VALUE 0x336ec578
104cee2cfb7SBoris Ostrovsky 
105cee2cfb7SBoris Ostrovsky /*
106d907be2bSMaran Wilson  * The values used in the type field of the memory map table entries are
107d907be2bSMaran Wilson  * defined below and match the Address Range Types as defined in the "System
108d907be2bSMaran Wilson  * Address Map Interfaces" section of the ACPI Specification. Please refer to
109d907be2bSMaran Wilson  * section 15 in version 6.2 of the ACPI spec: http://uefi.org/specifications
110d907be2bSMaran Wilson  */
111d907be2bSMaran Wilson #define XEN_HVM_MEMMAP_TYPE_RAM       1
112d907be2bSMaran Wilson #define XEN_HVM_MEMMAP_TYPE_RESERVED  2
113d907be2bSMaran Wilson #define XEN_HVM_MEMMAP_TYPE_ACPI      3
114d907be2bSMaran Wilson #define XEN_HVM_MEMMAP_TYPE_NVS       4
115d907be2bSMaran Wilson #define XEN_HVM_MEMMAP_TYPE_UNUSABLE  5
116d907be2bSMaran Wilson #define XEN_HVM_MEMMAP_TYPE_DISABLED  6
117d907be2bSMaran Wilson #define XEN_HVM_MEMMAP_TYPE_PMEM      7
118d907be2bSMaran Wilson 
119d907be2bSMaran Wilson /*
120cee2cfb7SBoris Ostrovsky  * C representation of the x86/HVM start info layout.
121cee2cfb7SBoris Ostrovsky  *
122cee2cfb7SBoris Ostrovsky  * The canonical definition of this layout is above, this is just a way to
123cee2cfb7SBoris Ostrovsky  * represent the layout described there using C types.
124cee2cfb7SBoris Ostrovsky  */
125cee2cfb7SBoris Ostrovsky struct hvm_start_info {
126cee2cfb7SBoris Ostrovsky     uint32_t magic;             /* Contains the magic value 0x336ec578       */
127cee2cfb7SBoris Ostrovsky                                 /* ("xEn3" with the 0x80 bit of the "E" set).*/
128cee2cfb7SBoris Ostrovsky     uint32_t version;           /* Version of this structure.                */
129cee2cfb7SBoris Ostrovsky     uint32_t flags;             /* SIF_xxx flags.                            */
130cee2cfb7SBoris Ostrovsky     uint32_t nr_modules;        /* Number of modules passed to the kernel.   */
131cee2cfb7SBoris Ostrovsky     uint64_t modlist_paddr;     /* Physical address of an array of           */
132cee2cfb7SBoris Ostrovsky                                 /* hvm_modlist_entry.                        */
133cee2cfb7SBoris Ostrovsky     uint64_t cmdline_paddr;     /* Physical address of the command line.     */
134cee2cfb7SBoris Ostrovsky     uint64_t rsdp_paddr;        /* Physical address of the RSDP ACPI data    */
135cee2cfb7SBoris Ostrovsky                                 /* structure.                                */
136d907be2bSMaran Wilson     /* All following fields only present in version 1 and newer */
137d907be2bSMaran Wilson     uint64_t memmap_paddr;      /* Physical address of an array of           */
138d907be2bSMaran Wilson                                 /* hvm_memmap_table_entry.                   */
139d907be2bSMaran Wilson     uint32_t memmap_entries;    /* Number of entries in the memmap table.    */
140d907be2bSMaran Wilson                                 /* Value will be zero if there is no memory  */
141d907be2bSMaran Wilson                                 /* map being provided.                       */
142d907be2bSMaran Wilson     uint32_t reserved;          /* Must be zero.                             */
143cee2cfb7SBoris Ostrovsky };
144cee2cfb7SBoris Ostrovsky 
145cee2cfb7SBoris Ostrovsky struct hvm_modlist_entry {
146cee2cfb7SBoris Ostrovsky     uint64_t paddr;             /* Physical address of the module.           */
147cee2cfb7SBoris Ostrovsky     uint64_t size;              /* Size of the module in bytes.              */
148cee2cfb7SBoris Ostrovsky     uint64_t cmdline_paddr;     /* Physical address of the command line.     */
149cee2cfb7SBoris Ostrovsky     uint64_t reserved;
150cee2cfb7SBoris Ostrovsky };
151cee2cfb7SBoris Ostrovsky 
152d907be2bSMaran Wilson struct hvm_memmap_table_entry {
153d907be2bSMaran Wilson     uint64_t addr;              /* Base address of the memory region         */
154d907be2bSMaran Wilson     uint64_t size;              /* Size of the memory region in bytes        */
155d907be2bSMaran Wilson     uint32_t type;              /* Mapping type                              */
156d907be2bSMaran Wilson     uint32_t reserved;          /* Must be zero for Version 1.               */
157d907be2bSMaran Wilson };
158d907be2bSMaran Wilson 
159cee2cfb7SBoris Ostrovsky #endif /* __XEN_PUBLIC_ARCH_X86_HVM_START_INFO_H__ */
160