/* there is input available from the other side. read the input * (from link-level raw socket, or ip connection, or pipe depending on * how we were initialized.) * make sure the message is an ll_shell_ftp message (reject it and * return 0 otherwise). */ static int receive_message(message_t *msg) { struct sockaddr_ll recv_arg; socklen_t recv_arg_len; int result; if (cooked_in_file == NULL) { memset(&recv_arg, 0, sizeof(recv_arg)); recv_arg.sll_family = AF_PACKET; recv_arg.sll_ifindex = get_index.ifr_ifindex; recv_arg.sll_protocol = htons(ETH_P_ALL); recv_arg_len = sizeof(recv_arg); result = recvfrom(packet_socket, (void *) msg, sizeof(*msg), MSG_TRUNC, (struct sockaddr *) &recv_arg, &recv_arg_len); } else if (have_in_pio) { result = pio_read(&in_pio, (void *) msg, sizeof(*msg)); } else { result = read(in_fd, (void *) msg, sizeof(*msg)); } if (result == -1) { if (db[5].d) { fprintf(stderr, "recvfrom errno %d (%s)\n", errno, strerror(errno)); } result = -1; goto done; } if (((unsigned char *) msg)[0] == 0x41) { result = 0; goto done; } if (msg->eth_header.h_proto != htons(0x2985)) { result = 0; goto done; } if (0 != mac_cmp(my_mac_addr, msg->eth_header.h_dest)) { // fprintf(stderr, "rejecting msg not for me.\n"); result = 0; goto done; } if (!server || receiving) { if (0 != mac_cmp(dest_mac_addr, msg->eth_header.h_source)) { // fprintf(stderr, "rejecting msg not for me.\n"); result = 0; goto done; } } done: return result; }
static int nor_read(const struct spi_flash *flash, u32 addr, size_t len, void *buf) { u32 next; size_t done = 0; uintptr_t dma_buf; size_t dma_buf_len; if (!IS_ALIGNED((uintptr_t)buf, SFLASH_DMA_ALIGN)) { next = MIN(ALIGN_UP((uintptr_t)buf, SFLASH_DMA_ALIGN) - (uintptr_t)buf, len); if (pio_read(addr, buf, next)) return -1; done += next; } if (ENV_BOOTBLOCK || ENV_VERSTAGE) { dma_buf = (uintptr_t)_dma_coherent; dma_buf_len = _dma_coherent_size; } else { dma_buf = (uintptr_t)_dram_dma; dma_buf_len = _dram_dma_size; } while (len - done >= SFLASH_DMA_ALIGN) { next = MIN(dma_buf_len, ALIGN_DOWN(len - done, SFLASH_DMA_ALIGN)); if (dma_read(addr + done, buf + done, next, dma_buf, dma_buf_len)) return -1; done += next; } next = len - done; if (next > 0 && pio_read(addr + done, buf + done, next)) return -1; return 0; }
void ows_process_cmds() { switch(ows_recv()) { case 0xF5: /* PIO ACCESS READ */ pio_read(); break; case 0x5A: /* PIO ACCESS WRITE */ pio_write(); break; default: break; } }
int main() { unsigned char status_reg = 0, error_reg = 1; char ptr[512]={0}; printf("%x\n",get_drive_head(0,0)); printf("%x\n",test(0xAB)); printf("%x\n",test1(0xBA)); printf("%x\n",test2(0xCA)); printf("ptr=%x %x\n",ptr,pio_read(0xA,0xB,0xC,0xD,ptr)); printf("%x\n",0xC+0x4); printf("%x\n",0x10+0x4); status_reg = 1; // status_reg |= (1<<7); // Set BSY if(status_check(0, error_reg, status_reg) == 0) { printf("status_check:: no error\n"); } if(bit_test(status_reg)==1) { printf("bit_test:: error\n"); } else { printf("bit_test:: no error\n"); } return 0; }
static void dwmmc_intr(void *arg) { struct mmc_command *cmd; struct dwmmc_softc *sc; uint32_t reg; sc = arg; DWMMC_LOCK(sc); cmd = sc->curcmd; /* First handle SDMMC controller interrupts */ reg = READ4(sc, SDMMC_MINTSTS); if (reg) { dprintf("%s 0x%08x\n", __func__, reg); if (reg & DWMMC_CMD_ERR_FLAGS) { WRITE4(sc, SDMMC_RINTSTS, DWMMC_CMD_ERR_FLAGS); dprintf("cmd err 0x%08x cmd 0x%08x\n", reg, cmd->opcode); cmd->error = MMC_ERR_TIMEOUT; } if (reg & DWMMC_DATA_ERR_FLAGS) { WRITE4(sc, SDMMC_RINTSTS, DWMMC_DATA_ERR_FLAGS); dprintf("data err 0x%08x cmd 0x%08x\n", reg, cmd->opcode); cmd->error = MMC_ERR_FAILED; if (!sc->use_pio) { dma_done(sc, cmd); dma_stop(sc); } } if (reg & SDMMC_INTMASK_CMD_DONE) { dwmmc_cmd_done(sc); sc->cmd_done = 1; WRITE4(sc, SDMMC_RINTSTS, SDMMC_INTMASK_CMD_DONE); } if (reg & SDMMC_INTMASK_ACD) { sc->acd_rcvd = 1; WRITE4(sc, SDMMC_RINTSTS, SDMMC_INTMASK_ACD); } if (reg & SDMMC_INTMASK_DTO) { sc->dto_rcvd = 1; WRITE4(sc, SDMMC_RINTSTS, SDMMC_INTMASK_DTO); } if (reg & SDMMC_INTMASK_CD) { /* XXX: Handle card detect */ WRITE4(sc, SDMMC_RINTSTS, SDMMC_INTMASK_CD); } } if (sc->use_pio) { if (reg & (SDMMC_INTMASK_RXDR|SDMMC_INTMASK_DTO)) { pio_read(sc, cmd); } if (reg & (SDMMC_INTMASK_TXDR|SDMMC_INTMASK_DTO)) { pio_write(sc, cmd); } } else { /* Now handle DMA interrupts */ reg = READ4(sc, SDMMC_IDSTS); if (reg) { dprintf("dma intr 0x%08x\n", reg); if (reg & (SDMMC_IDINTEN_TI | SDMMC_IDINTEN_RI)) { WRITE4(sc, SDMMC_IDSTS, (SDMMC_IDINTEN_TI | SDMMC_IDINTEN_RI)); WRITE4(sc, SDMMC_IDSTS, SDMMC_IDINTEN_NI); dma_done(sc, cmd); } } } dwmmc_tasklet(sc); DWMMC_UNLOCK(sc); }
static uint32_t pm1ab_io_read(__unused struct acrn_vm *vm, uint16_t addr, size_t width) { return pio_read(addr, width); }