FreeBSD kernel /amd64 XEN device code
xenstore_dev.c File Reference
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/uio.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/conf.h>
#include <sys/module.h>
#include <sys/selinfo.h>
#include <sys/sysctl.h>
#include <sys/poll.h>
#include <xen/xen-os.h>
#include <xen/hypervisor.h>
#include <xen/xenstore/xenstorevar.h>
#include <xen/xenstore/xenstore_internal.h>
Include dependency graph for xenstore_dev.c:

Go to the source code of this file.

Data Structures

struct  xs_dev_transaction
 
struct  xs_dev_watch
 
struct  xs_dev_data
 

Macros

#define MASK_READ_IDX(idx)   ((idx)&(PAGE_SIZE-1))
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void xs_queue_reply (struct xs_dev_data *u, const char *data, unsigned int len)
 
static const char * xs_dev_error_to_string (int error)
 
static void xs_dev_return_error (struct xs_dev_data *u, int error, int req_id, int tx_id)
 
static int xs_dev_watch_message_parse_string (const char **p, const char *end, const char **string_r)
 
static int xs_dev_watch_message_parse (const struct xsd_sockmsg *msg, const char **path_r, const char **token_r)
 
static struct xs_dev_watchxs_dev_find_watch (struct xs_dev_data *u, const char *token)
 
static void xs_dev_watch_cb (struct xs_watch *watch, const char **vec, unsigned int len)
 
static struct xs_dev_transactionxs_dev_find_transaction (struct xs_dev_data *u, uint32_t tx_id)
 
static int xs_dev_read (struct cdev *dev, struct uio *uio, int ioflag)
 
static int xs_dev_write (struct cdev *dev, struct uio *uio, int ioflag)
 
static int xs_dev_poll (struct cdev *dev, int events, struct thread *td)
 
static void xs_dev_dtor (void *arg)
 
static int xs_dev_open (struct cdev *dev, int oflags, int devtype, struct thread *td)
 
static void xs_dev_identify (driver_t *driver __unused, device_t parent)
 Identify instances of this device type in the system. More...
 
static int xs_dev_probe (device_t dev)
 Probe for the existence of the Xenstore device. More...
 
static int xs_dev_attach (device_t dev)
 Attach the Xenstore device. More...
 
 DEFINE_CLASS_0 (xs_dev, xs_dev_driver, xs_dev_methods, 0)
 
 DRIVER_MODULE (xs_dev, xenstore, xs_dev_driver, xs_dev_devclass, NULL, NULL)
 

Variables

static unsigned int max_pending_watches = 1000
 
static struct cdevsw xs_dev_cdevsw
 
static device_method_t xs_dev_methods []
 
devclass_t xs_dev_devclass
 

Macro Definition Documentation

◆ MASK_READ_IDX

#define MASK_READ_IDX (   idx)    ((idx)&(PAGE_SIZE-1))

Definition at line 85 of file xenstore_dev.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DEFINE_CLASS_0()

DEFINE_CLASS_0 ( xs_dev  ,
xs_dev_driver  ,
xs_dev_methods  ,
 
)

◆ DRIVER_MODULE()

DRIVER_MODULE ( xs_dev  ,
xenstore  ,
xs_dev_driver  ,
xs_dev_devclass  ,
NULL  ,
NULL   
)

◆ xs_dev_attach()

static int xs_dev_attach ( device_t  dev)
static

Attach the Xenstore device.

Parameters
devNewBus device_t for this instance.
Returns
On success, 0. Otherwise an errno value indicating the type of failure.

Definition at line 513 of file xenstore_dev.c.

References max_pending_watches, and xs_dev_cdevsw.

◆ xs_dev_dtor()

static void xs_dev_dtor ( void *  arg)
static

Definition at line 420 of file xenstore_dev.c.

References xs_dev_data::ev_rsel, xs_dev_data::lock, xs_dev_data::u, xs_transaction_end(), and xs_unregister_watch().

Referenced by xs_dev_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_dev_error_to_string()

static const char * xs_dev_error_to_string ( int  error)
static

Definition at line 112 of file xenstore_dev.c.

Referenced by xs_dev_return_error().

Here is the caller graph for this function:

◆ xs_dev_find_transaction()

static struct xs_dev_transaction * xs_dev_find_transaction ( struct xs_dev_data u,
uint32_t  tx_id 
)
static

Definition at line 219 of file xenstore_dev.c.

Referenced by xs_dev_write().

Here is the caller graph for this function:

◆ xs_dev_find_watch()

static struct xs_dev_watch * xs_dev_find_watch ( struct xs_dev_data u,
const char *  token 
)
static

Definition at line 185 of file xenstore_dev.c.

Referenced by xs_dev_write().

Here is the caller graph for this function:

◆ xs_dev_identify()

static void xs_dev_identify ( driver_t *driver  __unused,
device_t  parent 
)
static

Identify instances of this device type in the system.

Parameters
driverThe driver performing this identify action.
parentThe NewBus parent device for any devices this method adds.

Definition at line 480 of file xenstore_dev.c.

◆ xs_dev_open()

static int xs_dev_open ( struct cdev *  dev,
int  oflags,
int  devtype,
struct thread *  td 
)
static

Definition at line 447 of file xenstore_dev.c.

References xs_dev_data::u, and xs_dev_dtor().

Here is the call graph for this function:

◆ xs_dev_poll()

static int xs_dev_poll ( struct cdev *  dev,
int  events,
struct thread *  td 
)
static

Definition at line 395 of file xenstore_dev.c.

References xs_dev_data::u.

◆ xs_dev_probe()

static int xs_dev_probe ( device_t  dev)
static

Probe for the existence of the Xenstore device.

Parameters
devNewBus device_t for this instance.
Returns
Always returns 0 indicating success.

Definition at line 497 of file xenstore_dev.c.

◆ xs_dev_read()

static int xs_dev_read ( struct cdev *  dev,
struct uio *  uio,
int  ioflag 
)
static

Definition at line 231 of file xenstore_dev.c.

References MASK_READ_IDX, and xs_dev_data::u.

◆ xs_dev_return_error()

static void xs_dev_return_error ( struct xs_dev_data u,
int  error,
int  req_id,
int  tx_id 
)
static

Definition at line 124 of file xenstore_dev.c.

References xs_dev_data::lock, xs_dev_error_to_string(), and xs_queue_reply().

Referenced by xs_dev_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_dev_watch_cb()

static void xs_dev_watch_cb ( struct xs_watch watch,
const char **  vec,
unsigned int  len 
)
static

Definition at line 197 of file xenstore_dev.c.

References xs_queue_reply().

Referenced by xs_dev_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_dev_watch_message_parse()

static int xs_dev_watch_message_parse ( const struct xsd_sockmsg *  msg,
const char **  path_r,
const char **  token_r 
)
static

Definition at line 164 of file xenstore_dev.c.

References xs_dev_watch_message_parse_string().

Referenced by xs_dev_write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xs_dev_watch_message_parse_string()

static int xs_dev_watch_message_parse_string ( const char **  p,
const char *  end,
const char **  string_r 
)
static

Definition at line 148 of file xenstore_dev.c.

Referenced by xs_dev_watch_message_parse().

Here is the caller graph for this function:

◆ xs_dev_write()

static int xs_dev_write ( struct cdev *  dev,
struct uio *  uio,
int  ioflag 
)
static

◆ xs_queue_reply()

static void xs_queue_reply ( struct xs_dev_data u,
const char *  data,
unsigned int  len 
)
static

Definition at line 97 of file xenstore_dev.c.

References xs_dev_data::ev_rsel, MASK_READ_IDX, xs_dev_data::read_buffer, xs_dev_data::read_cons, and xs_dev_data::read_prod.

Referenced by xs_dev_return_error(), xs_dev_watch_cb(), and xs_dev_write().

Here is the caller graph for this function:

Variable Documentation

◆ max_pending_watches

unsigned int max_pending_watches = 1000
static

Definition at line 56 of file xenstore_dev.c.

Referenced by xs_dev_attach(), and xs_dev_write().

◆ xs_dev_cdevsw

struct cdevsw xs_dev_cdevsw
static
Initial value:
= {
.d_version = D_VERSION,
.d_read = xs_dev_read,
.d_write = xs_dev_write,
.d_open = xs_dev_open,
.d_poll = xs_dev_poll,
.d_name = "xs_dev",
}
static int xs_dev_write(struct cdev *dev, struct uio *uio, int ioflag)
Definition: xenstore_dev.c:259
static int xs_dev_read(struct cdev *dev, struct uio *uio, int ioflag)
Definition: xenstore_dev.c:231
static int xs_dev_poll(struct cdev *dev, int events, struct thread *td)
Definition: xenstore_dev.c:395
static int xs_dev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
Definition: xenstore_dev.c:447

Definition at line 463 of file xenstore_dev.c.

Referenced by xs_dev_attach().

◆ xs_dev_devclass

devclass_t xs_dev_devclass

Definition at line 547 of file xenstore_dev.c.

◆ xs_dev_methods

device_method_t xs_dev_methods[]
static
Initial value:
= {
DEVMETHOD(device_identify, xs_dev_identify),
DEVMETHOD(device_probe, xs_dev_probe),
DEVMETHOD(device_attach, xs_dev_attach),
DEVMETHOD_END
}
static void xs_dev_identify(driver_t *driver __unused, device_t parent)
Identify instances of this device type in the system.
Definition: xenstore_dev.c:480
static int xs_dev_attach(device_t dev)
Attach the Xenstore device.
Definition: xenstore_dev.c:513
static int xs_dev_probe(device_t dev)
Probe for the existence of the Xenstore device.
Definition: xenstore_dev.c:497

Definition at line 537 of file xenstore_dev.c.