STATIC_INLINE_EMUL_NETBSD void write_timezone(unsigned_word addr, struct timezone tz, cpu *processor, unsigned_word cia) { H2T(tz.tz_minuteswest); H2T(tz.tz_dsttime); emul_write_buffer(&tz, addr, sizeof(tz), processor, cia); }
STATIC_INLINE_EMUL_NETBSD void write_timeval(unsigned_word addr, struct timeval t, cpu *processor, unsigned_word cia) { H2T(t.tv_sec); H2T(t.tv_usec); emul_write_buffer(&t, addr, sizeof(t), processor, cia); }
STATIC_INLINE_EMUL_NETBSD void write_direntries(unsigned_word addr, char *buf, int nbytes, cpu *processor, unsigned_word cia) { while (nbytes > 0) { struct dirent *out; struct dirent *in = (struct dirent*)buf; ASSERT(in->d_reclen <= nbytes); out = (struct dirent*)zalloc(in->d_reclen); memcpy(out/*dest*/, in/*src*/, in->d_reclen); H2T(out->d_fileno); H2T(out->d_reclen); H2T(out->d_type); H2T(out->d_namlen); emul_write_buffer(out, addr, in->d_reclen, processor, cia); nbytes -= in->d_reclen; addr += in->d_reclen; buf += in->d_reclen; free(out); } }
static void hw_data_init_data_callback(device *me) { unsigned_word addr = device_find_integer_property(me, "real-address"); const device_property *data = device_find_property(me, "data"); const char *instance_spec = (device_find_property(me, "instance") != NULL ? device_find_string_property(me, "instance") : NULL); device_instance *instance = NULL; if (data == NULL) device_error(me, "missing property <data>\n"); if (instance_spec != NULL) instance = tree_instance(me, instance_spec); switch (data->type) { case integer_property: { unsigned_cell buf = device_find_integer_property(me, "data"); H2T(buf); if (instance == NULL) { if (device_dma_write_buffer(device_parent(me), &buf, 0 /*address-space*/, addr, sizeof(buf), /*nr-bytes*/ 1 /*violate ro*/) != sizeof(buf)) device_error(me, "Problem storing integer 0x%x at 0x%lx\n", (unsigned)buf, (unsigned long)addr); } else { if (device_instance_seek(instance, 0, addr) < 0 || device_instance_write(instance, &buf, sizeof(buf)) != sizeof(buf)) device_error(me, "Problem storing integer 0x%x at 0x%lx of instance %s\n", (unsigned)buf, (unsigned long)addr, instance_spec); } } break; default: device_error(me, "Write of this data is not yet implemented\n"); break; } if (instance != NULL) device_instance_delete(instance); }
STATIC_INLINE_EMUL_NETBSD void write_rusage(unsigned_word addr, struct rusage rusage, cpu *processor, unsigned_word cia) { H2T(rusage.ru_utime.tv_sec); /* user time used */ H2T(rusage.ru_utime.tv_usec); H2T(rusage.ru_stime.tv_sec); /* system time used */ H2T(rusage.ru_stime.tv_usec); H2T(rusage.ru_maxrss); /* integral max resident set size */ H2T(rusage.ru_ixrss); /* integral shared text memory size */ H2T(rusage.ru_idrss); /* integral unshared data size */ H2T(rusage.ru_isrss); /* integral unshared stack size */ H2T(rusage.ru_minflt); /* page reclaims */ H2T(rusage.ru_majflt); /* page faults */ H2T(rusage.ru_nswap); /* swaps */ H2T(rusage.ru_inblock); /* block input operations */ H2T(rusage.ru_oublock); /* block output operations */ H2T(rusage.ru_msgsnd); /* messages sent */ H2T(rusage.ru_msgrcv); /* messages received */ H2T(rusage.ru_nsignals); /* signals received */ H2T(rusage.ru_nvcsw); /* voluntary context switches */ H2T(rusage.ru_nivcsw); /* involuntary context switches */ emul_write_buffer(&rusage, addr, sizeof(rusage), processor, cia); }
STATIC_INLINE_EMUL_NETBSD void write_statfs(unsigned_word addr, struct statfs buf, cpu *processor, unsigned_word cia) { H2T(buf.f_type); H2T(buf.f_flags); H2T(buf.f_bsize); H2T(buf.f_iosize); H2T(buf.f_blocks); H2T(buf.f_bfree); H2T(buf.f_bavail); H2T(buf.f_files); H2T(buf.f_ffree); H2T(buf.f_fsid.val[0]); H2T(buf.f_fsid.val[1]); H2T(buf.f_owner); /* f_spare[4]; */ /* f_fstypename[MFSNAMELEN]; */ /* f_mntonname[MNAMELEN]; */ /* f_mntfromname[MNAMELEN]; */ emul_write_buffer(&buf, addr, sizeof(buf), processor, cia); }
STATIC_INLINE_EMUL_NETBSD void write_stat(unsigned_word addr, struct stat buf, cpu *processor, unsigned_word cia) { H2T(buf.st_dev); H2T(buf.st_ino); H2T(buf.st_mode); H2T(buf.st_nlink); H2T(buf.st_uid); H2T(buf.st_gid); H2T(buf.st_size); H2T(buf.st_atime); /* H2T(buf.st_spare1); */ H2T(buf.st_mtime); /* H2T(buf.st_spare2); */ H2T(buf.st_ctime); /* H2T(buf.st_spare3); */ #ifdef AC_STRUCT_ST_RDEV H2T(buf.st_rdev); #endif #ifdef AC_STRUCT_ST_BLKSIZE H2T(buf.st_blksize); #endif #ifdef AC_STRUCT_ST_BLOCKS H2T(buf.st_blocks); #endif #if WITH_NetBSD_HOST H2T(buf.st_flags); H2T(buf.st_gen); #endif emul_write_buffer(&buf, addr, sizeof(buf), processor, cia); }