2 * arch/sh/kernel/machvec.c
4 * The SuperH machine vector setup handlers, yanked from setup.c
6 * Copyright (C) 1999 Niibe Yutaka
7 * Copyright (C) 2002 - 2007 Paul Mundt
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/init.h>
14 #include <linux/string.h>
15 #include <asm/machvec.h>
16 #include <asm/sections.h>
17 #include <asm/addrspace.h>
18 #include <asm/setup.h>
22 #define MV_NAME_SIZE 32
24 #define for_each_mv(mv) \
25 for ((mv) = (struct sh_machine_vector *)&__machvec_start; \
26 (mv) && (unsigned long)(mv) < (unsigned long)&__machvec_end; \
29 static struct sh_machine_vector
* __init
get_mv_byname(const char *name
)
31 struct sh_machine_vector
*mv
;
34 if (strcasecmp(name
, mv
->mv_name
) == 0)
40 static unsigned int __initdata machvec_selected
;
42 static int __init
early_parse_mv(char *from
)
44 char mv_name
[MV_NAME_SIZE
] = "";
48 struct sh_machine_vector
*mvp
;
50 mv_end
= strchr(from
, ' ');
52 mv_end
= from
+ strlen(from
);
54 mv_comma
= strchr(from
, ',');
55 mv_len
= mv_end
- from
;
56 if (mv_len
> (MV_NAME_SIZE
-1))
57 mv_len
= MV_NAME_SIZE
-1;
58 memcpy(mv_name
, from
, mv_len
);
59 mv_name
[mv_len
] = '\0';
64 /* Boot with the generic vector */
65 if (strcmp(mv_name
, "generic") == 0)
68 mvp
= get_mv_byname(mv_name
);
70 printk("Available vectors:\n\n\t'%s', ", sh_mv
.mv_name
);
72 printk("'%s', ", mvp
->mv_name
);
74 panic("Failed to select machvec '%s' -- halting.\n",
81 early_param("sh_mv", early_parse_mv
);
83 void __init
sh_mv_setup(void)
86 * Only overload the machvec if one hasn't been selected on
87 * the command line with sh_mv=
89 if (!machvec_selected
) {
90 unsigned long machvec_size
;
92 machvec_size
= ((unsigned long)&__machvec_end
-
93 (unsigned long)&__machvec_start
);
96 * Sanity check for machvec section alignment. Ensure
97 * __initmv hasn't been misused.
99 if (machvec_size
% sizeof(struct sh_machine_vector
))
100 panic("machvec misaligned, invalid __initmv use?");
103 * If the machvec hasn't been preselected, use the first
104 * vector (usually the only one) from .machvec.init.
106 if (machvec_size
>= sizeof(struct sh_machine_vector
))
107 sh_mv
= *(struct sh_machine_vector
*)&__machvec_start
;
110 printk(KERN_NOTICE
"Booting machvec: %s\n", get_system_type());
113 * Manually walk the vec, fill in anything that the board hasn't yet
114 * by hand, wrapping to the generic implementation.
116 #define mv_set(elem) do { \
117 if (!sh_mv.mv_##elem) \
118 sh_mv.mv_##elem = generic_##elem; \
121 mv_set(inb
); mv_set(inw
); mv_set(inl
);
122 mv_set(outb
); mv_set(outw
); mv_set(outl
);
124 mv_set(inb_p
); mv_set(inw_p
); mv_set(inl_p
);
125 mv_set(outb_p
); mv_set(outw_p
); mv_set(outl_p
);
127 mv_set(insb
); mv_set(insw
); mv_set(insl
);
128 mv_set(outsb
); mv_set(outsw
); mv_set(outsl
);
131 mv_set(ioport_unmap
);
135 if (!sh_mv
.mv_nr_irqs
)
136 sh_mv
.mv_nr_irqs
= NR_IRQS
;
139 __set_io_port_base(P2SEG
);
141 __set_io_port_base(0);