static u32_t pci_inw(u16_t port) { u32_t value; int s; if ((s=sys_inw(port, &value)) !=OK) printf("ACPI: warning, sys_inw failed: %d\n", s); return value; }
PUBLIC unsigned pci_inw(U16_t port) { u32_t value; int s; if ((s=sys_inw(port, &value)) !=OK) printf("%s: warning, sys_inw failed: %d\n", DRIVER_NAME, s); return value; }
/* * Transfer words from hardware to a destination buffer using port-based I/O. */ void netdriver_portinw(struct netdriver_data * data, size_t off, long port, size_t size) { uint8_t buf[2]; uint32_t value; size_t chunk; unsigned int i; int r, odd_byte; off = netdriver_prepare_copy(data, off, size, &i); odd_byte = 0; while (size > 0) { chunk = data->iovec[i].iov_size - off; if (chunk > size) chunk = size; assert(chunk > 0); if (odd_byte) { if ((r = sys_safecopyto(data->endpt, data->iovec[i].iov_grant, off, (vir_bytes)&buf[1], 1)) != OK) panic("netdriver: unable to copy data: %d", r); off++; size--; chunk--; } odd_byte = chunk & 1; chunk -= odd_byte; if (chunk > 0) { if ((r = sys_safe_insw(port, data->endpt, data->iovec[i].iov_grant, off, chunk)) != OK) panic("netdriver: port input failed: %d", r); off += chunk; size -= chunk; } if (odd_byte) { if ((r = sys_inw(port, &value)) != OK) panic("netdriver: port input failed: %d", r); *(uint16_t *)buf = (uint16_t)value; if ((r = sys_safecopyto(data->endpt, data->iovec[i].iov_grant, off, (vir_bytes)&buf[0], 1)) != OK) panic("netdriver: unable to copy data: %d", r); size--; } i++; off = 0; } }
/* ** Name: unsigned int inw(unsigned short int port); ** Function: Reads a word from specified i/o port. */ PUBLIC unsigned int inw(unsigned short port) { unsigned int value; int rc; if ((rc = sys_inw(port, &value)) != OK) warning("inw", rc); return value; }
static unsigned my_inw(u16_t port) { u32_t value; int s; if ((s = sys_inw(port, &value)) != OK) printf("RTL8169: warning, sys_inw failed: %d\n", s); return value; }
ACPI_STATUS AcpiOsReadPort ( ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width) { *Value = 0; switch (Width) { case 8: sys_inb(Address, Value); break; case 16: sys_inw(Address, Value); break; case 32: sys_inl(Address, Value); break; } return AE_OK; }
ACPI_STATUS AcpiOsReadPort ( ACPI_IO_ADDRESS Address, UINT32 *Value, UINT32 Width) { *Value = 0; switch (Width) { case 8: sys_inb(Address, Value); break; case 16: sys_inw(Address, Value); break; case 32: sys_inl(Address, Value); break; default: panic("unsupported width: %d", Width); } return AE_OK; }