xenstore.c (7c743c89a068dd36b60dab9a485e9b5195c8e1cc) | xenstore.c (cfa0b7b82fbdda56d7160569def5c6133eb045aa) |
---|---|
1/****************************************************************************** 2 * xenstore.c 3 * 4 * Low-level kernel interface to the XenStore. 5 * 6 * Copyright (C) 2005 Rusty Russell, IBM Corporation 7 * Copyright (C) 2009,2010 Spectra Logic Corporation 8 * --- 101 unchanged lines hidden (view full) --- 110 * Pointer to shared memory communication structures allowing us 111 * to communicate with the XenStore service. 112 * 113 * When operating in full PV mode, this pointer is set early in kernel 114 * startup from within xen_machdep.c. In HVM mode, we use hypercalls 115 * to get the guest frame number for the shared page and then map it 116 * into kva. See xs_init() for details. 117 */ | 1/****************************************************************************** 2 * xenstore.c 3 * 4 * Low-level kernel interface to the XenStore. 5 * 6 * Copyright (C) 2005 Rusty Russell, IBM Corporation 7 * Copyright (C) 2009,2010 Spectra Logic Corporation 8 * --- 101 unchanged lines hidden (view full) --- 110 * Pointer to shared memory communication structures allowing us 111 * to communicate with the XenStore service. 112 * 113 * When operating in full PV mode, this pointer is set early in kernel 114 * startup from within xen_machdep.c. In HVM mode, we use hypercalls 115 * to get the guest frame number for the shared page and then map it 116 * into kva. See xs_init() for details. 117 */ |
118struct xenstore_domain_interface *xen_store; | 118static struct xenstore_domain_interface *xen_store; |
119 120/*-------------------------- Private Data Structures ------------------------*/ 121 122/** 123 * Structure capturing messages received from the XenStore service. 124 */ 125struct xs_stored_msg { 126 TAILQ_ENTRY(xs_stored_msg) list; --- 971 unchanged lines hidden (view full) --- 1098 /* Allow us to get device_t from softc and vice-versa. */ 1099 xs.xs_dev = dev; 1100 device_set_softc(dev, &xs); 1101 1102 /* Initialize the interface to xenstore. */ 1103 struct proc *p; 1104 1105 xs.initialized = false; | 119 120/*-------------------------- Private Data Structures ------------------------*/ 121 122/** 123 * Structure capturing messages received from the XenStore service. 124 */ 125struct xs_stored_msg { 126 TAILQ_ENTRY(xs_stored_msg) list; --- 971 unchanged lines hidden (view full) --- 1098 /* Allow us to get device_t from softc and vice-versa. */ 1099 xs.xs_dev = dev; 1100 device_set_softc(dev, &xs); 1101 1102 /* Initialize the interface to xenstore. */ 1103 struct proc *p; 1104 1105 xs.initialized = false; |
1106 if (xen_hvm_domain()) { 1107 xs.evtchn = hvm_get_parameter(HVM_PARAM_STORE_EVTCHN); 1108 xs.gpfn = hvm_get_parameter(HVM_PARAM_STORE_PFN); 1109 xen_store = pmap_mapdev(xs.gpfn * PAGE_SIZE, PAGE_SIZE); 1110 xs.initialized = true; 1111 } else if (xen_pv_domain()) { 1112 if (HYPERVISOR_start_info->store_evtchn == 0) { 1113 struct evtchn_alloc_unbound alloc_unbound; | 1106 xs.evtchn = xen_get_xenstore_evtchn(); 1107 if (xs.evtchn == 0) { 1108 struct evtchn_alloc_unbound alloc_unbound; |
1114 | 1109 |
1115 /* Allocate a local event channel for xenstore */ 1116 alloc_unbound.dom = DOMID_SELF; 1117 alloc_unbound.remote_dom = DOMID_SELF; 1118 error = HYPERVISOR_event_channel_op( 1119 EVTCHNOP_alloc_unbound, &alloc_unbound); 1120 if (error != 0) 1121 panic( 1122 "unable to alloc event channel for Dom0: %d", 1123 error); | 1110 /* Allocate a local event channel for xenstore */ 1111 alloc_unbound.dom = DOMID_SELF; 1112 alloc_unbound.remote_dom = DOMID_SELF; 1113 error = HYPERVISOR_event_channel_op( 1114 EVTCHNOP_alloc_unbound, &alloc_unbound); 1115 if (error != 0) 1116 panic( 1117 "unable to alloc event channel for Dom0: %d", 1118 error); |
1124 | 1119 |
1125 HYPERVISOR_start_info->store_evtchn = 1126 alloc_unbound.port; 1127 xs.evtchn = alloc_unbound.port; | 1120 xs.evtchn = alloc_unbound.port; |
1128 | 1121 |
1129 /* Allocate memory for the xs shared ring */ 1130 xen_store = malloc(PAGE_SIZE, M_XENSTORE, 1131 M_WAITOK | M_ZERO); 1132 } else { 1133 xs.evtchn = HYPERVISOR_start_info->store_evtchn; 1134 xs.initialized = true; 1135 } | 1122 /* Allocate memory for the xs shared ring */ 1123 xen_store = malloc(PAGE_SIZE, M_XENSTORE, M_WAITOK | M_ZERO); 1124 xs.gpfn = atop(pmap_kextract((vm_offset_t)xen_store)); |
1136 } else { | 1125 } else { |
1137 panic("Unknown domain type, cannot initialize xenstore."); | 1126 xs.gpfn = xen_get_xenstore_mfn(); 1127 xen_store = pmap_mapdev_attr(ptoa(xs.gpfn), PAGE_SIZE, 1128 PAT_WRITE_BACK); 1129 xs.initialized = true; |
1138 } 1139 1140 TAILQ_INIT(&xs.reply_list); 1141 TAILQ_INIT(&xs.watch_events); 1142 1143 mtx_init(&xs.ring_lock, "ring lock", NULL, MTX_DEF); 1144 mtx_init(&xs.reply_lock, "reply lock", NULL, MTX_DEF); 1145 sx_init(&xs.xenwatch_mutex, "xenwatch"); --- 104 unchanged lines hidden (view full) --- 1250/*------------------------------- Sysctl Data --------------------------------*/ 1251/* XXX Shouldn't the node be somewhere else? */ 1252SYSCTL_NODE(_dev, OID_AUTO, xen, CTLFLAG_RD, NULL, "Xen"); 1253SYSCTL_INT(_dev_xen, OID_AUTO, xsd_port, CTLFLAG_RD, &xs.evtchn, 0, ""); 1254SYSCTL_ULONG(_dev_xen, OID_AUTO, xsd_kva, CTLFLAG_RD, (u_long *) &xen_store, 0, ""); 1255 1256/*-------------------------------- Public API --------------------------------*/ 1257/*------- API comments for these methods can be found in xenstorevar.h -------*/ | 1130 } 1131 1132 TAILQ_INIT(&xs.reply_list); 1133 TAILQ_INIT(&xs.watch_events); 1134 1135 mtx_init(&xs.ring_lock, "ring lock", NULL, MTX_DEF); 1136 mtx_init(&xs.reply_lock, "reply lock", NULL, MTX_DEF); 1137 sx_init(&xs.xenwatch_mutex, "xenwatch"); --- 104 unchanged lines hidden (view full) --- 1242/*------------------------------- Sysctl Data --------------------------------*/ 1243/* XXX Shouldn't the node be somewhere else? */ 1244SYSCTL_NODE(_dev, OID_AUTO, xen, CTLFLAG_RD, NULL, "Xen"); 1245SYSCTL_INT(_dev_xen, OID_AUTO, xsd_port, CTLFLAG_RD, &xs.evtchn, 0, ""); 1246SYSCTL_ULONG(_dev_xen, OID_AUTO, xsd_kva, CTLFLAG_RD, (u_long *) &xen_store, 0, ""); 1247 1248/*-------------------------------- Public API --------------------------------*/ 1249/*------- API comments for these methods can be found in xenstorevar.h -------*/ |
1250bool 1251xs_initialized(void) 1252{ 1253 1254 return (xs.initialized); 1255} 1256 1257evtchn_port_t 1258xs_evtchn(void) 1259{ 1260 1261 return (xs.evtchn); 1262} 1263 1264vm_paddr_t 1265xs_address(void) 1266{ 1267 1268 return (ptoa(xs.gpfn)); 1269} 1270 |
|
1258int 1259xs_directory(struct xs_transaction t, const char *dir, const char *node, 1260 u_int *num, const char ***result) 1261{ 1262 struct sbuf *path; 1263 char *strings; 1264 u_int len = 0; 1265 int error; --- 380 unchanged lines hidden --- | 1271int 1272xs_directory(struct xs_transaction t, const char *dir, const char *node, 1273 u_int *num, const char ***result) 1274{ 1275 struct sbuf *path; 1276 char *strings; 1277 u_int len = 0; 1278 int error; --- 380 unchanged lines hidden --- |