Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Extracted from arch/m68k/kernel/setup.c. |
| 3 | * Should be properly generalized and put somewhere else. |
| 4 | * Jesper |
| 5 | */ |
| 6 | |
| 7 | #include <linux/types.h> |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/string.h> |
| 10 | #include <linux/init.h> |
| 11 | |
| 12 | #include <asm/setup.h> |
| 13 | #include <asm/bootinfo.h> |
| 14 | |
| 15 | extern char cmd_line[CL_SIZE]; |
| 16 | |
| 17 | extern int num_memory; |
| 18 | extern int m68k_realnum_memory; |
| 19 | extern struct mem_info memory[NUM_MEMINFO]; |
| 20 | extern struct mem_info m68k_memory[NUM_MEMINFO]; |
| 21 | extern struct mem_info ramdisk; |
| 22 | |
| 23 | extern int amiga_parse_bootinfo(const struct bi_record *); |
| 24 | extern int atari_parse_bootinfo(const struct bi_record *); |
| 25 | extern int mac_parse_bootinfo(const struct bi_record *); |
| 26 | |
| 27 | void __init parse_bootinfo(const struct bi_record *record) |
| 28 | { |
| 29 | while (record->tag != BI_LAST) { |
| 30 | int unknown = 0; |
| 31 | const u_long *data = record->data; |
| 32 | switch (record->tag) { |
| 33 | case BI_MACHTYPE: |
| 34 | case BI_CPUTYPE: |
| 35 | case BI_FPUTYPE: |
| 36 | case BI_MMUTYPE: |
| 37 | /* Already set up by head.S */ |
| 38 | break; |
| 39 | |
| 40 | case BI_MEMCHUNK: |
| 41 | if (num_memory < NUM_MEMINFO) { |
| 42 | memory[num_memory].addr = data[0]; |
| 43 | memory[num_memory].size = data[1]; |
| 44 | num_memory++; |
| 45 | |
| 46 | /* FIXME: duplicate for m68k drivers. */ |
| 47 | m68k_memory[m68k_realnum_memory].addr = data[0]; |
| 48 | m68k_memory[m68k_realnum_memory].size = data[1]; |
| 49 | m68k_realnum_memory++; |
| 50 | } else |
| 51 | printk("parse_bootinfo: too many memory chunks\n"); |
| 52 | break; |
| 53 | |
| 54 | case BI_RAMDISK: |
| 55 | ramdisk.addr = data[0]; |
| 56 | ramdisk.size = data[1]; |
| 57 | break; |
| 58 | |
| 59 | case BI_COMMAND_LINE: |
| 60 | strlcpy(cmd_line, (const char *)data, sizeof(cmd_line)); |
| 61 | break; |
| 62 | |
| 63 | default: |
| 64 | if (MACH_IS_AMIGA) |
| 65 | unknown = amiga_parse_bootinfo(record); |
| 66 | else if (MACH_IS_ATARI) |
| 67 | unknown = atari_parse_bootinfo(record); |
| 68 | else if (MACH_IS_MAC) |
| 69 | unknown = mac_parse_bootinfo(record); |
| 70 | else |
| 71 | unknown = 1; |
| 72 | } |
| 73 | if (unknown) |
| 74 | printk("parse_bootinfo: unknown tag 0x%04x ignored\n", |
| 75 | record->tag); |
| 76 | record = (struct bi_record *)((u_long)record+record->size); |
| 77 | } |
| 78 | } |