/*ARGSUSED*/ static PyObject * arch_isainfo(PyObject *self, PyObject *args) { char *buf1; char *buf2; char *buf = NULL; PyObject *robj; buf1 = get_sysinfo(SI_ARCHITECTURE_64); buf2 = get_sysinfo(SI_ARCHITECTURE_32); if (buf1 == NULL && buf2 == NULL) return (NULL); if (buf1 == NULL && buf2) buf = buf2; if (buf2 == NULL && buf1) buf = buf1; if (buf == NULL) { robj = Py_BuildValue("[ss]", buf1, buf2); } else { robj = Py_BuildValue("[s]", buf); } free(buf1); free(buf2); return (robj); }
static void init_app_info() { if ('\0' == g_udpxy_finfo[0]) { (void) snprintf( g_udpxy_finfo, sizeof(g_udpxy_finfo), "%s %s-%d.%d (%s) %s [%s]", g_udpxy_app, VERSION, BUILDNUM, PATCH, BUILD_TYPE, COMPILE_MODE, get_sysinfo(NULL) ); } }
void mk_app_info(const char *appname, char *info, size_t infolen) { assert(info); if ('\0' == *info) { (void) snprintf(info, infolen, "%s %s-%d.%d (%s) %s [%s]", appname, VERSION, BUILDNUM, PATCH, BUILD_TYPE, COMPILE_MODE, get_sysinfo(NULL) ); } }
void show_mems() { struct sysinfo *sinfo = get_sysinfo(); char tmp[20]; lcd_draw_string(9 * 4, 0, "Mem"); sprintf(tmp, "%0.1f/%0.0fM", sinfo->totalram/1024.0/1024.0 - sinfo->freeram/1024.0/1024.0, sinfo->totalram/1024.0/1024.0 ); lcd_draw_string(9 * 4, 128 - 8 * strlen(tmp), tmp); }
int main(int argc, char * const argv[]) { int c; boolean_t fork = B_TRUE; progname = basename(strdup(argv[0])); if ((fmri = (const char *)getenv("SMF_FMRI")) == NULL) fmri = DEFAULT_FMRI; (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); while ((c = getopt(argc, argv, "djn")) != EOF) { switch (c) { case 'd': dlevel = 0xffff; break; case 'j': json = B_TRUE; break; case 'n': fork = B_FALSE; break; default: (void) fprintf(stderr, gettext("Unknown option " "\'%c\'.\n"), c); usage(progname); } } pid = getpid(); if ((main_port = port_create()) == -1) err(EXIT_FAILURE, "port_create() failed"); list_create(&links, sizeof (link_t), offsetof(link_t, node)); VERIFY(get_sysinfo()); lldp_read_config(); signal_init(); get_port_list(); lldp_init(4); cdp_init(4); main_loop(); return (0); }
/*ARGSUSED*/ static PyObject * arch_release(PyObject *self, PyObject *args) { char *buf = NULL; PyObject *robj; buf = get_sysinfo(SI_RELEASE); if (buf == NULL) return (NULL); robj = Py_BuildValue("s", buf); free(buf); return (robj); }
/*ARGSUSED*/ static PyObject * arch_platform(PyObject *self, PyObject *args) { char *buf = NULL; PyObject *robj; buf = get_sysinfo(SI_PLATFORM); if (buf == NULL) return (NULL); robj = Py_BuildValue("s", buf); free(buf); return (robj); }
int main(int argc, char *argv[]) { void *tarfile_addr; size_t tarfile_length; void *elf_file_addr; size_t elf_file_length; void *free_space; uint32_t cr3; char *pfree; kprintf("Loading the Anvil...\n"); parse_cmd_line(argc, argv); cpu_init(); /* * Get all the Grub info now so we can touch memory and it won't matter * too much if we trash it. */ mbi_mem_get_info(); free_space = mbi_module_get_info(&tarfile_addr, &tarfile_length); // free_space = 0x80100000; // tarfile_addr = (uintptr_t)0x80012000; // tarfile_length = 3150336; sysinfo.initrd_info.base_addr = (uintptr_t)tarfile_addr; sysinfo.initrd_info.length = tarfile_length; get_sysinfo(); /* Load the OS. We'll be loading 2 files, the kernel and init */ pfree = free_space; kprintf("\nLoading kernel\n========================\n"); /* Assume the module is a TAR file and search it for the files */ if (tar_search(tarfile_addr, tarfile_length, "anvil-knl", &elf_file_addr, &elf_file_length) == -1) { kprintf("Couldn't untar kernel\n"); return 0; } /* Now load the kernel. It should be a single segment */ if (elf_load(pfree, elf_file_addr, &sysinfo.kernel_program_info) == -1) { return 0; } sysinfo.kernel_program_info.seginfo[0].paddr = (uintptr_t)pfree; /* Skip over the kernel (and an 8 page stack */ pfree += sysinfo.kernel_program_info.seginfo[0].length + 8 * __PAGESIZE; kprintf("\nLoading init\n========================\n"); /* Assume the module is a TAR file and search it for the pieces */ if (tar_search(tarfile_addr, tarfile_length, "init", &elf_file_addr, &elf_file_length) == 0) { /* Load init */ if (elf_load(pfree, elf_file_addr, &sysinfo.init_program_info) == -1) { return 0; } } else { kprintf("init not found, ignoring\n"); } sysinfo.init_program_info.seginfo[0].paddr = (uintptr_t)pfree; sysinfo.init_program_info.seginfo[1].paddr = (uintptr_t)pfree + sysinfo.init_program_info.seginfo[0].length; vbe_init(); cr3 = paging_init(free_space, sysinfo.kernel_program_info.seginfo[0].length); cpu_switch_longmode(cr3); /* * The return value tells the code in boot.S what to do * * 0: just hang * 1: launch 32bit kernel * 2: launch 64bit kernel * * any other value just hang */ return 2; }
long get_uptime() { return get_sysinfo()->uptime; }
unsigned long *get_loads() { return get_sysinfo()->loads; }