Tue Mar 30 02:04:44 2021 UTC ()
Convert walnut to use powerpc/ibm4xx/openbios.
No functional changes.


(rin)
diff -r1.10 -r1.11 src/sys/arch/evbppc/conf/Makefile.walnut.inc
diff -r1.18 -r1.19 src/sys/arch/evbppc/conf/files.walnut
diff -r1.64 -r1.65 src/sys/arch/evbppc/walnut/machdep.c
diff -r1.24 -r0 src/sys/arch/evbppc/walnut/walnut_start.S
diff -r1.24 -r1.25 src/sys/arch/powerpc/include/ibm4xx/cpu.h

cvs diff -r1.10 -r1.11 src/sys/arch/evbppc/conf/Makefile.walnut.inc (expand / switch to unified diff)

--- src/sys/arch/evbppc/conf/Makefile.walnut.inc 2021/03/29 13:12:38 1.10
+++ src/sys/arch/evbppc/conf/Makefile.walnut.inc 2021/03/30 02:04:43 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile.walnut.inc,v 1.10 2021/03/29 13:12:38 rin Exp $ 1# $NetBSD: Makefile.walnut.inc,v 1.11 2021/03/30 02:04:43 rin Exp $
2 2
3MKIMG?= ${HOST_SH} ${THISPPC}/compile/walnut-mkimg.sh 3MKIMG?= ${HOST_SH} ${THISPPC}/compile/walnut-mkimg.sh
4CFLAGS+=-mcpu=405 4CFLAGS+=-mcpu=405
5AFLAGS+=-mcpu=405 5AFLAGS+=-mcpu=405
6TEXTADDR?= 25000 6TEXTADDR?= 25000
7 7
8SYSTEM_FIRST_OBJ= walnut_start.o 8SYSTEM_FIRST_OBJ= locore.o
9SYSTEM_FIRST_SFILE= ${THISPPC}/walnut/walnut_start.S 9SYSTEM_FIRST_SFILE= ${POWERPC}/${PPCDIR}/openbios/locore.S
10 10
11SYSTEM_LD_TAIL_EXTRA_EXTRA+=; \ 11SYSTEM_LD_TAIL_EXTRA_EXTRA+=; \
12 echo ${MKIMG} $@ $@.img ; \ 12 echo ${MKIMG} $@ $@.img ; \
13 OBJDUMP=${OBJDUMP}; OBJCOPY=${OBJCOPY}; STAT=${TOOL_STAT}; \ 13 OBJDUMP=${OBJDUMP}; OBJCOPY=${OBJCOPY}; STAT=${TOOL_STAT}; \
14 export OBJDUMP OBJCOPY STAT; ${MKIMG} $@ $@.img 14 export OBJDUMP OBJCOPY STAT; ${MKIMG} $@ $@.img

cvs diff -r1.18 -r1.19 src/sys/arch/evbppc/conf/files.walnut (expand / switch to unified diff)

--- src/sys/arch/evbppc/conf/files.walnut 2021/03/29 14:21:08 1.18
+++ src/sys/arch/evbppc/conf/files.walnut 2021/03/30 02:04:43 1.19
@@ -1,23 +1,24 @@ @@ -1,23 +1,24 @@
1# $NetBSD: files.walnut,v 1.18 2021/03/29 14:21:08 rin Exp $ 1# $NetBSD: files.walnut,v 1.19 2021/03/30 02:04:43 rin Exp $
2# 2#
3# walnut-specific configuration info 3# walnut-specific configuration info
4 4
5file arch/evbppc/walnut/autoconf.c 5file arch/evbppc/walnut/autoconf.c
6file arch/evbppc/walnut/consinit.c 6file arch/evbppc/walnut/consinit.c
7file arch/evbppc/walnut/machdep.c 7file arch/evbppc/walnut/machdep.c
8file arch/powerpc/ibm4xx/ibm4xx_autoconf.c 8file arch/powerpc/ibm4xx/ibm4xx_autoconf.c
9file arch/powerpc/ibm4xx/ibm40x_machdep.c 9file arch/powerpc/ibm4xx/ibm40x_machdep.c
10file arch/powerpc/ibm4xx/ibm4xx_machdep.c 10file arch/powerpc/ibm4xx/ibm4xx_machdep.c
 11file arch/powerpc/ibm4xx/openbios/openbios.c
11 12
12# Memory Disk for install kernel 13# Memory Disk for install kernel
13file dev/md_root.c memory_disk_hooks 14file dev/md_root.c memory_disk_hooks
14 15
15# Machine-independent SCSI drivers 16# Machine-independent SCSI drivers
16include "dev/scsipi/files.scsipi" 17include "dev/scsipi/files.scsipi"
17 18
18# Machine-independent ATA drivers 19# Machine-independent ATA drivers
19include "dev/ata/files.ata" 20include "dev/ata/files.ata"
20 21
21# Off-chip peripheral bus 22# Off-chip peripheral bus
22device pbus {[addr=-1], [irq=-1]} 23device pbus {[addr=-1], [irq=-1]}
23attach pbus at plb 24attach pbus at plb

cvs diff -r1.64 -r1.65 src/sys/arch/evbppc/walnut/machdep.c (expand / switch to unified diff)

--- src/sys/arch/evbppc/walnut/machdep.c 2021/03/30 01:33:50 1.64
+++ src/sys/arch/evbppc/walnut/machdep.c 2021/03/30 02:04:44 1.65
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.c,v 1.64 2021/03/30 01:33:50 rin Exp $ */ 1/* $NetBSD: machdep.c,v 1.65 2021/03/30 02:04:44 rin Exp $ */
2 2
3/* 3/*
4 * Copyright 2001, 2002 Wasabi Systems, Inc. 4 * Copyright 2001, 2002 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc. 7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -57,27 +57,27 @@ @@ -57,27 +57,27 @@
57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 57 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 58 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 59 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 60 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 61 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 62 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 63 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 64 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 65 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 66 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67 */ 67 */
68 68
69#include <sys/cdefs.h> 69#include <sys/cdefs.h>
70__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.64 2021/03/30 01:33:50 rin Exp $"); 70__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.65 2021/03/30 02:04:44 rin Exp $");
71 71
72#include "opt_compat_netbsd.h" 72#include "opt_compat_netbsd.h"
73#include "opt_ddb.h" 73#include "opt_ddb.h"
74 74
75#include <sys/param.h> 75#include <sys/param.h>
76#include <sys/boot_flag.h> 76#include <sys/boot_flag.h>
77#include <sys/buf.h> 77#include <sys/buf.h>
78#include <sys/bus.h> 78#include <sys/bus.h>
79#include <sys/cpu.h> 79#include <sys/cpu.h>
80#include <sys/device.h> 80#include <sys/device.h>
81#include <sys/exec.h> 81#include <sys/exec.h>
82#include <sys/kernel.h> 82#include <sys/kernel.h>
83#include <sys/ksyms.h> 83#include <sys/ksyms.h>
@@ -98,26 +98,28 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v  @@ -98,26 +98,28 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v
98 98
99#include <machine/powerpc.h> 99#include <machine/powerpc.h>
100#include <machine/walnut.h> 100#include <machine/walnut.h>
101 101
102#include <powerpc/trap.h> 102#include <powerpc/trap.h>
103#include <powerpc/pcb.h> 103#include <powerpc/pcb.h>
104 104
105#include <powerpc/spr.h> 105#include <powerpc/spr.h>
106#include <powerpc/ibm4xx/spr.h> 106#include <powerpc/ibm4xx/spr.h>
107#include <powerpc/ibm4xx/cpu.h> 107#include <powerpc/ibm4xx/cpu.h>
108#include <powerpc/ibm4xx/dcr4xx.h> 108#include <powerpc/ibm4xx/dcr4xx.h>
109#include <powerpc/ibm4xx/ibm405gp.h> 109#include <powerpc/ibm4xx/ibm405gp.h>
110 110
 111#include <powerpc/ibm4xx/openbios.h>
 112
111#include <powerpc/ibm4xx/pci_machdep.h> 113#include <powerpc/ibm4xx/pci_machdep.h>
112 114
113#include <powerpc/pic/picvar.h> 115#include <powerpc/pic/picvar.h>
114 116
115#include <dev/cons.h> 117#include <dev/cons.h>
116#include <dev/pci/pcivar.h> 118#include <dev/pci/pcivar.h>
117#include <dev/pci/pciconf.h> 119#include <dev/pci/pciconf.h>
118 120
119#include "ksyms.h" 121#include "ksyms.h"
120 122
121#if defined(DDB) 123#if defined(DDB)
122#include <powerpc/db_machdep.h> 124#include <powerpc/db_machdep.h>
123#include <ddb/db_extern.h> 125#include <ddb/db_extern.h>
@@ -129,127 +131,78 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v  @@ -129,127 +131,78 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v
129/* 131/*
130 * Global variables used here and there 132 * Global variables used here and there
131 */ 133 */
132struct vm_map *phys_map = NULL; 134struct vm_map *phys_map = NULL;
133 135
134/* 136/*
135 * This should probably be in autoconf! XXX 137 * This should probably be in autoconf! XXX
136 */ 138 */
137char machine[] = MACHINE; /* from <machine/param.h> */ 139char machine[] = MACHINE; /* from <machine/param.h> */
138char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ 140char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */
139 141
140void initppc(vaddr_t, vaddr_t, char *, void *); 142void initppc(vaddr_t, vaddr_t, char *, void *);
141 143
142struct board_cfg_data board_data; 
143 
144void 144void
145initppc(vaddr_t startkernel, vaddr_t endkernel, char *args, void *info_block) 145initppc(vaddr_t startkernel, vaddr_t endkernel, char *args, void *info_block)
146{ 146{
 147 u_int memsize;
 148
147 /* Disable all external interrupts */ 149 /* Disable all external interrupts */
148 mtdcr(DCR_UIC0_BASE + DCR_UIC_ER, 0); 150 mtdcr(DCR_UIC0_BASE + DCR_UIC_ER, 0);
149 151
150 /* Initialize cache info for memcpy, etc. */ 152 /* Setup board from OpenBIOS */
151 cpu_probe_cache(); 153 openbios_board_init(info_block);
152 154 memsize = openbios_board_memsize_get();
153 /* Save info block */ 
154 memcpy(&board_data, info_block, sizeof(board_data)); 
155 
156 ibm40x_memsize_init(board_data.mem_size, startkernel); 
157 155
158 /* Linear map kernel memory */ 156 /* Linear map kernel memory */
159 for (vaddr_t va = 0; va < endkernel; va += TLB_PG_SIZE) { 157 for (vaddr_t va = 0; va < endkernel; va += TLB_PG_SIZE) {
160 ppc4xx_tlb_reserve(va, va, TLB_PG_SIZE, TLB_EX); 158 ppc4xx_tlb_reserve(va, va, TLB_PG_SIZE, TLB_EX);
161 } 159 }
162 160
163 /* Map console after physmem (see pmap_tlbmiss()) */ 161 /* Map console after physmem (see pmap_tlbmiss()) */
164 ppc4xx_tlb_reserve(IBM405GP_UART0_BASE, 162 ppc4xx_tlb_reserve(IBM405GP_UART0_BASE, roundup(memsize, TLB_PG_SIZE),
165 roundup(board_data.mem_size, TLB_PG_SIZE), 
166 TLB_PG_SIZE, TLB_I | TLB_G); 163 TLB_PG_SIZE, TLB_I | TLB_G);
167 164
168 mtspr(SPR_TCR, 0); /* disable all timers */ 165 mtspr(SPR_TCR, 0); /* disable all timers */
169 166
 167 ibm40x_memsize_init(memsize, startkernel);
170 ibm4xx_init(startkernel, endkernel, pic_ext_intr); 168 ibm4xx_init(startkernel, endkernel, pic_ext_intr);
171 169
172#ifdef DEBUG 170#ifdef DEBUG
173 printf("Board config data:\n"); 171 openbios_board_print();
174 printf(" usr_config_ver = %s\n", board_data.usr_config_ver); 
175 printf(" rom_sw_ver = %s\n", board_data.rom_sw_ver); 
176 printf(" mem_size = %u\n", board_data.mem_size); 
177 printf(" mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n", 
178 board_data.mac_address_local[0], board_data.mac_address_local[1], 
179 board_data.mac_address_local[2], board_data.mac_address_local[3], 
180 board_data.mac_address_local[4], board_data.mac_address_local[5]); 
181 printf(" mac_address_pci = %02x:%02x:%02x:%02x:%02x:%02x\n", 
182 board_data.mac_address_pci[0], board_data.mac_address_pci[1], 
183 board_data.mac_address_pci[2], board_data.mac_address_pci[3], 
184 board_data.mac_address_pci[4], board_data.mac_address_pci[5]); 
185 printf(" processor_speed = %u\n", board_data.processor_speed); 
186 printf(" plb_speed = %u\n", board_data.plb_speed); 
187 printf(" pci_speed = %u\n", board_data.pci_speed); 
188#endif 172#endif
189 173
190#ifdef DDB 174#ifdef DDB
191 if (boothowto & RB_KDB) 175 if (boothowto & RB_KDB)
192 Debugger(); 176 Debugger();
193#endif 177#endif
194 178
195 /* 179 /*
196 * Look for the ibm4xx modules in the right place. 180 * Look for the ibm4xx modules in the right place.
197 */ 181 */
198 module_machine = module_machine_ibm4xx; 182 module_machine = module_machine_ibm4xx;
199} 183}
200 184
201/* 185/*
202 * Machine dependent startup code. 186 * Machine dependent startup code.
203 */ 187 */
204 188
205void 189void
206cpu_startup(void) 190cpu_startup(void)
207{ 191{
208 prop_number_t pn; 
209 prop_data_t pd; 
210 192
211 ibm4xx_cpu_startup("Walnut PowerPC 405GP Evaluation Board"); 193 ibm4xx_cpu_startup("Walnut PowerPC 405GP Evaluation Board");
212 194
213 board_info_init(); 195 openbios_board_info_set();
214 
215 pn = prop_number_create_integer(board_data.mem_size); 
216 KASSERT(pn != NULL); 
217 if (prop_dictionary_set(board_properties, "mem-size", pn) == false) 
218 panic("setting mem-size"); 
219 prop_object_release(pn); 
220 
221 pd = prop_data_create_data_nocopy(board_data.mac_address_local, 
222 sizeof(board_data.mac_address_local)); 
223 KASSERT(pd != NULL); 
224 if (prop_dictionary_set(board_properties, "emac0-mac-addr", 
225 pd) == false) 
226 panic("setting emac0-mac-addr"); 
227 prop_object_release(pd); 
228 
229 pd = prop_data_create_data_nocopy(board_data.mac_address_pci, 
230 sizeof(board_data.mac_address_pci)); 
231 KASSERT(pd != NULL); 
232 if (prop_dictionary_set(board_properties, "sip0-mac-addr", 
233 pd) == false) 
234 panic("setting sip0-mac-addr"); 
235 prop_object_release(pd); 
236 
237 pn = prop_number_create_integer(board_data.processor_speed); 
238 KASSERT(pn != NULL); 
239 if (prop_dictionary_set(board_properties, "processor-frequency", 
240 pn) == false) 
241 panic("setting processor-frequency"); 
242 prop_object_release(pn); 
243 196
244 /* 197 /*
245 * Now that we have VM, malloc()s are OK in bus_space. 198 * Now that we have VM, malloc()s are OK in bus_space.
246 */ 199 */
247 bus_space_mallocok(); 200 bus_space_mallocok();
248 fake_mapiodev = 0; 201 fake_mapiodev = 0;
249} 202}
250 203
251int 204int
252ibm4xx_pci_bus_maxdevs(void *v, int busno) 205ibm4xx_pci_bus_maxdevs(void *v, int busno)
253{ 206{
254 207
255 /* 208 /*

File Deleted: src/sys/arch/evbppc/walnut/Attic/walnut_start.S

cvs diff -r1.24 -r1.25 src/sys/arch/powerpc/include/ibm4xx/cpu.h (expand / switch to unified diff)

--- src/sys/arch/powerpc/include/ibm4xx/cpu.h 2021/03/30 01:16:45 1.24
+++ src/sys/arch/powerpc/include/ibm4xx/cpu.h 2021/03/30 02:04:44 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.h,v 1.24 2021/03/30 01:16:45 rin Exp $ */ 1/* $NetBSD: cpu.h,v 1.25 2021/03/30 02:04:44 rin Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Wasabi Systems, Inc. 4 * Copyright 2002 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Eduardo Horvath for Wasabi Systems, Inc. 7 * Written by Eduardo Horvath for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -135,33 +135,14 @@ extern struct pic_ops pic_uic403; @@ -135,33 +135,14 @@ extern struct pic_ops pic_uic403;
135extern struct pic_ops pic_uic0; 135extern struct pic_ops pic_uic0;
136extern struct pic_ops pic_uic1; 136extern struct pic_ops pic_uic1;
137extern struct pic_ops pic_uic2; 137extern struct pic_ops pic_uic2;
138 138
139extern paddr_t msgbuf_paddr; 139extern paddr_t msgbuf_paddr;
140extern vaddr_t msgbuf_vaddr; 140extern vaddr_t msgbuf_vaddr;
141extern char msgbuf[MSGBUFSIZE]; 141extern char msgbuf[MSGBUFSIZE];
142#endif /* _KERNEL */ 142#endif /* _KERNEL */
143 143
144/* Board info dictionary */ 144/* Board info dictionary */
145extern prop_dictionary_t board_properties; 145extern prop_dictionary_t board_properties;
146extern void board_info_init(void); 146extern void board_info_init(void);
147 147
148/*****************************************************************************/ 
149/* THIS CODE IS OBSOLETE. WILL BE REMOVED */ 
150/* 
151 * Board configuration structure from the OpenBIOS. 
152 */ 
153struct board_cfg_data { 
154 unsigned char usr_config_ver[4]; 
155 unsigned char rom_sw_ver[30]; 
156 unsigned int mem_size; 
157 unsigned char mac_address_local[6]; 
158 unsigned char mac_address_pci[6]; 
159 unsigned int processor_speed; 
160 unsigned int plb_speed; 
161 unsigned int pci_speed; 
162}; 
163 
164extern struct board_cfg_data board_data; 
165/*****************************************************************************/ 
166 
167#endif /* _IBM4XX_CPU_H_ */ 148#endif /* _IBM4XX_CPU_H_ */