static void bch(unsigned fn, _go32_dpmi_registers* r) { static const unsigned pci_stack_size = 2048; _go32_dpmi_seginfo si; int go32_ec; assert(pci_stack_size <= 65536); r->h.ah = PCI_FUNCTION_ID; r->h.al = fn; memset(&si, 0, sizeof(si)); si.size = (pci_stack_size + 15) / 16; go32_ec = _go32_dpmi_allocate_dos_memory(&si); if(go32_ec != 0) { fprintf(stderr, "DOS memory allocation failed: %d\n", go32_ec); abort(); } r->x.ss = si.rm_segment; r->x.sp = pci_stack_size; go32_ec = _go32_dpmi_simulate_int(0x1A, r); if(go32_ec != 0) { _go32_dpmi_free_dos_memory(&si); fprintf(stderr, "Simulate int failed: %d\n", go32_ec); abort(); } _go32_dpmi_free_dos_memory(&si); }
static void Cleanup(CMI8738_Driver_t* ds) { if(ds->dmabuf.size != 0) { _go32_dpmi_free_dos_memory(&ds->dmabuf); ds->dmabuf.size = 0; } if(ds->base_addr != 0) { wrdm32(ds, 0x00, (1U << 18)); } }