apr_status_t h2_mplx_process(h2_mplx *m, int stream_id, const h2_request *req, int eos, h2_stream_pri_cmp *cmp, void *ctx) { apr_status_t status; AP_DEBUG_ASSERT(m); if (m->aborted) { return APR_ECONNABORTED; } status = apr_thread_mutex_lock(m->lock); if (APR_SUCCESS == status) { h2_io *io = open_io(m, stream_id); io->request = req; io->request_body = !eos; if (eos) { status = h2_io_in_close(io); } h2_tq_add(m->q, io->id, cmp, ctx); ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, m->c, "h2_mplx(%ld-%d): process", m->c->id, stream_id); H2_MPLX_IO_IN(APLOG_TRACE2, m, io, "h2_mplx_process"); apr_thread_mutex_unlock(m->lock); } if (status == APR_SUCCESS) { workers_register(m); } return status; }
apr_status_t h2_mplx_process(h2_mplx *m, int stream_id, const h2_request *req, h2_stream_pri_cmp *cmp, void *ctx) { apr_status_t status; int was_empty = 0; int acquired; AP_DEBUG_ASSERT(m); if ((status = enter_mutex(m, &acquired)) == APR_SUCCESS) { if (m->aborted) { status = APR_ECONNABORTED; } else { h2_io *io = open_io(m, stream_id); io->request = req; if (!io->request->body) { status = h2_io_in_close(io); } was_empty = h2_tq_empty(m->q); h2_tq_add(m->q, io->id, cmp, ctx); ap_log_cerror(APLOG_MARK, APLOG_TRACE1, status, m->c, "h2_mplx(%ld-%d): process", m->c->id, stream_id); H2_MPLX_IO_IN(APLOG_TRACE2, m, io, "h2_mplx_process"); } leave_mutex(m, acquired); } if (status == APR_SUCCESS && was_empty) { workers_register(m); } return status; }
int main(int argc, char **argv) { struct holder holder = {}; if (argc < 2) errx(1, "bad arguments"); open_io(&holder, argv[1]); holder.samples_count = holder.ininfo.samplerate / 100; /* do we have enough data? no = clamp the graph */ if (holder.width > holder.samples_count / 2) holder.width = holder.samples_count / 2; prepare_fftw(&holder); decode(&holder); destroy_fftw(&holder); close_io(&holder); return 0; }
int file_open(const char *filename) { load_fd=open_io(filename); if(load_fd >= 0) seek_io(load_fd, 0); return load_fd>-1; }
void *load_elf(char *spec) { #if 0 int fd; void *entry=NULL; int i, lszz_offs, elf_offs; char buf[128]; // , *addr; Elf_ehdr ehdr; Elf_phdr *phdr; size_t s; if( (fd=open_io(spec)) == -1 ) return NULL; if( (elf_offs=find_elf(fd)) < 0 ) { printk("----> %s is not an ELF image\n", buf ); return NULL; } if( !(phdr=elf_readhdrs(fd, 0, &ehdr)) ) { printk("elf32_readhdrs failed\n"); return NULL; } (unsigned long long *)entry = ehdr.e_entry; lszz_offs = elf_offs; for( i=0; i<ehdr.e_phnum; i++ ) { s = MIN( phdr[i].p_filesz, phdr[i].p_memsz ); seek_io( fd, elf_offs + phdr[i].p_offset ); /* printk("filesz: %08lX memsz: %08lX p_offset: %08lX p_vaddr %08lX\n", phdr[i].p_filesz, phdr[i].p_memsz, phdr[i].p_offset, phdr[i].p_vaddr ); */ if( phdr[i].p_vaddr != phdr[i].p_paddr ) printk("WARNING: ELF segment virtual addr != physical addr\n"); lszz_offs = MAX( lszz_offs, elf_offs + phdr[i].p_offset + phdr[i].p_filesz ); if( !s ) continue; printk("ELF ROM-section loaded at %08lX (size %08lX)\n", (unsigned long)phdr[i].p_vaddr, (unsigned long)phdr[i].p_memsz); } free( phdr ); return entry; #else return NULL; #endif }
int linux_load(struct sys_info *info, const char *file, const char *cmdline) { struct linux_header hdr; struct linux_params *params; uint32_t kern_addr, kern_size; char *initrd_file = NULL; fd = open_io(file); if (fd == -1) { return -1; } kern_addr = load_linux_header(&hdr); if (kern_addr == 0) return LOADER_NOT_SUPPORT; params = phys_to_virt(LINUX_PARAM_LOC); init_linux_params(params, &hdr); set_memory_size(params, info); initrd_file = parse_command_line(cmdline, phys_to_virt(COMMAND_LINE_LOC)); set_command_line_loc(params, &hdr); kern_size = load_linux_kernel(&hdr, kern_addr); if (kern_size == 0) { if (initrd_file) free(initrd_file); return -1; } if (initrd_file) { if (load_initrd(&hdr, info, kern_addr+kern_size, params, initrd_file) != 0) { free(initrd_file); return -1; } free(initrd_file); } hardware_setup(); start_linux(kern_addr, params); return 0; }
static void briq_startup( void ) { const char *paths[] = { "hd:0,\\zImage.chrp", NULL }; const char *args[] = { "root=/dev/hda2 console=ttyS0,115200", NULL }; unsigned long entry; int i, fd; for( i=0; paths[i]; i++ ) { if( (fd=open_io(paths[i])) == -1 ) continue; (void) load_elf_rom( &entry, fd ); close_io( fd ); encode_bootpath( paths[i], args[i] ); update_nvram(); transfer_control_to_elf( entry ); /* won't come here */ } printk("*** Boot failure! No secondary bootloader specified ***\n"); }
static int load_initrd(struct linux_header *hdr, struct sys_info *info, uint32_t kern_end, struct linux_params *params, const char *initrd_file) { uint32_t max; uint32_t start, end, size; uint64_t forced; fd = open_io(initrd_file); if (fd == -1) { printf("Can't open initrd: %s\n", initrd_file); return -1; } #if 0 if (using_devsize) { printf("Attempt to load up to end of device as initrd; " "specify the image size\n"); return -1; } #endif size = file_size(); /* Find out the kernel's restriction on how high the initrd can be * placed */ if (hdr->protocol_version >= 0x203) max = hdr->initrd_addr_max; else max = 0x38000000; /* Hardcoded value for older kernels */ /* FILO itself is at the top of RAM. (relocated) * So, try putting initrd just below us. */ end = virt_to_phys(_start); if (end > max) end = max; /* If "mem=" option is given, we have to put the initrd within * the specified range. */ if (forced_memsize) { forced = forced_memsize; if (forced > max) forced = max; /* If the "mem=" is lower, it's easy */ if (forced <= end) end = forced; else { /* Otherwise, see if we can put it above us */ if (virt_to_phys(_end) + size <= forced) end = forced; /* Ok */ } } start = end - size; start &= ~0xfff; /* page align */ end = start + size; debug("start=%#x end=%#x\n", start, end); if (start < kern_end) { printf("Initrd is too big to fit in memory\n"); return -1; } printf("Loading initrd... "); if (read_io(fd, phys_to_virt(start), size) != size) { printf("Can't read initrd\n"); return -1; } printf("ok\n"); params->initrd_start = start; params->initrd_size = size; close_io(fd); return 0; }
int file_open(const char *filename) { load_fd=open_io(filename); /* if(load_fd!=-1) */ seek_io(load_fd, 0); return load_fd>-1; }