本文整理汇总了C++中OBJECT函数的典型用法代码示例。如果您正苦于以下问题:C++ OBJECT函数的具体用法?C++ OBJECT怎么用?C++ OBJECT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OBJECT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apic_common_realize
static void apic_common_realize(DeviceState *dev, Error **errp)
{
APICCommonState *s = APIC_COMMON(dev);
APICCommonClass *info;
static DeviceState *vapic;
static int apic_no;
static bool mmio_registered;
if (apic_no >= MAX_APICS) {
error_setg(errp, "%s initialization failed.",
object_get_typename(OBJECT(dev)));
return;
}
s->idx = apic_no++;
info = APIC_COMMON_GET_CLASS(s);
info->realize(dev, errp);
if (!mmio_registered) {
ICCBus *b = ICC_BUS(qdev_get_parent_bus(dev));
memory_region_add_subregion(b->apic_address_space, 0, &s->io_memory);
mmio_registered = true;
}
#ifndef CONFIG_HAX
/* Note: We need at least 1M to map the VAPIC option ROM */
if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
ram_size >= 1024 * 1024) {
vapic = sysbus_create_simple("kvmvapic", -1, NULL);
}
#endif
s->vapic = vapic;
if (apic_report_tpr_access && info->enable_tpr_reporting) {
info->enable_tpr_reporting(s, true);
}
}
示例2: detach
static void detach(sPAPRDRConnector *drc, DeviceState *d,
spapr_drc_detach_cb *detach_cb,
void *detach_cb_opaque, Error **errp)
{
DPRINTFN("drc: %x, detach", get_index(drc));
drc->detach_cb = detach_cb;
drc->detach_cb_opaque = detach_cb_opaque;
if (drc->isolation_state != SPAPR_DR_ISOLATION_STATE_ISOLATED) {
DPRINTFN("awaiting transition to isolated state before removal");
drc->awaiting_release = true;
return;
}
if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI &&
drc->allocation_state != SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {
DPRINTFN("awaiting transition to unusable state before removal");
drc->awaiting_release = true;
return;
}
drc->indicator_state = SPAPR_DR_INDICATOR_STATE_INACTIVE;
if (drc->detach_cb) {
drc->detach_cb(drc->dev, drc->detach_cb_opaque);
}
drc->awaiting_release = false;
g_free(drc->fdt);
drc->fdt = NULL;
drc->fdt_start_offset = 0;
object_property_del(OBJECT(drc), "device", NULL);
drc->dev = NULL;
drc->detach_cb = NULL;
drc->detach_cb_opaque = NULL;
}
示例3: goldfish_fb_init
static int goldfish_fb_init(SysBusDevice *sbdev)
{
DeviceState *dev = DEVICE(sbdev);
struct goldfish_fb_state *s = GOLDFISH_FB(dev);
dev->id = g_strdup(TYPE_GOLDFISH_FB);
sysbus_init_irq(sbdev, &s->irq);
s->con = graphic_console_init(dev, 0, &goldfish_fb_ops, s);
s->dpi = 165; /* TODO: Find better way to get actual value ! */
s->format = HAL_PIXEL_FORMAT_RGB_565;
memory_region_init_io(&s->iomem, OBJECT(s), &goldfish_fb_iomem_ops, s,
"goldfish_fb", 0x100);
sysbus_init_mmio(sbdev, &s->iomem);
register_savevm(dev, "goldfish_fb", 0, GOLDFISH_FB_SAVE_VERSION,
goldfish_fb_save, goldfish_fb_load, s);
return 0;
}
示例4: tnetw1130_init
static int tnetw1130_init(PCIDevice *pci_dev)
{
TNETW1130State *d = DO_UPCAST(TNETW1130State, dev, pci_dev);
tnetw1130_t *s = &d->tnetw1130;
/* TI TNETW1130 */
tnetw1130_pci_config(d->dev.config);
/* Handler for memory-mapped I/O */
memory_region_init_io(&d->mmio_bar0, &tnetw1130_ops0, s, "tnetw1130_mmio0",
TNETW1130_MEM0_SIZE);
memory_region_init_io(&d->mmio_bar1, &tnetw1130_ops1, s, "tnetw1130_mmio1",
TNETW1130_MEM1_SIZE);
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio_bar0);
pci_register_bar(&d->dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio_bar1);
#if 0
static const char macaddr[6] = {
0x00, 0x60, 0x65, 0x02, 0x4a, 0x8e
};
memcpy(s->conf.macaddr.a, macaddr, 6);
#endif
qemu_macaddr_default_if_unset(&s->conf.macaddr);
tnetw1130_reset(s);
s->nic = qemu_new_nic(&net_info, &s->conf,
object_get_typename(OBJECT(pci_dev)),
pci_dev->qdev.id, s);
qemu_format_nic_info_str(qemu_get_queue(s->nic), s->conf.macaddr.a);
qemu_register_reset(nic_reset, d);
return 0;
}
示例5: scsi_hot_add
static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
DriveInfo *dinfo, int printinfo)
{
SCSIBus *scsibus;
SCSIDevice *scsidev;
scsibus = (SCSIBus *)
object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
TYPE_SCSI_BUS);
if (!scsibus) {
error_report("Device is not a SCSI adapter");
return -1;
}
/*
* drive_init() tries to find a default for dinfo->unit. Doesn't
* work at all for hotplug though as we assign the device to a
* specific bus instead of the first bus with spare scsi ids.
*
* Ditch the calculated value and reload from option string (if
* specified).
*/
dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1);
dinfo->bus = scsibus->busnr;
scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo->bdrv, dinfo->unit,
false, -1);
if (!scsidev) {
return -1;
}
dinfo->unit = scsidev->id;
if (printinfo)
monitor_printf(mon, "OK bus %d, unit %d\n",
scsibus->busnr, scsidev->id);
return 0;
}
示例6: g_new0
XenBlockDataPlane *xen_block_dataplane_create(XenDevice *xendev,
BlockConf *conf,
IOThread *iothread)
{
XenBlockDataPlane *dataplane = g_new0(XenBlockDataPlane, 1);
dataplane->xendev = xendev;
dataplane->blk = conf->blk;
QLIST_INIT(&dataplane->inflight);
QLIST_INIT(&dataplane->freelist);
if (iothread) {
dataplane->iothread = iothread;
object_ref(OBJECT(dataplane->iothread));
dataplane->ctx = iothread_get_aio_context(dataplane->iothread);
} else {
dataplane->ctx = qemu_get_aio_context();
}
dataplane->bh = aio_bh_new(dataplane->ctx, xen_block_dataplane_bh,
dataplane);
return dataplane;
}
示例7: ipi_realize
static void ipi_realize(DeviceState *dev, Error **errp)
{
IPI *s = XILINX_IPI(dev);
const char *prefix = object_get_canonical_path(OBJECT(dev));
unsigned int i;
for (i = 0; i < ARRAY_SIZE(ipi_regs_info); ++i) {
DepRegisterInfo *r = &s->regs_info[ipi_regs_info[i].decode.addr/4];
*r = (DepRegisterInfo) {
.data = (uint8_t *)&s->regs[
ipi_regs_info[i].decode.addr/4],
.data_size = sizeof(uint32_t),
.access = &ipi_regs_info[i],
.debug = XILINX_IPI_ERR_DEBUG,
.prefix = prefix,
.opaque = s,
};
dep_register_init(r);
qdev_pass_all_gpios(DEVICE(r), dev);
}
qdev_init_gpio_in_named(dev, ipi_handler, "IPI_INPUTS", 32);
qdev_init_gpio_in_named(dev, obs_handler, "OBS_INPUTS", 32);
}
static void ipi_init(Object *obj)
{
IPI *s = XILINX_IPI(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
memory_region_init_io(&s->iomem, obj, &ipi_ops, s,
TYPE_XILINX_IPI, R_MAX * 4);
sysbus_init_mmio(sbd, &s->iomem);
sysbus_init_irq(sbd, &s->irq);
}
示例8: cgraphics_label_widget_create
void cgraphics_label_widget_create( widget_t *widget )
{
object_t *object = (object_t *)widget;
widget_t *parent = (widget_t *)object->parent;
HWND hwnd, hwnd_parent = widget_get_container(OBJECT(parent));
/* FIXME: bad default */
if ( widget->size_req->h == -1 )
widget->size_req->h = 25;
if ( !( hwnd = CreateWindowEx( 0, "STATIC",
"",
WS_CHILD | SS_LEFTNOWORDWRAP,
widget->size_req->x, widget->size_req->y,
widget->size_req->w, widget->size_req->h,
hwnd_parent,
NULL, (HINSTANCE) GetModuleHandle( NULL ), NULL ) ) )
MessageBox( 0, "Could not create label HWND.", "Claro error", 0 );
widget->native = hwnd;
ShowWindow( hwnd, SW_SHOW );
UpdateWindow( hwnd );
}
示例9: sysbus_esp_realize
static void sysbus_esp_realize(DeviceState *dev, Error **errp)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
SysBusESPState *sysbus = ESP(dev);
ESPState *s = &sysbus->esp;
Error *err = NULL;
sysbus_init_irq(sbd, &s->irq);
assert(sysbus->it_shift != -1);
s->chip_id = TCHI_FAS100A;
memory_region_init_io(&sysbus->iomem, OBJECT(sysbus), &sysbus_esp_mem_ops,
sysbus, "esp", ESP_REGS << sysbus->it_shift);
sysbus_init_mmio(sbd, &sysbus->iomem);
qdev_init_gpio_in(dev, sysbus_esp_gpio_demux, 2);
scsi_bus_new(&s->bus, sizeof(s->bus), dev, &esp_scsi_info, NULL);
scsi_bus_legacy_handle_cmdline(&s->bus, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
}
}
示例10: tcp_chr_tls_init
static void tcp_chr_tls_init(Chardev *chr)
{
SocketChardev *s = SOCKET_CHARDEV(chr);
QIOChannelTLS *tioc;
Error *err = NULL;
gchar *name;
if (s->is_listen) {
tioc = qio_channel_tls_new_server(
s->ioc, s->tls_creds,
NULL, /* XXX Use an ACL */
&err);
} else {
tioc = qio_channel_tls_new_client(
s->ioc, s->tls_creds,
s->addr->u.inet.data->host,
&err);
}
if (tioc == NULL) {
error_free(err);
tcp_chr_disconnect(chr);
return;
}
name = g_strdup_printf("chardev-tls-%s-%s",
s->is_listen ? "server" : "client",
chr->label);
qio_channel_set_name(QIO_CHANNEL(tioc), name);
g_free(name);
object_unref(OBJECT(s->ioc));
s->ioc = QIO_CHANNEL(tioc);
qio_channel_tls_handshake(tioc,
tcp_chr_tls_handshake,
chr,
NULL);
}
示例11: spapr_cpu_core_realize_child
static void spapr_cpu_core_realize_child(Object *child,
sPAPRMachineState *spapr, Error **errp)
{
Error *local_err = NULL;
CPUState *cs = CPU(child);
PowerPCCPU *cpu = POWERPC_CPU(cs);
Object *obj;
object_property_set_bool(child, true, "realized", &local_err);
if (local_err) {
goto error;
}
spapr_cpu_init(spapr, cpu, &local_err);
if (local_err) {
goto error;
}
obj = object_new(spapr->icp_type);
object_property_add_child(child, "icp", obj, &error_abort);
object_unref(obj);
object_property_add_const_link(obj, ICP_PROP_XICS, OBJECT(spapr),
&error_abort);
object_property_add_const_link(obj, ICP_PROP_CPU, child, &error_abort);
object_property_set_bool(obj, true, "realized", &local_err);
if (local_err) {
goto free_icp;
}
return;
free_icp:
object_unparent(obj);
error:
error_propagate(errp, local_err);
}
示例12: main
int main(int argc, char *argv[])
{
image_t * img;
object_t * menu;
list_item_t * quit_item;
claro_base_init();
claro_graphics_init();
log_fd_set_level(CL_DEBUG, stderr);
clog(CL_INFO, "%s running using Claro!", __FILE__);
w = window_widget_create(0, new_bounds(100, 100, 230, 230), 0);
object_addhandler(w, "destroy", window_closed);
window_set_title(w, "Status Icon");
menu = menu_widget_create(w, 0);
quit_item = menu_append_item(menu, NULL, stock_get_image("system-log-out"), "Quit");
object_addhandler(OBJECT(quit_item), "pushed", window_closed);
img = image_load(w, "icon.png");
s = status_icon_create(w, img, 0);
status_icon_set_tooltip(s, "Claro - Status Icon");
status_icon_set_menu(s, menu);
object_addhandler(s, "pushed", status_icon_pushed);
window_show(w);
window_focus(w);
block_heap_loginfo();
claro_loop();
return 0;
}
示例13: R_DispatchOrEvalSP
/* Version of DispatchOrEval for "[" and friends that speeds up simple cases.
Also defined in subassign.c */
static R_INLINE
int R_DispatchOrEvalSP(SEXP call, SEXP op, const char *generic, SEXP args,
SEXP rho, SEXP *ans)
{
SEXP prom = NULL;
if (args != R_NilValue && CAR(args) != R_DotsSymbol) {
SEXP x = eval(CAR(args), rho);
PROTECT(x);
if (! OBJECT(x)) {
*ans = CONS_NR(x, evalListKeepMissing(CDR(args), rho));
UNPROTECT(1);
return FALSE;
}
prom = mkPROMISE(CAR(args), R_GlobalEnv);
SET_PRVALUE(prom, x);
args = CONS(prom, CDR(args));
UNPROTECT(1);
}
PROTECT(args);
int disp = DispatchOrEval(call, op, generic, args, rho, ans, 0, 0);
if (prom) DECREMENT_REFCNT(PRVALUE(prom));
UNPROTECT(1);
return disp;
}
示例14: nvram_sysbus_initfn
static int nvram_sysbus_initfn(SysBusDevice *dev)
{
NvRamState *s = &FROM_SYSBUS(SysBusNvRamState, dev)->nvram;
FILE *file;
s->contents = g_malloc0(s->chip_size);
memory_region_init_io(&s->iomem, OBJECT(s), &nvram_ops, s,
"nvram", s->chip_size);
sysbus_init_mmio(dev, &s->iomem);
/* Read current file */
file = fopen(s->filename, "rb");
if (file) {
/* Read nvram contents */
if (fread(s->contents, s->chip_size, 1, file) != 1) {
printf("nvram_sysbus_initfn: short read\n");
}
fclose(file);
}
nvram_post_load(s, 0);
return 0;
}
示例15: PCI_DEVICE
/*
* Implementation of an interface to adjust firmware path
* for the bootindex property handling.
*/
static char *heathrow_fw_dev_path(FWPathProvider *p, BusState *bus,
DeviceState *dev)
{
PCIDevice *pci;
IDEBus *ide_bus;
IDEState *ide_s;
MACIOIDEState *macio_ide;
if (!strcmp(object_get_typename(OBJECT(dev)), "macio-oldworld")) {
pci = PCI_DEVICE(dev);
return g_strdup_printf("[email protected]%x", PCI_SLOT(pci->devfn));
}
if (!strcmp(object_get_typename(OBJECT(dev)), "macio-ide")) {
macio_ide = MACIO_IDE(dev);
return g_strdup_printf("[email protected]%x", macio_ide->addr);
}
if (!strcmp(object_get_typename(OBJECT(dev)), "ide-drive")) {
ide_bus = IDE_BUS(qdev_get_parent_bus(dev));
ide_s = idebus_active_if(ide_bus);
if (ide_s->drive_kind == IDE_CD) {
return g_strdup("cdrom");
}
return g_strdup("disk");
}
if (!strcmp(object_get_typename(OBJECT(dev)), "ide-hd")) {
return g_strdup("disk");
}
if (!strcmp(object_get_typename(OBJECT(dev)), "ide-cd")) {
return g_strdup("cdrom");
}
if (!strcmp(object_get_typename(OBJECT(dev)), "virtio-blk-device")) {
return g_strdup("disk");
}
return NULL;
}