int Flash_Write(ioAddress offset, ioData data) { ioData status = 0; IO_Write(CommandRegister, ProgramCommand); IO_Write(offset, data); while ((status & ReadyBit) == 0) status = IO_Read(StatusRegister); if (status != ReadyBit) { IO_Write(CommandRegister, Reset); if (status & VppErrorBit) return FLASH_VPP_ERROR; else if (status & ProgramErrorBit) return FLASH_PROGRAM_ERROR; else if (status & BlockProtectionErrorBit) return FLASH_PROTECTED_BLOCK_ERROR; else return FLASH_UNKNOWN_PROGRAM_ERROR; } IO_Read(address); return FLASH_SUCCESS; }
int Flash_Write(ioAddress address, ioData data) { IO_Write(0, 0x40); IO_Write(address, data); IO_Read(0); IO_Read(address); return FLASH_SUCCESS; }
int Flash_Write(ioAddress address, ioData data) { IO_Write(CommandRegister, ProgramCommand); IO_Write(address, data); IO_Read(StatusRegister); IO_Read(address); return FLASH_SUCCESS; }
static void applicationTick(void) { BTN_STATE_ENUM up = IO_Read(UP_PINS, UP_PIN); // Read up button state; BTN_STATE_ENUM digit = IO_Read(DIGIT_PINS, DIGIT_PIN); // Read digit button state; UC_BTN_Tick(up, digit); }
static void readTestMode(void) { testMode = 0; if (IO_Read(SETUP_PINS, SETUP_PIN0) == false) { testMode += 1; } if (IO_Read(SETUP_PINS, SETUP_PIN1) == false) { testMode += 2; } }
void SaveVgaRegisters() { for (int i=0; i<9; i++) { IO_Write (0x3CE,i); gfxReg3CE[i] = IO_Read(0x3CF); } /* Setup some default values in GFX regs that should work */ IO_Write(0x3CE,3); IO_Write(0x3Cf,0); //disable rotate and operation IO_Write(0x3CE,5); IO_Write(0x3Cf,gfxReg3CE[5]&0xf0); //Force read/write mode 0 //Set Map to all planes. Celtic Tales index3C4 = IO_Read(0x3c4); IO_Write(0x3C4,2); gfxReg3C5 = IO_Read(0x3C5); IO_Write(0x3C5,0xF); }
int Flash_Write(ioAddress address, ioData data) { ioData status = 0; IO_Write(CommandRegister, ProgramCommand); IO_Write(address, data); while ((status & ReadyBit) == 0) status = IO_Read(StatusRegister); IO_Read(address); return FLASH_SUCCESS; }
int Flash_Write(ioAddress offset, ioData data) { ioData status = 0; IO_Write(CommandRegister, ProgramCommand); IO_Write(offset, data); while ((status & ReadyBit) == 0) status = IO_Read(StatusRegister); if (status != ReadyBit) return writeError(status); if (data != IO_Read(offset)) return FLASH_READ_BACK_ERROR; return FLASH_SUCCESS; }
int pigaleWindow::publicLoad(int pos) // Only called by the server {QFileInfo fi(InputFileName); QString m; if(!fi.exists() || fi.size() == 0) {m = QString("file -%1- does not exist").arg(InputFileName); LogPrintf("%s\n",(const char *)m.toLatin1()); setPigaleError(-1,"Non existing file"); return -1; } int i = IO_WhoseIs((const char *)InputFileName.toLatin1()); if(i < 0) {m = QString("%1: unrecognized format").arg(InputFileName); LogPrintf("%s\n",(const char *)m.toLatin1()); setPigaleError(-1,"unrecognized format"); return -1; } InputDriver = i; int NumRecords =IO_GetNumRecords(i,(const char *)InputFileName.toLatin1()); *pGraphIndex = pos; if(*pGraphIndex > NumRecords)*pGraphIndex = 1; else if(*pGraphIndex < 1)*pGraphIndex += NumRecords; if(IO_Read(i,GC,(const char *)InputFileName.toLatin1(),NumRecords,*pGraphIndex) != 0) {m = QString("Could not read:%1").arg(InputFileName); LogPrintf("%s\n",(const char *)m.toLatin1()); return -2; } QFile file(InputFileName); file.remove(); if(debug())DebugPrintf("\n**** %s: %d/%d",(const char *)InputFileName.toLatin1(),*pGraphIndex,NumRecords); Prop<bool> eoriented(GC.Set(tedge()),PROP_ORIENTED,false); TopologicalGraph G(GC); return *pGraphIndex; }
static int ZFILE_read(ZFILE zfd, char *buf, jint nbytes) { #ifdef WIN32 return (int) IO_Read(zfd, buf, nbytes); #else return read(zfd, buf, nbytes); #endif }
Bit8u VESA_GetPalette(PhysPt data,Bitu index,Bitu count) { Bit8u r,g,b; if (index>255) return VESA_FAIL; if (index+count>256) return VESA_FAIL; IO_Write(0x3c7,(Bit8u)index); while (count) { r = IO_Read(0x3c9); g = IO_Read(0x3c9); b = IO_Read(0x3c9); mem_writeb(data++,b); mem_writeb(data++,g); mem_writeb(data++,r); data++; count--; } return VESA_SUCCESS; }
Bit8u VESA_GetDisplayStart(Bit16u & x,Bit16u & y) { Bitu pixels_per_offset; Bitu panning_factor = 1; switch (CurMode->type) { case M_TEXT: pixels_per_offset = 16; break; case M_LIN4: pixels_per_offset = 16; break; case M_LIN8: panning_factor = 2; pixels_per_offset = 8; break; case M_LIN15: case M_LIN16: panning_factor = 2; pixels_per_offset = 4; break; case M_LIN32: pixels_per_offset = 2; break; default: return VESA_MODE_UNSUPPORTED; } IO_Read(0x3da); // reset attribute flipflop IO_Write(0x3c0,0x13 | 0x20); // panning register, screen on Bit8u panning = IO_Read(0x3c1); Bitu virtual_screen_width = vga.config.scan_len * pixels_per_offset; Bitu start_pixel = vga.config.display_start * (pixels_per_offset/2) + panning / panning_factor; y = start_pixel / virtual_screen_width; x = start_pixel % virtual_screen_width; return VESA_SUCCESS; }
void FinishSetMode_PVGA1A(Bitu /*crtc_base*/, VGA_ModeExtraData* modeData) { pvga1a.biosMode = modeData->modeNo; // Reset to single bank and set it to 0. May need to unlock first (DPaint locks on exit) IO_Write(0x3ce, 0x0f); Bitu oldlock = IO_Read(0x3cf); IO_Write(0x3cf, 0x05); IO_Write(0x3ce, 0x09); IO_Write(0x3cf, 0x00); IO_Write(0x3ce, 0x0a); IO_Write(0x3cf, 0x00); IO_Write(0x3ce, 0x0b); Bit8u val = IO_Read(0x3cf); IO_Write(0x3cf, val & ~0x08); IO_Write(0x3ce, 0x0c); IO_Write(0x3cf, 0x00); IO_Write(0x3ce, 0x0d); IO_Write(0x3cf, 0x00); IO_Write(0x3ce, 0x0e); IO_Write(0x3cf, 0x00); IO_Write(0x3ce, 0x0f); IO_Write(0x3cf, oldlock); if (svga.determine_mode) svga.determine_mode(); if(vga.mode != M_VGA) { vga.config.compatible_chain4 = false; // vga.vmemwrap = vga.mem.memsize; } else { vga.config.compatible_chain4 = true; // vga.vmemwrap = 256*1024; } // FIXME: What? Is this needed? vga.config.compatible_chain4 = false; VGA_SetupHandlers(); }
static Bitu INT70_Handler(void) { /* Acknowledge irq with cmos */ IO_Write(0x70,0xc); IO_Read(0x71); if (mem_readb(BIOS_WAIT_FLAG_ACTIVE)) { Bit32u count=mem_readd(BIOS_WAIT_FLAG_COUNT); if (count>997) { mem_writed(BIOS_WAIT_FLAG_COUNT,count-997); } else { mem_writed(BIOS_WAIT_FLAG_COUNT,0); PhysPt where=Real2Phys(mem_readd(BIOS_WAIT_FLAG_POINTER)); mem_writeb(where,mem_readb(where)|0x80); mem_writeb(BIOS_WAIT_FLAG_ACTIVE,0); mem_writed(BIOS_WAIT_FLAG_POINTER,RealMake(0,BIOS_WAIT_FLAG_TEMP)); IO_Write(0x70,0xb); IO_Write(0x71,IO_Read(0x71)&~0x40); } } /* Signal EOI to both pics */ IO_Write(0xa0,0x20); IO_Write(0x20,0x20); return 0; }
//TODO Maybe use fflush, but that seemed to f**k up in visual c bool localFile::Read(Bit8u * data,Bit16u * size) { if ((this->flags & 0xf) == OPEN_WRITE) { // check if file opened in write-only mode DOS_SetError(DOSERR_ACCESS_DENIED); return false; } if (last_action==WRITE) fseek(fhandle,ftell(fhandle),SEEK_SET); last_action=READ; *size=(Bit16u)fread(data,1,*size,fhandle); /* Fake harddrive motion. Inspector Gadget with soundblaster compatible */ /* Same for Igor */ /* hardrive motion => unmask irq 2. Only do it when it's masked as unmasking is realitively heavy to emulate */ Bit8u mask = IO_Read(0x21); if(mask & 0x4 ) IO_Write(0x21,mask&0xfb); return true; }
int Flash_Write(ioAddress offset, ioData data) { ioData status = 0; uint32_t timestamp = MicroTime_Get(); IO_Write(CommandRegister, ProgramCommand); IO_Write(offset, data); status = IO_Read(StatusRegister); while ((status & ReadyBit) == 0) { if (MicroTime_Get() - timestamp >= FLASH_WRITE_TIMEOUT_IN_MICROSECONDS) return FLASH_TIMEOUT_ERROR; status = IO_Read(StatusRegister); } if (status != ReadyBit) return writeError(status); if (data != IO_Read(offset)) return FLASH_READ_BACK_ERROR; return FLASH_SUCCESS; }
static int ZFILE_read(ZFILE zfd, char *buf, jint nbytes) { #ifdef WIN32 return (int) IO_Read(zfd, buf, nbytes); #else /* * Calling JVM_Read will return JVM_IO_INTR when Thread.interrupt is called * only on Solaris. Continue reading jar file in this case is the best * thing to do since zip file reading is relatively fast and it is very onerous * for a interrupted thread to deal with this kind of hidden I/O. However, handling * JVM_IO_INTR is tricky and could cause undesired side effect. So we decided * to simply call "read" on Solaris/Linux. See details in bug 6304463. */ return read(zfd, buf, nbytes); #endif }
Bit8u VESA_SetDisplayStart(Bit16u x,Bit16u y) { // TODO wait for retrace in case bl==0x80 Bitu pixels_per_offset; Bitu panning_factor = 1; switch (CurMode->type) { case M_TEXT: case M_LIN4: pixels_per_offset = 16; break; case M_LIN8: panning_factor = 2; // the panning register ignores bit0 in this mode pixels_per_offset = 8; break; case M_LIN15: case M_LIN16: panning_factor = 2; // this may be DOSBox specific pixels_per_offset = 4; break; case M_LIN32: pixels_per_offset = 2; break; default: return VESA_MODE_UNSUPPORTED; } // We would have to divide y by the character height for text modes and // write the remainder to the CRTC preset row scan register, // but VBE2 BIOSes that actually get that far also don't. // Only a VBE3 BIOS got it right. Bitu virtual_screen_width = vga.config.scan_len * pixels_per_offset; Bitu new_start_pixel = virtual_screen_width * y + x; Bitu new_crtc_start = new_start_pixel / (pixels_per_offset/2); Bitu new_panning = new_start_pixel % (pixels_per_offset/2); new_panning *= panning_factor; vga.config.display_start = new_crtc_start; // Setting the panning register is nice as it allows for super smooth // scrolling, but if we hit the retrace pulse there may be flicker as // panning and display start are latched at different times. IO_Read(0x3da); // reset attribute flipflop IO_Write(0x3c0,0x13 | 0x20); // panning register, screen on IO_Write(0x3c0,new_panning); return VESA_SUCCESS; }
int pigaleWindow::load(int pos) {setPigaleError(); QString m; QFileInfo fi(InputFileName); if(!fi.exists() || fi.size() == 0) {m = QString("file -%1- does not exist").arg(InputFileName); if(!ServerExecuting)statusBar()->showMessage(m,2000); LogPrintf("%s\n",(const char *)m.toLatin1()); return -1; } if (!IO_IsMine(InputDriver,(const char *)InputFileName.toLatin1())) {m.sprintf("file -%s- is not a valid %s",(const char *)InputFileName.toLatin1(),IO_Name(InputDriver)); if(!ServerExecuting)statusBar()->showMessage(m,2000); LogPrintf("%s\n",(const char *)m.toLatin1()); return -1; } UndoClear();UndoSave(); int NumRecords =IO_GetNumRecords(InputDriver,(const char *)InputFileName.toLatin1()); if(pos == 1)++(*pGraphIndex); else if(pos == -1)--(*pGraphIndex); if(*pGraphIndex > NumRecords)*pGraphIndex = 1; else if(*pGraphIndex < 1)*pGraphIndex += NumRecords; if(IO_Read(InputDriver,GC,(const char *)InputFileName.toLatin1(),NumRecords,*pGraphIndex) != 0) {m = QString("Could not read:%1").arg(InputFileName); if(!ServerExecuting)statusBar()->showMessage(m,2000); return -2; } if(debug())DebugPrintf("\n**** %s: %d/%d",(const char *)InputFileName.toLatin1(),*pGraphIndex,NumRecords); Prop<bool> eoriented(GC.Set(tedge()),PROP_ORIENTED,false); TopologicalGraph G(GC); UndoSave(); banner(); information(); gw->editor->update(1); return *pGraphIndex; }
static void Tandy_SetupTransfer(PhysPt bufpt,bool isplayback) { Bitu length=real_readw(0x40,0xd0); if (length==0) return; /* nothing to do... */ if ((tandy_sb.port==0) && (tandy_dac.port==0)) return; Bit8u tandy_irq = 7; if (tandy_sb.port) tandy_irq = tandy_sb.irq; else if (tandy_dac.port) tandy_irq = tandy_dac.irq; Bit8u tandy_irq_vector = tandy_irq; if (tandy_irq_vector<8) tandy_irq_vector += 8; else tandy_irq_vector += (0x70-8); /* revector IRQ-handler if necessary */ RealPt current_irq=RealGetVec(tandy_irq_vector); if (current_irq!=tandy_DAC_callback[0]->Get_RealPointer()) { real_writed(0x40,0xd6,current_irq); RealSetVec(tandy_irq_vector,tandy_DAC_callback[0]->Get_RealPointer()); } Bit8u tandy_dma = 1; if (tandy_sb.port) tandy_dma = tandy_sb.dma; else if (tandy_dac.port) tandy_dma = tandy_dac.dma; if (tandy_sb.port) { IO_Write(tandy_sb.port+0xc,0xd0); /* stop DMA transfer */ IO_Write(0x21,IO_Read(0x21)&(~(1<<tandy_irq))); /* unmask IRQ */ IO_Write(tandy_sb.port+0xc,0xd1); /* turn speaker on */ } else { IO_Write(tandy_dac.port,IO_Read(tandy_dac.port)&0x60); /* disable DAC */ IO_Write(0x21,IO_Read(0x21)&(~(1<<tandy_irq))); /* unmask IRQ */ } IO_Write(0x0a,0x04|tandy_dma); /* mask DMA channel */ IO_Write(0x0c,0x00); /* clear DMA flipflop */ if (isplayback) IO_Write(0x0b,0x48|tandy_dma); else IO_Write(0x0b,0x44|tandy_dma); /* set physical address of buffer */ Bit8u bufpage=(Bit8u)((bufpt>>16)&0xff); IO_Write(tandy_dma*2,(Bit8u)(bufpt&0xff)); IO_Write(tandy_dma*2,(Bit8u)((bufpt>>8)&0xff)); switch (tandy_dma) { case 0: IO_Write(0x87,bufpage); break; case 1: IO_Write(0x83,bufpage); break; case 2: IO_Write(0x81,bufpage); break; case 3: IO_Write(0x82,bufpage); break; } real_writeb(0x40,0xd4,bufpage); /* calculate transfer size (respects segment boundaries) */ Bit32u tlength=length; if (tlength+(bufpt&0xffff)>0x10000) tlength=0x10000-(bufpt&0xffff); real_writew(0x40,0xd0,(Bit16u)(length-tlength)); /* remaining buffer length */ tlength--; /* set transfer size */ IO_Write(tandy_dma*2+1,(Bit8u)(tlength&0xff)); IO_Write(tandy_dma*2+1,(Bit8u)((tlength>>8)&0xff)); Bit16u delay=(Bit16u)(real_readw(0x40,0xd2)&0xfff); Bit8u amplitude=(Bit8u)((real_readw(0x40,0xd2)>>13)&0x7); if (tandy_sb.port) { IO_Write(0x0a,tandy_dma); /* enable DMA channel */ /* set frequency */ IO_Write(tandy_sb.port+0xc,0x40); IO_Write(tandy_sb.port+0xc,256-delay*100/358); /* set playback type to 8bit */ if (isplayback) IO_Write(tandy_sb.port+0xc,0x14); else IO_Write(tandy_sb.port+0xc,0x24); /* set transfer size */ IO_Write(tandy_sb.port+0xc,(Bit8u)(tlength&0xff)); IO_Write(tandy_sb.port+0xc,(Bit8u)((tlength>>8)&0xff)); } else {
int main() { //Request IO privileges R01_GetIOPrivileges(); //Get the boot information, retrieve the ACPI table base address //Find the MCFG table //Get the ECAM addresses //Open the list describing which drivers support which hardware UID dst_pid = 0; uint64_t error = 0; uint32_t tmp_key = 0; RetrieveNamespace("initrd", &tmp_key); while(!IsNamespaceRetrieved(tmp_key, &dst_pid, &error)); uint8_t access_key[KEY_BYTES]; uint64_t fd = 0; IO_Open(":pci_devices.txt", FileSystemOpFlag_Read, 0, access_key, dst_pid, &fd); FileSystemDirectoryEntry file_info; IO_GetFileProperties(":pci_devices.txt", &file_info, dst_pid); uint64_t len = file_info.Length; uint64_t addr = 0; uint64_t read_key = 0; uint64_t write_key = 0; IO_AllocateBuffer(&len, &addr, &read_key, &write_key); IO_Read(fd, 0, read_key, file_info.Length, dst_pid); uint32_t str_len = file_info.Length; char *file_ptr = (char*)addr; char *file_end = file_ptr + str_len; //Enumerate PCI devices uint32_t bus = 0; uint32_t device = 0; int dev_index = -1; while(1) { PCI_GetNextDevice(&bus, &device); dev_index++; if(bus != -1 && device != -1) { uint32_t funcs = PCI_GetFuncCount(bus, device); PCI_Device devInfo; for(uint32_t f = 0; f < funcs; f++) { PCI_GetPCIDevice(bus, device, f, &devInfo); char tStr[512]; sprintf(tStr, "B:%x D:%x F:%x DID:%x VID:%x CLS:%x SCLS:%x PIF:%x\r\n", bus, device, f, devInfo.DeviceID, devInfo.VendorID, devInfo.ClassCode, devInfo.SubClassCode, devInfo.ProgIF); int tStr_i = 0; while(tStr[tStr_i]) { outb(0x3f8, tStr[tStr_i++]); } //Check the device information file for this device char *cur_loc = file_ptr; while(cur_loc < file_end) { uint32_t vendor_id = 0; uint32_t device_id = 0; uint32_t class_code = 0; uint32_t subclass_code = 0; uint32_t prog_if = 0; char driver_file[256]; memset(driver_file, 0, 256); driver_file[0] = ':'; sscanf(cur_loc, "%s |%x|%x|%x|%x|%x\n", driver_file + 1, &vendor_id, &device_id, &class_code, &subclass_code, &prog_if); cur_loc = strchr(cur_loc, '\n') + 1; int vendor_m = (vendor_id == devInfo.VendorID || vendor_id == 0xFFFF); int dev_m = (device_id == devInfo.DeviceID || device_id == 0xFFFF); int class_m = (class_code == devInfo.ClassCode || class_code == 0xFFFF); int subclass_m = (subclass_code == devInfo.SubClassCode || subclass_code == 0xFFFF); int prog_if_m = (prog_if == devInfo.ProgIF || prog_if == 0xFFFF); if(vendor_m && dev_m && class_m && subclass_m && prog_if_m) { char devStr[512]; sprintf(devStr, "B:%d D:%d F:%d DID:%x VID:%x", bus, device, f, device_id, vendor_id); uint64_t bar_vals[6]; uint64_t bar_sz[6]; for(int i = 0; i < devInfo.BarCount; i++) { bar_vals[i] = PCI_GetBAR(&devInfo, i); uint64_t sz = PCI_GetBARSize(&devInfo, i); bar_sz[i] = sz; if(bar_vals[i] != 0 && !PCI_IsIOSpaceBAR(&devInfo, i)) { //Setup the mapping R0_AllocateSharedMemory(sz, CachingModeUncachable, MemoryAllocationType_MMap | MemoryAllocationType_Phys, MemoryAllocationFlags_Write | MemoryAllocationFlags_Read | MemoryAllocationFlags_User | MemoryAllocationFlags_Present, bar_vals[i], &bar_vals[i]); GetSharedMemoryKey(bar_vals[i], sz, CachingModeUncachable, MemoryAllocationFlags_Write | MemoryAllocationFlags_Read | MemoryAllocationFlags_User | MemoryAllocationFlags_Present, &bar_vals[i]); } else { bar_vals[i] = 0; } } char bars[512]; sprintf(bars, "B0:%llx B1:%llx B2:%llx B3:%llx B4:%llx B5:%llx", bar_vals[0], bar_vals[1], bar_vals[2], bar_vals[3], bar_vals[4], bar_vals[5]); char *argv[] = { driver_file + 1, devStr, bars }; int devStr_i = 0; while(driver_file[devStr_i]) { outb(0x3f8, driver_file[devStr_i++]); } UID pid = 0; if(StartProcess(driver_file, argv, 3, dst_pid, access_key, 1, &pid) != 0) __asm__("hlt"); break; } } //Load the associated drivers, passing a key to the appropriate shared memory block //Start the driver } } else break; device++; } //while(1); }
Bitu XMS_GetEnabledA20(void) { return (IO_Read(0x92)&2)>0; }
Bitu XMS_EnableA20(bool enable) { Bit8u val = IO_Read (0x92); if (enable) IO_Write(0x92,val | 2); else IO_Write(0x92,val & ~2); return 0; }
int CT_data( unsigned int ctn, unsigned char *dad, unsigned char *sad, unsigned int lc, const unsigned char *cmd, unsigned int *lr, unsigned char *rsp ) { int IretVal; unsigned char ack_byte; /* READER COMMAND */ if (*dad == 1) { /* This command goes to the reader */ *sad = 1; /* Data is going from reader (1) to host (2) */ *dad = 2; /*******************/ /* CT-BCS Commands */ /*******************/ /* Reset - Reset the card and return ATR */ if (cmd[0] == 0x20 && cmd[1] == 0x11) { if (IO_RF2SC_Reset () == FALSE) IretVal = ERR_TRANS; else { /* Read the ATR. */ *lr = IO_Read2 (*lr, rsp); rsp[*lr] = 0x90; rsp[*lr+1] = 0x00; *lr += 2; IretVal = OK; } } /* Request ICC - Turn on reader/card */ else if (cmd[0] == 0x20 && cmd[1] == 0x12) { /* Just turn on the clock */ IO_RF2SC_EN_CLK (TRUE); *lr = 0; IretVal = OK; } /* Eject ICC - Turn off card's clock & Reset Low */ else if (cmd[0] == 0x20 && cmd[1] == 0x15) { reset_low(); /* Reset Low smart card*/ IO_RF2SC_EN_CLK (FALSE); /* Stop clock */ *lr = 0; IretVal = OK; } /* Get Card Status, ICC status Data Object (DO) */ else if (cmd[0] == 0x20 && cmd[1] == 0x13) { if (IO_RF2SC_IsCardInserted ()) *rsp = 5; /* card is present and electrically connected */ else *rsp = 0; /* card not present */ *lr = 1; IretVal = OK; } /* Command sent directly to the card */ else { /* Don't do anything.. */ *lr = 0; IretVal = OK; } } /* CARD COMMAND */ else if (*dad == 0) { /* This command goes to the card */ BYTE sw1, sw2; BYTE get_response[5]; int i, max_len; /* printf("sending command to card... len %d\n", lc); */ *sad = 0; /* Card (0) --> Host (2) */ *dad = 2; IretVal = OK; /* Algoritmo T = 0 implementado como indica el libro Smart Card Handbook 3rd edition, * Autores Rankl & Effing. Chapter 6, Smart Card data transmission, page 403 */ /* Send the command (first five bytes) */ for (i = 0; i < 5; i++) if (!IO_Write (cmd[i])) { IretVal = ERR_TRANS; break; } max_len = *lr; /* Read the card's ACK byte */ *lr = IO_Read (1, &ack_byte); //printf("\nACK de la tarjeta: %02X\n", ack_byte); /*Si el byte ACK de la tarjeta es igual al byte INS mando el resto del comando*/ if (ack_byte == cmd[1]) { /* Send the rest of the command */ for (i = 5; i < lc; i++) { if (!IO_Write (cmd[i])) { IretVal = ERR_TRANS; break; } } IO_Read (1, &sw1); IO_Read (1, &sw2); } else { sw1 = ack_byte; IO_Read (1, &sw2); } //printf("SW1: %02X, SW2: %02X\n", sw1, sw2); switch(sw1){ case 0x90: rsp[0] = sw1; rsp[1] = sw2; *lr = 2; break; case 0x6c: memcpy(get_response, cmd, 5); get_response[4] = sw2; for (i = 0; i < 5; i++) if (!IO_Write (get_response[i])) { IretVal = ERR_TRANS; break; } /* Read the card's second response, if something was sent */ /* CHECK: can there be anything here more than two bytes if it was a long command above? */ *lr = IO_Read (1, &ack_byte); //printf("\nACK de la tarjeta: %02X\n", ack_byte); *lr = IO_Read2 (max_len, rsp); break; default: rsp[0] = sw1; rsp[1] = sw2; *lr = 2; break; } } else { /* This command goes nowhere because the dest. is invalid */ IretVal = ERR_INVALID; } if (IretVal != OK) *lr = 0; return IretVal; }
Bit8u VESA_GetCPUWindow(Bit8u window,Bit16u & address) { if (window) return VESA_FAIL; IO_Write(0x3d4,0x6a); address=IO_Read(0x3d5); return VESA_SUCCESS; }