/* * Initialize all plugins */ void wdt_plugins_init(uev_ctx_t *ctx, int T) { /* Start file descriptor monitor */ filenr_init(ctx, T); /* Start load average monitor, if enabled */ loadavg_init(ctx, T); /* Start memory leak monitor */ meminfo_init(ctx, T); /* Start process monitor */ pmon_init(ctx, T); }
vaddr_t mips_init(uint64_t argc, uint64_t argv, uint64_t envp, uint64_t cv, char *boot_esym) { uint32_t prid; u_long memlo, memhi, cpuspeed; vaddr_t xtlb_handler; const char *envvar; int i; extern char start[], edata[], end[]; extern char exception[], e_exception[]; extern char *hw_vendor, *hw_prod; extern void xtlb_miss; /* * Make sure we can access the extended address space. * This is not necessary on real hardware, but some emulators * are not aware of this. */ setsr(getsr() | SR_KX | SR_UX); /* * Clear the compiled BSS segment in OpenBSD code. * PMON is supposed to have done this, though. */ bzero(edata, end - edata); /* * Set up early console output. */ prid = cp0_get_prid(); pmon_init((int32_t)argc, (int32_t)argv, (int32_t)envp, (int32_t)cv, prid); cn_tab = &pmoncons; /* * Reserve space for the symbol table, if it exists. */ /* Attempt to locate ELF header and symbol table after kernel. */ if (end[0] == ELFMAG0 && end[1] == ELFMAG1 && end[2] == ELFMAG2 && end[3] == ELFMAG3) { /* ELF header exists directly after kernel. */ ssym = end; esym = boot_esym; ekern = esym; } else { ssym = (char *)(vaddr_t)*(int32_t *)end; if (((long)ssym - (long)end) >= 0 && ((long)ssym - (long)end) <= 0x1000 && ssym[0] == ELFMAG0 && ssym[1] == ELFMAG1 && ssym[2] == ELFMAG2 && ssym[3] == ELFMAG3) { /* Pointers exist directly after kernel. */ esym = (char *)(vaddr_t)*((int32_t *)end + 1); ekern = esym; } else { /* Pointers aren't setup either... */ ssym = NULL; esym = NULL; ekern = end; } } /* * While the kernel supports other processor types than Loongson, * we are currently not expecting to run on a system with a * different processor. Just to be on the safe side, refuse to * run on non-Loongson2 processors for now. */ switch ((prid >> 8) & 0xff) { case MIPS_LOONGSON2: switch (prid & 0xff) { #ifdef CPU_LOONGSON2 #ifdef CPU_LOONGSON2C case 0x00: loongson_ver = 0x2c; break; #endif case 0x02: loongson_ver = 0x2e; break; case 0x03: loongson_ver = 0x2f; break; #endif #ifdef CPU_LOONGSON3 case 0x05: loongson_ver = 0x3a; break; #endif default: break; } } if (loongson_ver == 0) { pmon_printf("This kernel doesn't support processor type 0x%x" ", version %d.%d.\n", (prid >> 8) & 0xff, (prid >> 4) & 0x0f, prid & 0x0f); goto unsupported; }
/* module initialization and will be executed automatically when loading. */ void module_init(){ pmon_init(); }