2 * linux/arch/h8300/kernel/setup.c
4 * Copyleft ()) 2000 James D. Schettine {james@telos-systems.com}
5 * Copyright (C) 1999,2000 Greg Ungerer (gerg@snapgear.com)
6 * Copyright (C) 1998,1999 D. Jeff Dionne <jeff@lineo.ca>
7 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
8 * Copyright (C) 1995 Hamish Macdonald
9 * Copyright (C) 2000 Lineo Inc. (www.lineo.com)
10 * Copyright (C) 2001 Lineo, Inc. <www.lineo.com>
12 * H8/300 porting Yoshinori Sato <ysato@users.sourceforge.jp>
16 * This file handles the architecture-dependent parts of system setup
19 #include <linux/config.h>
20 #include <linux/kernel.h>
21 #include <linux/sched.h>
22 #include <linux/delay.h>
23 #include <linux/interrupt.h>
26 #include <linux/console.h>
27 #include <linux/genhd.h>
28 #include <linux/errno.h>
29 #include <linux/string.h>
30 #include <linux/major.h>
31 #include <linux/bootmem.h>
32 #include <linux/seq_file.h>
34 #include <asm/setup.h>
37 #ifdef CONFIG_BLK_DEV_INITRD
38 #include <asm/pgtable.h>
41 #if defined(__H8300H__)
45 #if defined(__H8300S__)
49 #if defined(CONFIG_INTELFLASH)
55 #define STUBSIZE 0xc000;
57 unsigned long rom_length;
58 unsigned long memory_start;
59 unsigned long memory_end;
61 struct task_struct *_current_task;
63 char command_line[512];
64 char saved_command_line[512];
66 extern int _stext, _etext, _sdata, _edata, _sbss, _ebss, _end;
67 extern int _ramstart, _ramend;
68 extern char _target_name[];
69 extern void h8300_gpio_init(void);
71 #if (defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)) \
72 && defined(CONFIG_GDB_MAGICPRINT)
73 /* printk with gdb service */
74 static void gdb_console_output(struct console *c, const char *msg, unsigned len)
76 for (; len > 0; len--) {
78 "jsr @0xc4"::"r"(*msg++):"er2");
83 * Setup initial baud/bits/parity. We do two things here:
84 * - construct a cflag setting for the first rs_open()
85 * - initialize the serial port
86 * Return non-zero if we didn't find a serial port.
88 static int __init gdb_console_setup(struct console *co, char *options)
93 static const struct console gdb_console = {
95 .write = gdb_console_output,
97 .setup = gdb_console_setup,
98 .flags = CON_PRINTBUFFER,
103 void __init setup_arch(char **cmdline_p)
107 memory_start = (unsigned long) &_ramstart;
109 /* allow for ROMFS on the end of the kernel */
110 if (memcmp((void *)(memory_start + BLKOFFSET), "-rom1fs-", 8) == 0) {
111 #if defined(CONFIG_BLK_DEV_INITRD)
112 initrd_start = memory_start += BLKOFFSET;
113 initrd_end = memory_start += be32_to_cpu(((unsigned long *) (memory_start))[2]);
115 memory_start += BLKOFFSET;
116 memory_start += be32_to_cpu(((unsigned long *) memory_start)[2]);
119 memory_start = PAGE_ALIGN(memory_start);
120 #if !defined(CONFIG_BLKDEV_RESERVE)
121 memory_end = (unsigned long) &_ramend; /* by now the stack is part of the init task */
122 #if defined(CONFIG_GDB_DEBUG)
123 memory_end -= STUBSIZE;
126 if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) &&
127 (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS)
128 /* overlap userarea */
129 memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS;
132 init_mm.start_code = (unsigned long) &_stext;
133 init_mm.end_code = (unsigned long) &_etext;
134 init_mm.end_data = (unsigned long) &_edata;
135 init_mm.brk = (unsigned long) 0;
137 #if (defined(CONFIG_H8300H_SIM) || defined(CONFIG_H8S_SIM)) && defined(CONFIG_GDB_MAGICPRINT)
138 register_console((struct console *)&gdb_console);
141 printk(KERN_INFO "\r\n\nuClinux " CPU "\n");
142 printk(KERN_INFO "Target Hardware: %s\n",_target_name);
143 printk(KERN_INFO "Flat model support (C) 1998,1999 Kenneth Albanowski, D. Jeff Dionne\n");
144 printk(KERN_INFO "H8/300 series support by Yoshinori Sato <ysato@users.sourceforge.jp>\n");
147 printk(KERN_DEBUG "KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x "
148 "BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext,
149 (int) &_sdata, (int) &_edata,
150 (int) &_sbss, (int) &_ebss);
151 printk(KERN_DEBUG "KERNEL -> ROMFS=0x%06x-0x%06x MEM=0x%06x-0x%06x "
152 "STACK=0x%06x-0x%06x\n",
153 (int) &_ebss, (int) memory_start,
154 (int) memory_start, (int) memory_end,
155 (int) memory_end, (int) &_ramend);
158 #ifdef CONFIG_DEFAULT_CMDLINE
159 /* set from default command line */
160 if (*command_line == '\0')
161 strcpy(command_line,CONFIG_KERNEL_COMMAND);
163 /* Keep a copy of command line */
164 *cmdline_p = &command_line[0];
165 memcpy(saved_command_line, command_line, sizeof(saved_command_line));
166 saved_command_line[sizeof(saved_command_line)-1] = 0;
169 if (strlen(*cmdline_p))
170 printk(KERN_DEBUG "Command line: '%s'\n", *cmdline_p);
174 * give all the memory to the bootmap allocator, tell it to put the
175 * boot mem_map at the start of memory
177 bootmap_size = init_bootmem_node(
179 memory_start >> PAGE_SHIFT, /* map goes here */
180 PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
181 memory_end >> PAGE_SHIFT);
183 * free the usable memory, we have to make sure we do not free
184 * the bootmem bitmap so we then reserve it after freeing it :-)
186 free_bootmem(memory_start, memory_end - memory_start);
187 reserve_bootmem(memory_start, bootmap_size);
189 * get kmalloc into gear
194 printk(KERN_DEBUG "Done setup_arch\n");
199 * Get CPU information for use by the procfs.
202 static int show_cpuinfo(struct seq_file *m, void *v)
209 mode = *(volatile unsigned char *)MDCR & 0x07;
211 clockfreq = CONFIG_CPU_CLOCK;
213 seq_printf(m, "CPU:\t\t%s (mode:%d)\n"
214 "Clock:\t\t%lu.%1luMHz\n"
215 "BogoMips:\t%lu.%02lu\n"
216 "Calibration:\t%lu loops\n",
218 clockfreq/100,clockfreq%100,
219 (loops_per_jiffy*HZ)/500000,((loops_per_jiffy*HZ)/5000)%100,
220 (loops_per_jiffy*HZ));
225 static void *c_start(struct seq_file *m, loff_t *pos)
227 return *pos < NR_CPUS ? ((void *) 0x12345678) : NULL;
230 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
233 return c_start(m, pos);
236 static void c_stop(struct seq_file *m, void *v)
240 struct seq_operations cpuinfo_op = {
244 .show = show_cpuinfo,