--- linux-2.6.31.10/arch/mips/metarouter/prom.c 1970-01-01 03:00:00.000000000 +0300 +++ linux-2.6.31.10.new/arch/mips/metarouter/prom.c 2010-04-12 15:54:46.000000000 +0300 @@ -0,0 +1,66 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern char arcs_cmdline[COMMAND_LINE_SIZE]; + +extern unsigned long totalram_pages; +extern unsigned long mips_hpt_frequency; + +void __init prom_init(void) +{ + int argc = fw_arg0; + char **argv = (char **) fw_arg1; + unsigned i; + unsigned offset = strlen(arcs_cmdline); + if (offset > 0) + offset += snprintf(arcs_cmdline + offset, + sizeof(arcs_cmdline) - offset, + " "); + + /* HZ must be parsed here because otherwise it's too late */ + for (i = 0; (i < argc && argv[i] != NULL); i++) { + if (strncmp(argv[i], "HZ=", 3) == 0) { + mips_hpt_frequency = + simple_strtoul(argv[i] + 3, 0, 10); + continue; + } + offset += snprintf(arcs_cmdline + offset, + sizeof(arcs_cmdline) - offset, + "%s ", argv[i]); + } +} + +void __init prom_free_prom_memory(void) +{ + unsigned long addr, end; + extern char _text; + + /* + * Free everything below the kernel itself but leave + * the first page reserved for the exception handlers. + */ + + end = __pa(&_text); + addr = PAGE_SIZE; + + while (addr < end) { + ClearPageReserved(virt_to_page(__va(addr))); + init_page_count(virt_to_page(__va(addr))); + free_page((unsigned long)__va(addr)); + addr += PAGE_SIZE; + ++totalram_pages; + } +} + +unsigned long long sched_clock(void) +{ + return read_c0_count() * 1000000000 / mips_hpt_frequency; +}