* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: svc.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
#pragma ident "@(#)svc.h 1.10 07/05/30 SMI"
#define XPID_GUESTBASE 16
#define XPID_GUEST(n) (XPID_GUESTBASE + (n))
/* the service config bits */
#define SVC_CFG_RX 0x00000001 /* support RECV */
#define SVC_CFG_RE 0x00000002 /* support RECV intr */
#define SVC_CFG_TX 0x00000004 /* support SEND */
#define SVC_CFG_TE 0x00000008 /* support SEND intr */
#define SVC_CFG_GET 0x00000010 /* support GETSTATUS */
#define SVC_CFG_SET 0x00000020 /* support SETSTATUS */
#define SVC_CFG_LINK 0x00000100 /* cross linked svc */
#define SVC_CFG_MAGIC 0x00000200 /* legion magic trap */
#define SVC_CFG_CALLBACK 0x0000800 /* hypervisor callback */
#define SVC_CFG_PRIV 0x80000000
SVC_CFG_RX | SVC_CFG_RI | \
SVC_CFG_TX | SVC_CFG_TI | \
SVC_CFG_GET | SVC_CFG_SET)
/* the service status/flag bits */
#define SVC_FLAGS_RI 0x00000001 /* RECV pending */
#define SVC_FLAGS_RE 0x00000002 /* RECV intr enabled */
#define SVC_FLAGS_TI 0x00000004 /* SEND complete */
#define SVC_FLAGS_TE 0x00000008 /* SEND intr enabled */
#define SVC_FLAGS_TP 0x00000010 /* TX pending (queued) */
#define SVC_FLAG_ABORT (1 << ABORT_SHIFT) /* ABORT XXX interrupt ? */
/* the offsets in the svc register tables */
/* fixed services between HV and VBSC */
#define VBSC_HV_ERRORS_SVC_SID 0x2
#define VBSC_HV_ERRORS_SVC_XID 0x2
#define VBSC_HV_ERRORS_SVC_FLAGS 0x35
#define VBSC_HV_ERRORS_SVC_MTU 0x200
#define VBSC_DEBUG_SVC_SID 0x3
#define VBSC_DEBUG_SVC_XID 0x2
#define VBSC_DEBUG_SVC_FLAGS 0x35
#define VBSC_DEBUG_SVC_MTU 0x200
/* May not modify condition codes */
#define LOCK(r_base, offset, r_tmp, r_tmp1) \
add r_base, offset, r_tmp ;\
1: casx [r_tmp], %g0, r_tmp1 ;\
/* May not modify condition codes */
/* watchout!! the branch will use the delay slot.. */
#define TRYLOCK(r_base, offset, r_tmp0, r_tmp1) \
add r_base, offset, r_tmp0 ;\
casx [r_tmp0], %g0, r_tmp1 ;\
brlz,pn r_tmp1, herr_wouldblock ;
#define TRACE(x) PRINT(x); PRINT("\r\n")
#define TRACE1(x) PRINT(x); PRINT(": "); PRINTX(%o0); PRINT("\r\n")
PRINT("svc root: "); PRINTX(r_root); \
PRINT(", "); PRINTX(r_svc); PRINT("\r\n");
#define SEND_SVC_PACKET(r_root, r_svc, sc0, sc1, sc2, sc3) \
ldx [r_root + HV_SVC_DATA_TXBASE], sc0 ; \
ldx [r_svc + SVC_CTRL_SEND + SVC_LINK_PA], sc1; \
ldx [r_svc + SVC_CTRL_SEND + SVC_LINK_SIZE], sc2; \
SMALL_COPY_MACRO(sc1, sc2, sc0, sc3) ; \
ldx [r_root + HV_SVC_DATA_TXCHANNEL], sc1 ; \
ldx [r_svc + SVC_CTRL_SEND + SVC_LINK_SIZE], sc2; \
sth sc2, [sc1 + FPGA_Q_SIZE] ; \
stb sc0, [sc1 + FPGA_Q_SEND] ;
#define UNLOCK(r_base, offset) \
stx %g0, [r_base + offset]
#define SVCCN_TYPE_BREAK 0x80
#define SVCCN_TYPE_HUP 0x81
#define SVCCN_TYPE_CHARS 0x00
* The svc_data blocks are back-to-back in memory (a linear array)
* if we get to the end then this is a bad service request.
uint64_t rx
; /* called on rx intr */
uint64_t cookie
; /* your callback cookie */
typedef struct svc_ctrl svc_ctrl_t
;
uint32_t ino
; /* virtual INO */
uint32_t config
; /* API control bits */
uint32_t state
; /* device state */
uint32_t dcount
; /* defer count */
uint32_t dstate
; /* defer state 0=NACK, 1=BUSY */
uint64_t lock
; /* simple mutex */
uint64_t intr_cookie
; /* intr gen cookie */
struct svc_callback callback
; /* HV call backhandle */
struct svc_ctrl
*link
; /* cross link */
uint32_t xid
; /* service guest ID */
uint16_t sum
; /* packet checksum */
uint16_t sid
; /* svcid */
typedef struct hv_svc_data hv_svc_data_t
;
uint64_t rxbase
; /* PA of RX buffer (SRAM) */
uint64_t txbase
; /* PA of TX buffer (SRAM) */
uint64_t rxchannel
; /* RX channel regs PA */
uint64_t txchannel
; /* TX channel regs PA */
uint64_t scr
[2]; /* reg scratch */
struct svc_ctrl
*sendh
; /* intrs send from here */
struct svc_ctrl
*sendt
; /* sender adds here */
struct svc_ctrl
*senddh
; /* holding.. (nack/busy) */
uint64_t lock
; /* need mutex?? */
struct svc_ctrl svcs
[MAX_SVCS
]; /* the svc buffers follow */
* Console protocol packet definition