Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Based on Ocelot Linux port, which is |
| 3 | * Copyright 2001 MontaVista Software Inc. |
| 4 | * Author: jsun@mvista.com or jsun@junsun.net |
| 5 | * |
| 6 | * Copyright 2003 ICT CAS |
| 7 | * Author: Michael Guo <guoyi@ict.ac.cn> |
| 8 | * |
| 9 | * Copyright (C) 2007 Lemote Inc. & Insititute of Computing Technology |
| 10 | * Author: Fuxin Zhang, zhangfx@lemote.com |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License as published by the |
| 14 | * Free Software Foundation; either version 2 of the License, or (at your |
| 15 | * option) any later version. |
| 16 | */ |
| 17 | #include <linux/init.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 18 | #include <linux/bootmem.h> |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 19 | #include <asm/bootinfo.h> |
| 20 | |
| 21 | extern unsigned long bus_clock; |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 22 | extern unsigned long cpu_clock_freq; |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 23 | extern unsigned int memsize, highmemsize; |
| 24 | extern int putDebugChar(unsigned char byte); |
| 25 | |
| 26 | static int argc; |
| 27 | /* pmon passes arguments in 32bit pointers */ |
| 28 | static int *arg; |
| 29 | static int *env; |
| 30 | |
| 31 | const char *get_system_type(void) |
| 32 | { |
| 33 | return "lemote-fulong"; |
| 34 | } |
| 35 | |
| 36 | void __init prom_init_cmdline(void) |
| 37 | { |
| 38 | int i; |
| 39 | long l; |
| 40 | |
| 41 | /* arg[0] is "g", the rest is boot parameters */ |
| 42 | arcs_cmdline[0] = '\0'; |
| 43 | for (i = 1; i < argc; i++) { |
| 44 | l = (long)arg[i]; |
| 45 | if (strlen(arcs_cmdline) + strlen(((char *)l) + 1) |
| 46 | >= sizeof(arcs_cmdline)) |
| 47 | break; |
| 48 | strcat(arcs_cmdline, ((char *)l)); |
| 49 | strcat(arcs_cmdline, " "); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | void __init prom_init(void) |
| 54 | { |
| 55 | long l; |
| 56 | argc = fw_arg0; |
| 57 | arg = (int *)fw_arg1; |
| 58 | env = (int *)fw_arg2; |
| 59 | |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 60 | prom_init_cmdline(); |
| 61 | |
| 62 | if ((strstr(arcs_cmdline, "console=")) == NULL) |
| 63 | strcat(arcs_cmdline, " console=ttyS0,115200"); |
| 64 | if ((strstr(arcs_cmdline, "root=")) == NULL) |
| 65 | strcat(arcs_cmdline, " root=/dev/hda1"); |
| 66 | |
| 67 | #define parse_even_earlier(res, option, p) \ |
| 68 | do { \ |
| 69 | if (strncmp(option, (char *)p, strlen(option)) == 0) \ |
| 70 | res = simple_strtol((char *)p + strlen(option"="), \ |
| 71 | NULL, 10); \ |
| 72 | } while (0) |
| 73 | |
| 74 | l = (long)*env; |
| 75 | while (l != 0) { |
| 76 | parse_even_earlier(bus_clock, "busclock", l); |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 77 | parse_even_earlier(cpu_clock_freq, "cpuclock", l); |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 78 | parse_even_earlier(memsize, "memsize", l); |
| 79 | parse_even_earlier(highmemsize, "highmemsize", l); |
| 80 | env++; |
| 81 | l = (long)*env; |
| 82 | } |
| 83 | if (memsize == 0) |
| 84 | memsize = 256; |
| 85 | |
| 86 | pr_info("busclock=%ld, cpuclock=%ld,memsize=%d,highmemsize=%d\n", |
Ralf Baechle | 348c913 | 2007-07-28 11:46:15 +0100 | [diff] [blame] | 87 | bus_clock, cpu_clock_freq, memsize, highmemsize); |
Songmao Tian | 42d226c | 2007-06-06 14:52:38 +0800 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | void __init prom_free_prom_memory(void) |
| 91 | { |
| 92 | } |
| 93 | |
| 94 | void prom_putchar(char c) |
| 95 | { |
| 96 | putDebugChar(c); |
| 97 | } |