| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * Hypervisor Software File: strand.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 2007 Sun Microsystems, Inc. All rights reserved. |
| 46 | * Use is subject to license terms. |
| 47 | */ |
| 48 | |
| 49 | #ifndef _STRAND_H |
| 50 | #define _STRAND_H |
| 51 | |
| 52 | #pragma ident "@(#)strand.h 1.1 07/05/03 SMI" |
| 53 | |
| 54 | #ifdef __cplusplus |
| 55 | extern "C" { |
| 56 | #endif |
| 57 | |
| 58 | #define STRAND_STACK_SIZE (64*1024) |
| 59 | |
| 60 | #define NUM_SCHED_SLOTS 2 |
| 61 | |
| 62 | /* These should become HV jump addresses */ |
| 63 | /* Leave them as values for now to ease debugging */ |
| 64 | #define SLOT_ACTION_NOP 0x0 |
| 65 | #define SLOT_ACTION_RUN_VCPU 0x1 |
| 66 | |
| 67 | /* These mail box commands to go away with a proper Q */ |
| 68 | #define HXMB_IDLE 0x0 |
| 69 | #define HXMB_BUSY (-1LL) /* to go away with proper Q */ |
| 70 | #define HXMB_NEWMONDO 0x1 |
| 71 | |
| 72 | /* These commands are put into the first word of the mondo sent */ |
| 73 | |
| 74 | /* SCHED, DESCHED and STOP all use the hvm_sched struct as payload */ |
| 75 | #define HXCMD_SCHED_VCPU 0x1 /* start a vcpu from stop/suspend */ |
| 76 | #define HXCMD_DESCHED_VCPU 0x2 /* suspend a vcpu */ |
| 77 | #define HXCMD_STOP_VCPU 0x3 /* stop a vcpu */ |
| 78 | /* SCRUB uses the hvm_scrub payload */ |
| 79 | #define HXCMD_SCRUBMEM 0x4 |
| 80 | /* GUEST commands all use the hvm_guestcmd struct as payload */ |
| 81 | #define HXCMD_GUEST_SHUTDOWN 0x5 /* initiate a guest shutdown */ |
| 82 | #define HXCMD_GUEST_PANIC 0x6 /* initiate a guest panic */ |
| 83 | #define HXCMD_STOP_GUEST 0x7 /* force a remote guest to stop */ |
| 84 | |
| 85 | /* |
| 86 | * mini-stack depth for each strand |
| 87 | */ |
| 88 | #define MINI_STACK_DEPTH 48 |
| 89 | |
| 90 | /* |
| 91 | * Number of per-strand scratch locations |
| 92 | */ |
| 93 | #define NSTRANDSCRATCH 8 |
| 94 | |
| 95 | |
| 96 | #ifndef _ASM |
| 97 | |
| 98 | /* |
| 99 | * Packet formats for the HV mondo messages |
| 100 | */ |
| 101 | |
| 102 | typedef struct hvm_sched { |
| 103 | uint64_t vcpup; |
| 104 | } hvm_sched_t; |
| 105 | |
| 106 | typedef struct hvm_scrub { |
| 107 | uint64_t start_pa; |
| 108 | uint64_t len; |
| 109 | } hvm_scrub_t; |
| 110 | |
| 111 | typedef struct hvm_guestcmd { |
| 112 | uint64_t vcpup; |
| 113 | uint64_t arg; |
| 114 | } hvm_guestcmd_t; |
| 115 | |
| 116 | typedef struct hvm_stopguest { |
| 117 | uint64_t guestp; |
| 118 | } hvm_stopguest_t; |
| 119 | |
| 120 | typedef struct hvm { |
| 121 | uint64_t cmd; |
| 122 | uint64_t from_strandp; |
| 123 | union { |
| 124 | hvm_sched_t sched; |
| 125 | hvm_scrub_t scrub; |
| 126 | hvm_guestcmd_t guestcmd; |
| 127 | hvm_stopguest_t stopguest; |
| 128 | uint64_t raw[6]; |
| 129 | } args; |
| 130 | } hvm_t; |
| 131 | |
| 132 | typedef struct strand strand_t; |
| 133 | typedef struct sched_slot sched_slot_t; |
| 134 | typedef struct xcall_mbox xcall_mbox_t; /* To be upgraded */ |
| 135 | |
| 136 | struct sched_slot { |
| 137 | uint64_t action; |
| 138 | uint64_t arg; |
| 139 | }; |
| 140 | |
| 141 | |
| 142 | struct xcall_mbox { |
| 143 | uint64_t command; |
| 144 | uint64_t mondobuf[8]; |
| 145 | }; |
| 146 | |
| 147 | extern void c_hvmondo_send(strand_t *destp, hvm_t *msgp); |
| 148 | |
| 149 | /* |
| 150 | * Mini stack support |
| 151 | * |
| 152 | * Each strand has a very simple work stack. Only 2 operations are supported: |
| 153 | * Push and Pop. In the event the stack gets full or under poped, HV will |
| 154 | * abort. |
| 155 | */ |
| 156 | struct mini_stack { |
| 157 | uint64_t ptr; /* ptr */ |
| 158 | uint64_t val[MINI_STACK_DEPTH]; /* value */ |
| 159 | }; |
| 160 | |
| 161 | extern strand_t strands[]; |
| 162 | |
| 163 | #endif /* !_ASM */ |
| 164 | |
| 165 | #include <platform/strand.h> |
| 166 | |
| 167 | #ifdef __cplusplus |
| 168 | } |
| 169 | #endif |
| 170 | |
| 171 | #endif /* _STRAND_H */ |