這麼奇怪的 function 也是用很奇怪的 方式 做出來的。
先是..arch/arm/tools/mach-types
# Database of machine macros and numbers # # This file is linux/arch/arm/tools/mach-types # # Up to date versions of this file can be obtained from: # # http://www.arm.linux.org.uk/developer/machines/download.php # # Please do not send patches to this file; it is automatically generated! # To add an entry into this database, please see Documentation/arm/README, # or visit: # # http://www.arm.linux.org.uk/developer/machines/?action=new # # Last update: Sun Feb 19 14:16:29 2012 # # machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number # ebsa110 ARCH_EBSA110 EBSA110 0 riscpc ARCH_RPC RISCPC 1 nexuspci ARCH_NEXUSPCI NEXUSPCI 3 ebsa285 ARCH_EBSA285 EBSA285 4 netwinder ARCH_NETWINDER NETWINDER 5 cats ARCH_CATS CATS 6 tbox ARCH_TBOX TBOX 7 co285 ARCH_CO285 CO285 8 clps7110 ARCH_CLPS7110 CLPS7110 9 archimedes ARCH_ARC ARCHIMEDES 10 a5k ARCH_A5K A5K 11 etoile ARCH_ETOILE ETOILE 12 lacie_nas ARCH_LACIE_NAS LACIE_NAS 13 clps7500 ARCH_CLPS7500 CLPS7500 14 shark ARCH_SHARK SHARK 15 brutus SA1100_BRUTUS BRUTUS 16 personal_server ARCH_PERSONAL_SERVER PERSONAL_SERVER 17 itsy SA1100_ITSY ITSY 18 l7200 ARCH_L7200 L7200 19 pleb SA1100_PLEB PLEB 20 integrator ARCH_INTEGRATOR INTEGRATOR 21 h3600 SA1100_H3600 H3600 22 ..有一堆 support 的列表..
然後..arch/arm/tools/Makefile
# # linux/arch/arm/tools/Makefile # # Copyright (C) 2001 Russell King # include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types @echo ' Generating $@' @mkdir -p $(dir $@) $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }叫 AWK script : gen-mach-types來處理 mach-types 這個檔案。
產生 : include/generated/mach-types.h
/* * This was automagically generated from arch/arm/tools/mach-types! * Do NOT edit */ #ifndef __ASM_ARM_MACH_TYPE_H #define __ASM_ARM_MACH_TYPE_H #ifndef __ASSEMBLY__ /* The type of machine we're running on */ extern unsigned int __machine_arch_type; #endif /* see arch/arm/kernel/arch.c for a description of these */ #define MACH_TYPE_EBSA110 0 #define MACH_TYPE_RISCPC 1 #define MACH_TYPE_NEXUSPCI 3 #define MACH_TYPE_EBSA285 4 #define MACH_TYPE_NETWINDER 5 #define MACH_TYPE_CATS 6 #define MACH_TYPE_TBOX 7 #define MACH_TYPE_CO285 8 #define MACH_TYPE_CLPS7110 9 #define MACH_TYPE_ARCHIMEDES 10 #define MACH_TYPE_A5K 11 #define MACH_TYPE_ETOILE 12 #define MACH_TYPE_LACIE_NAS 13 #define MACH_TYPE_CLPS7500 14 #define MACH_TYPE_SHARK 15 #define MACH_TYPE_BRUTUS 16 #define MACH_TYPE_PERSONAL_SERVER 17 #define MACH_TYPE_ITSY 18 #define MACH_TYPE_L7200 19 #define MACH_TYPE_PLEB 20 #define MACH_TYPE_INTEGRATOR 21 #define MACH_TYPE_H3600 22 #define MACH_TYPE_IXP1200 23 ..... #ifdef CONFIG_ARCH_EBSA110 # ifdef machine_arch_type # undef machine_arch_type # define machine_arch_type __machine_arch_type # else # define machine_arch_type MACH_TYPE_EBSA110 # endif # define machine_is_ebsa110() (machine_arch_type == MACH_TYPE_EBSA110) #else # define machine_is_ebsa110() (0) #endif #ifdef CONFIG_ARCH_RPC # ifdef machine_arch_type # undef machine_arch_type # define machine_arch_type __machine_arch_type # else # define machine_arch_type MACH_TYPE_RISCPC # endif # define machine_is_riscpc() (machine_arch_type == MACH_TYPE_RISCPC) #else # define machine_is_riscpc() (0) #endif #ifdef CONFIG_ARCH_NEXUSPCI # ifdef machine_arch_type # undef machine_arch_type # define machine_arch_type __machine_arch_type # else # define machine_arch_type MACH_TYPE_NEXUSPCI # endif # define machine_is_nexuspci() (machine_arch_type == MACH_TYPE_NEXUSPCI) #else # define machine_is_nexuspci() (0) #endif這樣就產生了所有的 machine_is_xxx()
然後就是 bootloader 傳來 machine_arch_type 這個變數: http://r40eubuntu.blogspot.tw/2013/06/machinearchtype-kernel.html
沒有留言:
張貼留言