Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / hypervisor / src / include / md / md_impl.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* Hypervisor Software File: md_impl.h
5*
6* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
7*
8* - Do no alter or remove copyright notices
9*
10* - Redistribution and use of this software in source and binary forms, with
11* or without modification, are permitted provided that the following
12* conditions are met:
13*
14* - Redistribution of source code must retain the above copyright notice,
15* this list of conditions and the following disclaimer.
16*
17* - Redistribution in binary form must reproduce the above copyright notice,
18* this list of conditions and the following disclaimer in the
19* documentation and/or other materials provided with the distribution.
20*
21* Neither the name of Sun Microsystems, Inc. or the names of contributors
22* may be used to endorse or promote products derived from this software
23* without specific prior written permission.
24*
25* This software is provided "AS IS," without a warranty of any kind.
26* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
27* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
28* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
29* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
30* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
31* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
32* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
33* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
34* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
35* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
36* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37*
38* You acknowledge that this software is not designed, licensed or
39* intended for use in the design, construction, operation or maintenance of
40* any nuclear facility.
41*
42* ========== Copyright Header End ============================================
43*/
44/*
45 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
46 * Use is subject to license terms.
47 */
48
49#ifndef _MD_MD_IMPL_H
50#define _MD_MD_IMPL_H
51
52#pragma ident "@(#)md_impl.h 1.5 06/10/26 SMI"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58 /*
59 * Each logical domain is detailed via a (Virtual) Machine Description
60 * available to each guest Operating System courtesy of a
61 * Hypervisor service.
62 *
63 * A complete Machine Description (MD) is built from a very
64 * simple list of descriptor table (DT) elements.
65 *
66 */
67
68
69#define MD_TRANSPORT_VERSION 0x10000 /* the version this library generates */
70
71#define MD_ILLEGAL_NODEIDX (-1)
72
73#define DT_LIST_END 0x0
74#define DT_NULL ' '
75#define DT_NODE 'N'
76#define DT_NODE_END 'E'
77#define DT_PROP_ARC 'a'
78#define DT_PROP_VAL 'v'
79#define DT_PROP_STR 's'
80#define DT_PROP_DAT 'd'
81#define MDET_NULL DT_NULL
82#define MDET_NODE DT_NODE
83#define MDET_NODE_END DT_NODE_END
84#define MDET_PROP_ARC DT_PROP_ARC
85#define MDET_PROP_VAL DT_PROP_VAL
86#define MDET_PROP_STR DT_PROP_STR
87#define MDET_PROP_DAT DT_PROP_DAT
88#define MDET_LIST_END DT_LIST_END
89
90#ifndef _ASM
91
92typedef struct md_header md_hdr_t;
93typedef struct md_header md_header_t;
94 /* FIXME: dtnode_t to be renamed as md_element_t */
95typedef struct md_element dtnode_t;
96typedef struct md_element md_element_t;
97
98/*
99 * Each MD has the following header to
100 * provide information about each section of the MD.
101 *
102 * The header fields are actually written in network
103 * byte order.
104 */
105
106struct md_header {
107 uint32_t transport_version;
108 uint32_t node_blk_sz; /* size in bytes of the node block */
109 uint32_t name_blk_sz; /* size in bytes of the name block */
110 uint32_t data_blk_sz; /* size in bytes of the data block */
111};
112
113/*
114 * This is the handle that represents the description
115 *
116 * While we are building the nodes the data and name tags in the nodes
117 * are in fact indexes into the table arrays.
118 *
119 * When we 'end nodes' the dtheader is added, and the data rewritten
120 * into the binary form.
121 *
122 */
123struct dthandle {
124 char **nametable;
125 uint8_t **datatable;
126 int namesize;
127 int datasize;
128 int nodesize;
129 int nameidx;
130 int dataidx;
131 int namebytes;
132 int databytes;
133 int nodeentries;
134 int preload;
135 struct dtnode *root;
136 int lastnode;
137};
138typedef struct dthandle dthandle_t;
139
140/*
141 * With this model there are 3 sections
142 * the description, the name table and the data blocks.
143 * the name and data entries are offsets from the
144 * base of their blocks, this makes it possible to extend the segments.
145 *
146 * For 'node' tags, the data is the index to the next node, not a data
147 * offset.
148 *
149 * All values are stored in network byte order.
150 * The namelen field holds the storage length of a ASCIIZ name, NOT the strlen.
151 */
152
153struct md_element {
154 uint8_t tag;
155 uint8_t namelen;
156 uint32_t name;
157 union {
158 struct {
159 uint32_t len;
160 uint32_t offset;
161 } prop_data; /* for PROP_DATA and PROP_STR */
162 uint64_t prop_val; /* for PROP_VAL */
163 uint64_t prop_idx; /* for PROP_ARC and NODE */
164 } d;
165};
166
167
168
169typedef struct {
170 md_header_t hdr;
171 md_element_t elem[];
172} bin_md_t;
173
174#define MD_ELEMENT_SIZE 16
175
176#endif /* !_ASM */
177
178#ifdef __cplusplus
179}
180#endif
181
182#endif /* _MD_MD_IMPL_H */