| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: machdep.c,v 1.350 2017/04/03 17:36:17 christos Exp $ */ | | 1 | /* $NetBSD: machdep.c,v 1.351 2017/08/15 09:26:56 maya Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988 University of Utah. | | 4 | * Copyright (c) 1988 University of Utah. |
5 | * Copyright (c) 1982, 1990 The Regents of the University of California. | | 5 | * Copyright (c) 1982, 1990 The Regents of the University of California. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * the Systems Programming Group of the University of Utah Computer | | 9 | * the Systems Programming Group of the University of Utah Computer |
10 | * Science Department. | | 10 | * Science Department. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -64,27 +64,27 @@ | | | @@ -64,27 +64,27 @@ |
64 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 64 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
65 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 65 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
66 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | | 66 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
67 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 67 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
68 | * | | 68 | * |
69 | */ | | 69 | */ |
70 | /* | | 70 | /* |
71 | * from: Utah $Hdr: machdep.c 1.63 91/04/24$ | | 71 | * from: Utah $Hdr: machdep.c 1.63 91/04/24$ |
72 | * | | 72 | * |
73 | * @(#)machdep.c 7.16 (Berkeley) 6/3/91 | | 73 | * @(#)machdep.c 7.16 (Berkeley) 6/3/91 |
74 | */ | | 74 | */ |
75 | | | 75 | |
76 | #include <sys/cdefs.h> | | 76 | #include <sys/cdefs.h> |
77 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.350 2017/04/03 17:36:17 christos Exp $"); | | 77 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.351 2017/08/15 09:26:56 maya Exp $"); |
78 | | | 78 | |
79 | #include "opt_adb.h" | | 79 | #include "opt_adb.h" |
80 | #include "opt_copy_symtab.h" | | 80 | #include "opt_copy_symtab.h" |
81 | #include "opt_ddb.h" | | 81 | #include "opt_ddb.h" |
82 | #include "opt_ddbparam.h" | | 82 | #include "opt_ddbparam.h" |
83 | #include "opt_kgdb.h" | | 83 | #include "opt_kgdb.h" |
84 | #include "opt_modular.h" | | 84 | #include "opt_modular.h" |
85 | #include "opt_compat_netbsd.h" | | 85 | #include "opt_compat_netbsd.h" |
86 | #include "akbd.h" | | 86 | #include "akbd.h" |
87 | #include "macfb.h" | | 87 | #include "macfb.h" |
88 | #include "zsc.h" | | 88 | #include "zsc.h" |
89 | | | 89 | |
90 | #include <sys/param.h> | | 90 | #include <sys/param.h> |
| @@ -862,32 +862,30 @@ static char *envbuf = NULL; | | | @@ -862,32 +862,30 @@ static char *envbuf = NULL; |
862 | | | 862 | |
863 | /* | | 863 | /* |
864 | * getenvvars: Grab a few useful variables | | 864 | * getenvvars: Grab a few useful variables |
865 | */ | | 865 | */ |
866 | | | 866 | |
867 | void | | 867 | void |
868 | getenvvars(u_long flag, char *buf) | | 868 | getenvvars(u_long flag, char *buf) |
869 | { | | 869 | { |
870 | extern u_long bootdev; | | 870 | extern u_long bootdev; |
871 | extern u_long macos_boottime, MacOSROMBase; | | 871 | extern u_long macos_boottime, MacOSROMBase; |
872 | extern long macos_gmtbias; | | 872 | extern long macos_gmtbias; |
873 | int root_scsi_id; | | 873 | int root_scsi_id; |
874 | u_long root_ata_dev; | | 874 | u_long root_ata_dev; |
875 | #ifdef __ELF__ | | | |
876 | int i; | | 875 | int i; |
877 | Elf_Ehdr *ehdr; | | 876 | Elf_Ehdr *ehdr; |
878 | Elf_Shdr *shp; | | 877 | Elf_Shdr *shp; |
879 | vaddr_t minsym; | | 878 | vaddr_t minsym; |
880 | #endif | | | |
881 | | | 879 | |
882 | /* | | 880 | /* |
883 | * If flag & 0x80000000 == 0, then we're booting with the old booter | | 881 | * If flag & 0x80000000 == 0, then we're booting with the old booter |
884 | * and we should freak out. | | 882 | * and we should freak out. |
885 | */ | | 883 | */ |
886 | if ((flag & 0x80000000) == 0) { | | 884 | if ((flag & 0x80000000) == 0) { |
887 | /* Freak out; print something if that becomes available */ | | 885 | /* Freak out; print something if that becomes available */ |
888 | } else | | 886 | } else |
889 | envbuf = buf; | | 887 | envbuf = buf; |
890 | | | 888 | |
891 | /* These next two should give us mapped video & serial */ | | 889 | /* These next two should give us mapped video & serial */ |
892 | /* We need these for pre-mapping graybars & echo, but probably */ | | 890 | /* We need these for pre-mapping graybars & echo, but probably */ |
893 | /* only on MacII or LC. -- XXX */ | | 891 | /* only on MacII or LC. -- XXX */ |
| @@ -980,57 +978,52 @@ getenvvars(u_long flag, char *buf) | | | @@ -980,57 +978,52 @@ getenvvars(u_long flag, char *buf) |
980 | ROMBase = (void *)getenv("ROMBASE"); | | 978 | ROMBase = (void *)getenv("ROMBASE"); |
981 | if (ROMBase == (void *)0) { | | 979 | if (ROMBase == (void *)0) { |
982 | ROMBase = (void *)ROMBASE; | | 980 | ROMBase = (void *)ROMBASE; |
983 | } | | 981 | } |
984 | MacOSROMBase = (unsigned long)ROMBase; | | 982 | MacOSROMBase = (unsigned long)ROMBase; |
985 | TimeDBRA = getenv("TIMEDBRA"); | | 983 | TimeDBRA = getenv("TIMEDBRA"); |
986 | ADBDelay = (u_short)getenv("ADBDELAY"); | | 984 | ADBDelay = (u_short)getenv("ADBDELAY"); |
987 | HwCfgFlags = getenv("HWCFGFLAGS"); | | 985 | HwCfgFlags = getenv("HWCFGFLAGS"); |
988 | HwCfgFlags2 = getenv("HWCFGFLAG2"); | | 986 | HwCfgFlags2 = getenv("HWCFGFLAG2"); |
989 | HwCfgFlags3 = getenv("HWCFGFLAG3"); | | 987 | HwCfgFlags3 = getenv("HWCFGFLAG3"); |
990 | ADBReInit_JTBL = getenv("ADBREINIT_JTBL"); | | 988 | ADBReInit_JTBL = getenv("ADBREINIT_JTBL"); |
991 | mrg_ADBIntrPtr = (void *)getenv("ADBINTERRUPT"); | | 989 | mrg_ADBIntrPtr = (void *)getenv("ADBINTERRUPT"); |
992 | | | 990 | |
993 | #ifdef __ELF__ | | | |
994 | /* | | 991 | /* |
995 | * Check the ELF headers. | | 992 | * Check the ELF headers. |
996 | */ | | 993 | */ |
997 | | | 994 | |
998 | ehdr = (void *)getenv("MARK_SYM"); | | 995 | ehdr = (void *)getenv("MARK_SYM"); |
999 | if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0 || | | 996 | if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0 || |
1000 | ehdr->e_ident[EI_CLASS] != ELFCLASS32) { | | 997 | ehdr->e_ident[EI_CLASS] != ELFCLASS32) { |
1001 | return; | | 998 | return; |
1002 | } | | 999 | } |
1003 | | | 1000 | |
1004 | /* | | 1001 | /* |
1005 | * Find the end of the symbols and strings. | | 1002 | * Find the end of the symbols and strings. |
1006 | */ | | 1003 | */ |
1007 | | | 1004 | |
1008 | minsym = ~0; | | 1005 | minsym = ~0; |
1009 | shp = (Elf_Shdr *)(end + ehdr->e_shoff); | | 1006 | shp = (Elf_Shdr *)(end + ehdr->e_shoff); |
1010 | for (i = 0; i < ehdr->e_shnum; i++) { | | 1007 | for (i = 0; i < ehdr->e_shnum; i++) { |
1011 | if (shp[i].sh_type != SHT_SYMTAB && | | 1008 | if (shp[i].sh_type != SHT_SYMTAB && |
1012 | shp[i].sh_type != SHT_STRTAB) { | | 1009 | shp[i].sh_type != SHT_STRTAB) { |
1013 | continue; | | 1010 | continue; |
1014 | } | | 1011 | } |
1015 | minsym = MIN(minsym, (vaddr_t)end + shp[i].sh_offset); | | 1012 | minsym = MIN(minsym, (vaddr_t)end + shp[i].sh_offset); |
1016 | } | | 1013 | } |
1017 | | | 1014 | |
1018 | symsize = 1; | | 1015 | symsize = 1; |
1019 | ssym = (int *)ehdr; | | 1016 | ssym = (int *)ehdr; |
1020 | #else | | | |
1021 | symsize = *(int *)&end; | | | |
1022 | ssym = ((int *)&end) + 1; | | | |
1023 | #endif | | | |
1024 | } | | 1017 | } |
1025 | | | 1018 | |
1026 | static long | | 1019 | static long |
1027 | getenv(const char *str) | | 1020 | getenv(const char *str) |
1028 | { | | 1021 | { |
1029 | /* | | 1022 | /* |
1030 | * Returns the value of the environment variable "str". | | 1023 | * Returns the value of the environment variable "str". |
1031 | * | | 1024 | * |
1032 | * Format of the buffer is "var=val\0var=val\0...\0var=val\0\0". | | 1025 | * Format of the buffer is "var=val\0var=val\0...\0var=val\0\0". |
1033 | * | | 1026 | * |
1034 | * Returns 0 if the variable is not there, and 1 if the variable is | | 1027 | * Returns 0 if the variable is not there, and 1 if the variable is |
1035 | * there without an "=val". | | 1028 | * there without an "=val". |
1036 | */ | | 1029 | */ |