1 /* $NetBSD: save.h,v 1.2 2007/09/23 16:25:30 bouyer Exp $ */
5 * Structure definitions for HVM state that is held by Xen and must
6 * be saved along with the domain's memory and device-model state.
8 * Copyright (c) 2007 XenSource Ltd.
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to
12 * deal in the Software without restriction, including without limitation the
13 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 * sell copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
29 #ifndef __XEN_PUBLIC_HVM_SAVE_H__
30 #define __XEN_PUBLIC_HVM_SAVE_H__
33 * Structures in this header *must* have the same layout in 32bit
34 * and 64bit environments: this means that all fields must be explicitly
35 * sized types and aligned to their sizes, and the structs must be
36 * a multiple of eight bytes long.
38 * Only the state necessary for saving and restoring (i.e. fields
39 * that are analogous to actual hardware state) should go in this file.
40 * Internal mechanisms should be kept in Xen-private headers.
43 #if !defined(__GNUC__) || defined(__STRICT_ANSI__)
44 #error "Anonymous structs/unions are a GNU extension."
48 * Each entry is preceded by a descriptor giving its type and length
50 struct hvm_save_descriptor
{
51 uint16_t typecode
; /* Used to demux the various types below */
52 uint16_t instance
; /* Further demux within a type */
53 uint32_t length
; /* In bytes, *not* including this descriptor */
58 * Each entry has a datatype associated with it: for example, the CPU state
59 * is saved as a HVM_SAVE_TYPE(CPU), which has HVM_SAVE_LENGTH(CPU),
60 * and is identified by a descriptor with typecode HVM_SAVE_CODE(CPU).
61 * DECLARE_HVM_SAVE_TYPE binds these things together with some type-system
65 #define DECLARE_HVM_SAVE_TYPE(_x, _code, _type) \
66 struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; }
68 #define HVM_SAVE_TYPE(_x) typeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->t)
69 #define HVM_SAVE_LENGTH(_x) (sizeof (HVM_SAVE_TYPE(_x)))
70 #define HVM_SAVE_CODE(_x) (sizeof (((struct __HVM_SAVE_TYPE_##_x *)(0))->c))
74 * The series of save records is teminated by a zero-type, zero-length
78 struct hvm_save_end
{};
79 DECLARE_HVM_SAVE_TYPE(END
, 0, struct hvm_save_end
);
81 #if defined(__i386__) || defined(__x86_64__)
82 #include "../arch-x86/hvm/save.h"
83 #elif defined(__ia64__)
84 #include "../arch-ia64/hvm/save.h"
86 #error "unsupported architecture"
89 #endif /* __XEN_PUBLIC_HVM_SAVE_H__ */