From: Paul M. <le...@li...> - 2003-05-16 20:57:26
|
This issue was initially brought up in the deviceinfo thread about a month ago, at which point I noted that I had a local script I was playing with to see about doing automatic machtype generation to clean up quite a bit of the include/asm-sh/machvec.h mess. At the moment, the current interface looks like the following: - Add a 1-bit value to sh_machine_vector to flag your current board type - Define MACH_xxx repeatedly through endless ifdefs to determine the current board type (also wrap through the sh_machine_vector struct if CONFIG_SH_GENERIC is set). This approach is ugly for quite a lot of reasons, least of all the fact that everytime a new board is added, structure size changes, and more of these ugly macros are generated. As a solution to this, I've essentially created a stripped-down clone of the ARM tree's mach type generation script. For this interface, I propose that we maintain a master-list of supported boards and their associated CONFIG options in some place like arch/sh/tools/mach-types. As an initial implementation, I have mach-types looking something like this: # # List of boards. # # # MACH_<xxx> CONFIG_<xxx> # SE SH_SOLUTION_ENGINE 7751SE SH_7751_SOLUTION_ENGINE HP600 SH_HP600 HP620 SH_HP620 HP680 SH_HP680 HP690 SH_HP690 HD64461 HD64461 HD64465 HD64465 SH2000 SH_SH2000 SATURN SH_SATURN DREAMCAST SH_DREAMCAST BIGSUR SH_BIGSUR ADX SH_ADX I suppose some more work could be done here to simplify things further (or potentially elaborate some more), but as I said, this is just an initial implementation. This list will then be passed through a script that will be invoked by arch/sh/Makefile early-on (probably at the same time that the symlinks in include/asm-sh are made), and will generate include/asm-sh/machtype.h automatically. This header can then be referenced directly and we can sanely gut most of machvec.h. As an example of an auto-generated machtype.h, I have the following: /* * Automagically generated, don't touch. */ #ifndef __ASM_SH_MACHTYPE_H #define __ASM_SH_MACHTYPE_H /* * We'll use the following MACH_xxx defs for placeholders for * the time being .. these will all go away once sh_machtype is * assigned per-board. * * For now we leave things the way they are for backwards * compatibility. */ /* Mach types */ #ifdef CONFIG_SH_SOLUTION_ENGINE #define MACH_SE 1 #else #define MACH_SE 0 #endif #ifdef CONFIG_SH_7751_SOLUTION_ENGINE #define MACH_7751SE 1 #else #define MACH_7751SE 0 #endif #ifdef CONFIG_SH_HP600 #define MACH_HP600 1 #else #define MACH_HP600 0 #endif #ifdef CONFIG_SH_HP620 #define MACH_HP620 1 #else #define MACH_HP620 0 #endif #ifdef CONFIG_SH_HP680 #define MACH_HP680 1 #else #define MACH_HP680 0 #endif #ifdef CONFIG_SH_HP690 #define MACH_HP690 1 #else #define MACH_HP690 0 #endif #ifdef CONFIG_HD64461 #define MACH_HD64461 1 #else #define MACH_HD64461 0 #endif #ifdef CONFIG_HD64465 #define MACH_HD64465 1 #else #define MACH_HD64465 0 #endif #ifdef CONFIG_SH_SH2000 #define MACH_SH2000 1 #else #define MACH_SH2000 0 #endif #ifdef CONFIG_SH_SATURN #define MACH_SATURN 1 #else #define MACH_SATURN 0 #endif #ifdef CONFIG_SH_DREAMCAST #define MACH_DREAMCAST 1 #else #define MACH_DREAMCAST 0 #endif #ifdef CONFIG_SH_BIGSUR #define MACH_BIGSUR 1 #else #define MACH_BIGSUR 0 #endif #ifdef CONFIG_SH_ADX #define MACH_ADX 1 #else #define MACH_ADX 0 #endif /* Machtype checks */ #define mach_is_se() (MACH_SE) #define mach_is_7751se() (MACH_7751SE) #define mach_is_hp600() (MACH_HP600) #define mach_is_hp620() (MACH_HP620) #define mach_is_hp680() (MACH_HP680) #define mach_is_hp690() (MACH_HP690) #define mach_is_hd64461() (MACH_HD64461) #define mach_is_hd64465() (MACH_HD64465) #define mach_is_sh2000() (MACH_SH2000) #define mach_is_saturn() (MACH_SATURN) #define mach_is_dreamcast() (MACH_DREAMCAST) #define mach_is_bigsur() (MACH_BIGSUR) #define mach_is_adx() (MACH_ADX) #endif /* __ASM_SH_MACHTYPE_H */ Also, if anyone is interested in the script for this, its nothing special, and is more or less just a quick and dirty hack. I've attached that as well, incase anyone wants to look it over. I realize this doesn't fixup the ifdef mess, but as noted in the comments above, its a temporary fix until something like sh_machtype gets introduced, and can then be set in board-specific setup code. If no one has any problems with this, I'll merge it into HEAD in the next few days. Comments? |