本文整理汇总了C++中DEVICE类的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE类的具体用法?C++ DEVICE怎么用?C++ DEVICE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DEVICE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_iobase
t_stat set_iobase(UNIT *uptr, int32 val, CONST char *cptr, void *desc)
{
DEVICE* dptr;
PNP_INFO* pnp;
t_stat rc;
uint16 newbase;
if (!cptr) return SCPE_ARG;
if (!uptr) return SCPE_IERR;
if (!(dptr = find_dev_from_unit(uptr))) return SCPE_IERR;
if (!(pnp = (PNP_INFO*)dptr->ctxt)) return SCPE_IERR;
newbase = get_uint (cptr, 16, 0xFF, &rc);
if (rc != SCPE_OK) return rc;
if (dptr->flags & DEV_DIS) {
printf("Device not enabled yet.\n");
pnp->io_base = newbase;
} else {
dptr->flags |= DEV_DIS;
dptr->reset(dptr);
pnp->io_base = newbase;
dptr->flags &= ~DEV_DIS;
dptr->reset(dptr);
}
return SCPE_OK;
}
示例2: dvd_close_job
bool dvd_close_job(DCR *dcr)
{
DEVICE *dev = dcr->dev;
JCR *jcr = dcr->jcr;
bool ok = true;
/*
* If the device is a dvd and WritePartAfterJob
* is set to yes, open the next part, so, in case of a device
* that requires mount, it will be written to the device.
*/
if (dev->is_dvd() && jcr->write_part_after_job && (dev->part_size > 0)) {
Dmsg1(400, "Writing last part=%d write_partafter_job is set.\n",
dev->part);
if (dev->part < dev->num_dvd_parts+1) {
Jmsg3(jcr, M_FATAL, 0, _("Error writing. Current part less than total number of parts (%d/%d, device=%s)\n"),
dev->part, dev->num_dvd_parts, dev->print_name());
dev->dev_errno = EIO;
ok = false;
}
if (ok && !dvd_write_part(dcr)) {
Jmsg2(jcr, M_FATAL, 0, _("Unable to write last on %s: ERR=%s\n"),
dev->print_name(), dev->bstrerror());
dev->dev_errno = EIO;
ok = false;
}
}
return ok;
}
示例3: term
/*
* Free memory allocated for the device
*/
void DEVICE::term(void)
{
DEVICE *dev = NULL;
Dmsg1(900, "term dev: %s\n", print_name());
close();
if (dev_name) {
free_memory(dev_name);
dev_name = NULL;
}
if (prt_name) {
free_memory(prt_name);
prt_name = NULL;
}
if (errmsg) {
free_pool_memory(errmsg);
errmsg = NULL;
}
pthread_mutex_destroy(&m_mutex);
pthread_cond_destroy(&wait);
pthread_cond_destroy(&wait_next_vol);
pthread_mutex_destroy(&spool_mutex);
pthread_mutex_destroy(&freespace_mutex);
if (attached_dcrs) {
delete attached_dcrs;
attached_dcrs = NULL;
}
/* We let the DEVRES pointer if not our device */
if (device && device->dev == this) {
device->dev = NULL;
}
delete this;
if (dev) {
dev->term();
}
}
示例4: dvd_remove_empty_part
void dvd_remove_empty_part(DCR *dcr)
{
DEVICE *dev = dcr->dev;
/* Remove the last part file if it is empty */
if (dev->is_dvd() && dev->num_dvd_parts > 0) {
struct stat statp;
uint32_t part_save = dev->part;
POOL_MEM archive_name(PM_FNAME);
int status;
dev->part = dev->num_dvd_parts;
make_spooled_dvd_filename(dev, archive_name);
/* Check that the part file is empty */
status = stat(archive_name.c_str(), &statp);
if (status == 0 && statp.st_size == 0) {
Dmsg3(100, "Unlink empty part in close call make_dvd_filename. part=%d num=%d vol=%s\n",
part_save, dev->num_dvd_parts, dev->getVolCatName());
Dmsg1(100, "unlink(%s)\n", archive_name.c_str());
unlink(archive_name.c_str());
if (part_save == dev->part) {
dev->set_part_spooled(false); /* no spooled part left */
}
} else if (status < 0) {
if (part_save == dev->part) {
dev->set_part_spooled(false); /* spool doesn't exit */
}
}
dev->part = part_save; /* restore part number */
}
}
示例5: reset
void VM::reset()
{
// reset all devices
for(DEVICE* device = first_device; device; device = device->next_device) {
device->reset();
}
}
示例6: emu
VM::VM(EMU* parent_emu) : emu(parent_emu)
{
// create devices
first_device = last_device = NULL;
dummy = new DEVICE(this, emu); // must be 1st device
event = new EVENT(this, emu); // must be 2nd device
drec = new DATAREC(this, emu);
sio = new I8251(this, emu);
pio_k = new I8255(this, emu);
pio_f = new I8255(this, emu);
io = new IO(this, emu);
psg = new SN76489AN(this, emu);
vdp = new TMS9918A(this, emu);
fdc = new UPD765A(this, emu);
cpu = new Z80(this, emu);
key = new KEYBOARD(this, emu);
memory = new MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(psg);
drec->set_context_out(pio_k, SIG_I8255_PORT_B, 0x80);
pio_k->set_context_port_c(key, SIG_KEYBOARD_COLUMN, 0x07, 0);
pio_k->set_context_port_c(drec, SIG_DATAREC_REMOTE, 0x08, 0);
pio_k->set_context_port_c(drec, SIG_DATAREC_OUT, 0x10, 0);
pio_f->set_context_port_c(fdc, SIG_UPD765A_MOTOR_NEG, 2, 0);
pio_f->set_context_port_c(fdc, SIG_UPD765A_TC, 4, 0);
pio_f->set_context_port_c(fdc, SIG_UPD765A_RESET, 8, 0);
pio_f->set_context_port_c(memory, SIG_MEMORY_SEL, 0x40, 0);
vdp->set_context_irq(cpu, SIG_CPU_IRQ, 1);
fdc->set_context_irq(pio_f, SIG_I8255_PORT_A, 1);
fdc->set_context_index(pio_f, SIG_I8255_PORT_A, 4);
#ifdef _FDC_DEBUG_LOG
fdc->set_context_cpu(cpu);
#endif
key->set_context_cpu(cpu);
key->set_context_pio(pio_k);
// cpu bus
cpu->set_context_mem(memory);
cpu->set_context_io(io);
cpu->set_context_intr(dummy);
// i/o bus
io->set_iomap_range_rw(0x40, 0x7f, psg);
io->set_iomap_range_rw(0x80, 0xbf, vdp);
io->set_iomap_range_rw(0xc0, 0xdf, pio_k);
io->set_iomap_range_rw(0xe0, 0xe3, fdc);
io->set_iomap_range_rw(0xe4, 0xe7, pio_f);
io->set_iomap_range_rw(0xe8, 0xeb, sio);
// initialize all devices
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
}
示例7: write_volume_label_to_block
/*
* Put a volume label into the block
*
* Returns: false on failure
* true on success
*/
static bool write_volume_label_to_block(DCR *dcr)
{
DEVICE *dev = dcr->dev;
DEV_BLOCK *block = dcr->block;
DEV_RECORD rec;
JCR *jcr = dcr->jcr;
Dmsg0(130, "write Label in write_volume_label_to_block()\n");
memset(&rec, 0, sizeof(rec));
rec.data = get_memory(SER_LENGTH_Volume_Label);
empty_block(block); /* Volume label always at beginning */
create_volume_label_record(dcr, dev, &rec);
block->BlockNumber = 0;
if (!write_record_to_block(dcr, &rec)) {
free_pool_memory(rec.data);
Jmsg1(jcr, M_FATAL, 0, _("Cannot write Volume label to block for device %s\n"),
dev->print_name());
return false;
} else {
Dmsg2(130, "Wrote label of %d bytes to block. Vol=%s\n", rec.data_len,
dcr->VolumeName);
}
free_pool_memory(rec.data);
return true;
}
示例8: emu
VM::VM(EMU* parent_emu) : emu(parent_emu)
{
// create devices
first_device = last_device = NULL;
dummy = new DEVICE(this, emu); // must be 1st device
event = new EVENT(this, emu); // must be 2nd device
sio = new I8251(this, emu);
drec = new CMT(this, emu);
io = new IO(this, emu);
vdp = new MC6847(this, emu);
not = new NOT(this, emu);
psg = new YM2203(this, emu);
cpu = new Z80(this, emu);
joystick = new JOYSTICK(this, emu);
keyboard = new KEYBOARD(this, emu);
memory = new MEMORY(this, emu);
system = new SYSTEM(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(psg);
vdp->set_vram_ptr(memory->get_vram(), 0x1800);
vdp->set_font_ptr(memory->get_cgrom(), memory->get_pcgram());
vdp->set_context_vsync(not, SIG_NOT_INPUT, 1);
not->set_context_out(cpu, SIG_CPU_IRQ, 1);
joystick->set_context_psg(psg);
system->set_context_drec(drec);
system->set_context_vdp(vdp);
drec->set_context_sio(sio);
// cpu bus
cpu->set_context_mem(memory);
cpu->set_context_io(io);
cpu->set_context_intr(dummy);
sio->set_context_out(drec, SIG_CMT_OUT);
// i/o bus
io->set_iomap_range_r(0x00, 0x0f, keyboard);
io->set_iomap_range_w(0x10, 0x1f, system);
io->set_iomap_range_w(0x30, 0x3f, system);
for(int i = 0x20; i < 0x30; i += 4) {
io->set_iomap_alias_w(i+1, psg, 1);
io->set_iomap_alias_r(i+2, psg, 1);
io->set_iomap_alias_w(i+3, psg, 0);
}
io->set_iomap_range_w(0x60, 0x7f, memory);
io->set_iomap_alias_rw(0xb0, sio, 0);
io->set_iomap_alias_rw(0xb8, sio, 1);
// initialize all devices
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
}
示例9: emu
VM::VM(EMU* parent_emu) : emu(parent_emu)
{
// create devices
first_device = last_device = NULL;
dummy = new DEVICE(this, emu); // must be 1st device
event = new EVENT(this, emu); // must be 2nd device
drec = new DATAREC(this, emu);
io = new IO(this, emu);
vdp = new MC6847(this, emu);
not = new NOT(this, emu);
psg = new YM2203(this, emu);
cpu = new Z80(this, emu);
joystick = new JOYSTICK(this, emu);
keyboard = new KEYBOARD(this, emu);
memory = new MEMORY(this, emu);
system = new SYSTEM(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(psg);
vdp->set_vram_ptr(memory->get_vram(), 0x1800);
vdp->set_context_vsync(not, SIG_NOT_INPUT, 1);
not->set_context_out(cpu, SIG_CPU_IRQ, 1);
vdp->set_context_vsync(system, SIG_SYSTEM_PORT, 0x10);
drec->set_context_out(system, SIG_SYSTEM_PORT, 0x20);
// bit6: printer busy
vdp->set_context_hsync(system, SIG_SYSTEM_PORT, 0x80);
joystick->set_context_psg(psg);
#ifdef _MAP1010
memory->set_context_keyboard(keyboard);
#endif
system->set_context_drec(drec);
system->set_context_vdp(vdp);
// cpu bus
cpu->set_context_mem(memory);
cpu->set_context_io(io);
cpu->set_context_intr(dummy);
// i/o bus
io->set_iomap_single_rw(0x40, system);
#ifndef _MAP1010
io->set_iomap_range_r(0x80, 0x88, keyboard);
#endif
io->set_iomap_alias_w(0xc0, psg, 1); // PSG data
io->set_iomap_alias_w(0xc1, psg, 0); // PSG ch
// io->set_iomap_alias_r(0xc0, psg, 1);
io->set_iomap_alias_r(0xc1, psg, 1); // PSG data
// initialize all devices
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
}
示例10: reset
void VM::reset()
{
memory->readrom(config.device_type);
// reset all devices
for(DEVICE* device = first_device; device; device = device->next_device) {
device->reset();
}
}
示例11: special_reset
void VM::special_reset()
{
// system reset
for(DEVICE* device = first_device; device; device = device->next_device) {
device->reset();
}
io->sysreset();
}
示例12: emu
VM::VM(EMU* parent_emu) : emu(parent_emu)
{
// create devices
first_device = last_device = NULL;
dummy = new DEVICE(this, emu); // must be 1st device
event = new EVENT(this, emu); // must be 2nd device
// cmt = new DATAREC(this, emu);
cpu = new I8080(this, emu);
pio = new I8155(this, emu);
io = new IO(this, emu);
buzzer = new PCM1BIT(this, emu);
rtc = new UPD1990A(this, emu);
keyboard = new KEYBOARD(this, emu);
lcd = new LCD(this, emu);
memory = new MEMORY(this, emu);
// set contexts
event->set_context_cpu(cpu);
event->set_context_sound(buzzer);
// cmt->set_context_out(cpu, SIG_I8085_SID, 1);
// cpu->set_context_sod(cmt, SIG_DATAREC_OUT, 1);
pio->set_context_port_a(rtc, SIG_UPD1990A_C0, 1, 0);
pio->set_context_port_a(rtc, SIG_UPD1990A_C1, 2, 0);
pio->set_context_port_a(rtc, SIG_UPD1990A_C2, 4, 0);
pio->set_context_port_a(rtc, SIG_UPD1990A_CLK, 8, 0);
pio->set_context_port_a(rtc, SIG_UPD1990A_DIN, 0x10, 0);
pio->set_context_port_a(keyboard, SIG_KEYBOARD_COLUMN_L, 0xff, 0);
pio->set_context_port_a(lcd, SIG_LCD_CHIPSEL_L, 0xff, 0);
pio->set_context_port_b(keyboard, SIG_KEYBOARD_COLUMN_H, 1, 0);
pio->set_context_port_b(lcd, SIG_LCD_CHIPSEL_H, 3, 0);
pio->set_context_port_b(buzzer, SIG_PCM1BIT_MUTE, 0x20, 0);
pio->set_context_timer(buzzer, SIG_PCM1BIT_SIGNAL, 1);
pio->set_constant_clock(CPU_CLOCKS);
rtc->set_context_dout(pio, SIG_I8155_PORT_C, 1);
rtc->set_context_tp(cpu, SIG_I8085_RST7, 1);
// memory->set_context_cmt(cmt);
memory->set_context_rtc(rtc);
// cpu bus
cpu->set_context_mem(memory);
cpu->set_context_io(io);
// i/o bus
io->set_iomap_range_w(0x90, 0x9f, memory);
io->set_iomap_range_rw(0xa0, 0xaf, memory);
io->set_iomap_range_rw(0xb0, 0xbf, pio);
io->set_iomap_range_r(0xe0, 0xef, keyboard);
io->set_iomap_range_rw(0xf0, 0xff, lcd);
// initialize all devices
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
}
示例13: save_state
void VM::save_state(FILEIO* state_fio)
{
state_fio->FputUint32(STATE_VERSION);
for(DEVICE* device = first_device; device; device = device->next_device) {
device->save_state(state_fio);
}
state_fio->Fwrite(ram, sizeof(ram), 1);
}
示例14: dir_ask_sysop_to_mount_volume
bool dir_ask_sysop_to_mount_volume(DCR *dcr, int /*mode*/)
{
DEVICE *dev = dcr->dev;
fprintf(stderr, _("Mount Volume \"%s\" on device %s and press return when ready: "),
dcr->VolumeName, dev->print_name());
dev->close(dcr);
getchar();
return true;
}
示例15:
VM::~VM()
{
// delete all devices
for(DEVICE* device = first_device; device;) {
DEVICE *next_device = device->next_device;
device->release();
delete device;
device = next_device;
}
}