int nec7210_write(gpib_board_t *board, nec7210_private_t *priv, uint8_t *buffer, size_t length, int send_eoi, size_t *bytes_written) { int retval = 0; *bytes_written = 0; clear_bit( DEV_CLEAR_BN, &priv->state ); //XXX if(send_eoi) { length-- ; /* save the last byte for sending EOI */ } if(length > 0) { if(0 /*priv->dma_channel*/) { // isa dma transfer /* dma writes are unreliable since they can't recover from bus errors * (which happen when ATN is asserted in the middle of a write) */ #if 0 retval = dma_write(board, priv, buffer, length); if(retval < 0) return retval; else count += retval; #endif }else { // PIO transfer size_t num_bytes; retval = pio_write(board, priv, buffer, length, &num_bytes); *bytes_written += num_bytes; if(retval < 0) { return retval; } } } if(send_eoi) { size_t num_bytes; /*send EOI */ write_byte(priv, AUX_SEOI, AUXMR); retval = pio_write(board, priv, &buffer[*bytes_written], 1, &num_bytes); *bytes_written += num_bytes; if(retval < 0) { return retval; } } return retval; }
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; } }
/* using the fd and if_index from device, send the message. * this is a low-level routine used only to send non-cloud messages. * but, it is called to send packets out of the cloud (eth or wlan ap) * and also to pass them along within the cloud. */ int sendum(byte *message, int msg_len, device_t *device) { struct sockaddr_ll send_arg; int result; // noncloud_message_count++; if (db[25].d || db[26].d) { short_print_io_stats(eprintf, stderr); } check_msg_count(); if (db[15].d) { // DEBUG_SPARSE_PRINT( ddprintf("sending payload message "); fn_print_message(eprintf, stderr, (unsigned char *) message, msg_len); // ) } if (db[14].d && is_wlan(device)) { ddprintf("sendum..\n"); } if (use_pipes) { result = pio_write(&device->out_pio, message, msg_len); if (db[14].d && is_wlan(device)) { ddprintf("sendum; "); pio_print(stderr, &device->out_pio); } } else { memset(&send_arg, 0, sizeof(send_arg)); send_arg.sll_family = AF_PACKET; send_arg.sll_halen = 6; memset(send_arg.sll_addr, 0, sizeof(send_arg.sll_addr)); send_arg.sll_ifindex = device->if_index; if (db[1].d) { ddprintf("do the sendto..\n"); } block_timer_interrupts(SIG_BLOCK); result = sendto(device->fd, message, msg_len, 0, (struct sockaddr *) &send_arg, sizeof(send_arg)); block_timer_interrupts(SIG_UNBLOCK); if (db[1].d) { ddprintf("sendto result: %d\n", result); } } if (db[1].d) { DEBUG_SPARSE_PRINT( ddprintf("sending to "); print_device(eprintf, stderr, device); ) }
static void pm1ab_io_write(struct acrn_vm *vm, uint16_t addr, size_t width, uint32_t v) { static uint32_t pm1a_cnt_ready = 0U; bool to_write = true; if (width == 2U) { uint8_t val = get_slp_typx(v); if ((addr == vm->pm.sx_state_data->pm1a_cnt.address) && (val == vm->pm.sx_state_data->s3_pkg.val_pm1a) && (s3_enabled(v) != 0U)) { if (vm->pm.sx_state_data->pm1b_cnt.address != 0UL) { pm1a_cnt_ready = v; } else { enter_s3(vm, v, 0U); } to_write = false; } else if ((addr == vm->pm.sx_state_data->pm1b_cnt.address) && (val == vm->pm.sx_state_data->s3_pkg.val_pm1b) && (s3_enabled(v) != 0U)) { if (pm1a_cnt_ready != 0U) { enter_s3(vm, pm1a_cnt_ready, v); pm1a_cnt_ready = 0U; } else { /* the case broke ACPI spec */ pr_err("PM1B_CNT write error!"); } to_write = false; } } if (to_write) { pio_write(v, addr, width); } }
/* send an eth_beacon out our cat-5 internal LAN interface via using a * link-level raw socket. the message contains this box's "name" * (wireless interface mac address), and in the packet header it contains * our LAN interface mac address and the eth_beacon protocol short int. */ static void send_beacon() { int result; #if DEBUG0 printf("hi from send_beacon..\n"); #endif mac_copy((mac_address_ptr_t) &buf[sizeof(struct ethhdr)], my_mac_addr); mac_copy((mac_address_ptr_t) &buf[sizeof(struct ethhdr) + sizeof(mac_address_t)], name_mac_addr); ethhdr_p->h_proto = htons(0x2984); mac_copy(ethhdr_p->h_dest, other_mac_addr); mac_copy(ethhdr_p->h_source, my_mac_addr); if (cooked_out_file == NULL) { memset(&send_arg, 0, sizeof(send_arg)); send_arg.sll_family = AF_PACKET; send_arg.sll_ifindex = eth_if_index; send_arg.sll_halen = 6; mac_copy(send_arg.sll_addr, other_mac_addr); result = sendto(packet_socket, buf, sizeof(struct ethhdr) + 12, 0, (struct sockaddr *) &send_arg, sizeof(send_arg)); } else { result = pio_write(out_pio, buf, sizeof(struct ethhdr) + 12); } if (result == -1) { fprintf(stderr, "sendto errno %d(%s)\n", errno, strerror(errno)); } else { #if DEBUG0 printf("sendto result %d\n", result); #endif } }
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); }
/* send buf to the other side. if we are using a link-level raw socket, * set up the "sendto" arguments to shove * the bits through the raw socket interface. * if an IP connection, do the "write()". * if a pipe, send the bytes through the pipe. * * if the buffer is too * long to fit in one sendto message, break the * buffer up into multiple chunks and send them separately. */ static void send_message(unsigned char *buf, int buflen, msg_type_t msg_type) { int result; message_t msg; if (db[1].d) { printf("hi from send_message.. sending %d bytes\n", buflen); } if (cooked_out_file == NULL) { memset(&send_arg, 0, sizeof(send_arg)); send_arg.sll_family = AF_PACKET; send_arg.sll_ifindex = eth_if_index; send_arg.sll_halen = 6; mac_copy(send_arg.sll_addr, dest_mac_addr); } msg.eth_header.h_proto = htons(0x2985); mac_copy(msg.eth_header.h_dest, dest_mac_addr); mac_copy(msg.eth_header.h_source, my_mac_addr); while (buflen > 0) { int next_gulp; if (buflen > BUF_LEN) { next_gulp = BUF_LEN; } else { next_gulp = buflen; } memcpy((void *) msg.msg_body, buf, next_gulp); msg.msg_body_len = next_gulp; msg.msg_type = msg_type; buf += next_gulp; buflen -= next_gulp; if (db[1].d) { fprintf(stderr, "sending %ld bytes..\n", (unsigned long) &(msg.msg_body[next_gulp]) - (unsigned long) &msg); } if (cooked_out_file == NULL) { result = sendto(packet_socket, (void *) &msg, (char *) &(msg.msg_body[next_gulp]) - (char *) &msg, 0, (struct sockaddr *) &send_arg, sizeof(send_arg)); } else if (have_out_pio) { result = pio_write(out_pio, (void *) &msg, (char *) &(msg.msg_body[next_gulp]) - (char *) &msg); } else { result = write(out_fd, (void *) &msg, (char *) &(msg.msg_body[next_gulp]) - (char *) &msg); } if (result == -1) { com_errors++; if (db[5].d) { fprintf(stderr, "sendto/write errno %d (%s)\n", errno, strerror(errno)); } } else { #if DEBUG0 printf("sendto result %d\n", result); #endif } } }