update (Blue Swirl)
[qemu/qemu_0_9_1_stable.git] / pc-bios / proll.patch
blob2fc27991ad8f3cdfe21dd5bcb0cb2cecb64a5409
1 diff -ruN proll_18.orig/Makefile proll-patch8/Makefile
2 --- proll_18.orig/Makefile 2002-09-13 14:16:59.000000000 +0000
3 +++ proll-patch8/Makefile 2004-11-13 15:50:49.000000000 +0000
4 @@ -4,6 +4,7 @@
5 make -C krups-ser all
6 make -C espresso all
7 make -C espresso-ser all
8 + make -C qemu all
10 clean:
11 make -C mrcoffee clean
12 @@ -11,3 +12,4 @@
13 make -C krups-ser clean
14 make -C espresso clean
15 make -C espresso-ser clean
16 + make -C qemu clean
17 diff -ruN proll_18.orig/qemu/Makefile proll-patch8/qemu/Makefile
18 --- proll_18.orig/qemu/Makefile 1970-01-01 00:00:00.000000000 +0000
19 +++ proll-patch8/qemu/Makefile 2005-03-02 16:41:50.000000000 +0000
20 @@ -0,0 +1,122 @@
22 +# proll:
23 +# qemu/Makefile - make PROLL for QEMU
24 +# $Id: proll.patch,v 1.4 2005/04/06 20:45:26 bellard Exp $
26 +# Copyright 1999 Pete Zaitcev
27 +# This is Free Software is licensed under terms of GNU General Public License.
30 +CC = gcc
32 +#CROSS = /usr/local/sparc/bin/sparc-sun-linux-
33 +CROSS = sparc-unknown-linux-gnu-
35 +CROSSCC = $(CROSS)gcc
36 +CROSSLD = $(CROSS)ld
37 +CROSSNM = $(CROSS)nm
39 +RM = /bin/rm -f
40 +ELFTOAOUT = elftoaout
43 +SRC = ../src
45 +# Due to remapping algorithm PROLBASE should be algned on PMD.
46 +# We make PROLBASE a define instead of using _start because we
47 +# want to shift it to form a PGD entry. A relocatable label will not work.
48 +# Linux kernel expects us to be at LINUX_OPPROM_BEGVM <asm-sparc/openprom.h>.
49 +PROLBASE = 0xffd00000
50 +PROLRODATA = 0xffd07000
51 +PROLDATA = 0xffd09000
52 +PROLSIZE = 240*1024
54 +# Linux
55 +# Fixed %g6 is for arch/sparc/kernel/head.S, it seems ok w/o -ffixed-g6.
56 +# Kernel uses -fcall-used-g5 -fcall-used-g7, we probably do not need them.
57 +# __ANSI__ is supposed to be on by default but it is not.
58 +CFLAGS = -O2 -Wall -DPROLBASE=$(PROLBASE) -DPROLDATA=$(PROLDATA) -DPROLRODATA=$(PROLRODATA) -D__ANSI__=1 -I$(SRC) -mcpu=hypersparc -g -DQEMU
59 +ASFLAGS = -D__ASSEMBLY__ -I$(SRC) -DPROLRODATA=$(PROLRODATA) -DPROLDATA=$(PROLDATA) -DPROLSIZE=$(PROLSIZE) -g
60 +# Solaris or Linux/i386 cross compilation
61 +#CFLAGS = -Iinclude -O
63 +LDFLAGS = -N -Ttext $(PROLBASE) --section-start .rodata=$(PROLRODATA) -Tdata $(PROLDATA) -Tbss $(PROLDATA)
65 +ALL = proll.aout
66 +PROLLEXE = proll.elf
68 +OBJS = head.o wuf.o wof.o main.o $(CONSOLE) \
69 + printf.o le.o system_qemu.o iommu.o \
70 + arp.o netinit.o bootp.o packet.o tftp.o udp.o sched_4m.o openprom.o \
71 + vconsole.o hconsole.o rconsole.o vcons_zs.o
73 +all: $(ALL)
75 +$(PROLLEXE): $(OBJS)
76 + $(CROSSLD) $(LDFLAGS) -o $(PROLLEXE) $(OBJS)
78 +head.o: head.S $(SRC)/phys_jj.h \
79 + $(SRC)/asi.h $(SRC)/psr.h $(SRC)/crs.h
80 + $(CROSSCC) $(ASFLAGS) -DPROLBASE=$(PROLBASE) -o $*.o -c $*.S
82 +main.o: main.c $(SRC)/asi.h $(SRC)/pgtsrmmu.h $(SRC)/iommu.h \
83 + $(SRC)/phys_jj.h $(SRC)/vconsole.h $(SRC)/version.h $(SRC)/general.h \
84 + $(SRC)/net.h $(SRC)/romlib.h $(SRC)/netpriv.h $(SRC)/arpa.h $(SRC)/system.h
85 + $(CROSSCC) $(CFLAGS) -c $*.c
86 +openprom.o: openprom.c $(SRC)/openprom.h $(SRC)/general.h $(SRC)/romlib.h \
87 + $(SRC)/vconsole.h $(SRC)/system.h $(SRC)/phys_jj.h
88 + $(CROSSCC) $(CFLAGS) -c $*.c
90 +system_qemu.o: system_qemu.c $(SRC)/vconsole.h $(SRC)/pgtsrmmu.h \
91 + $(SRC)/timer.h $(SRC)/general.h $(SRC)/net.h $(SRC)/romlib.h $(SRC)/asi.h \
92 + $(SRC)/netpriv.h $(SRC)/arpa.h $(SRC)/system.h $(SRC)/crs.h
93 + $(CROSSCC) $(CFLAGS) -c $*.c
94 +iommu.o: $(SRC)/iommu.c $(SRC)/pgtsrmmu.h $(SRC)/phys_jj.h $(SRC)/iommu.h \
95 + $(SRC)/vconsole.h $(SRC)/general.h $(SRC)/romlib.h $(SRC)/system.h $(SRC)/asi.h
96 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
97 +vconsole.o: $(SRC)/vconsole.c $(SRC)/vconsole.h $(SRC)/hconsole.h
98 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
99 +vcons_zs.o: $(SRC)/vcons_zs.c $(SRC)/vconsole.h $(SRC)/system.h
100 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
101 +hconsole.o: $(SRC)/hconsole.c $(SRC)/hconsole.h $(SRC)/rconsole.h $(SRC)/phys_jj.h
102 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
103 +rconsole.o: $(SRC)/rconsole.c $(SRC)/rconsole.h
104 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
105 +printf.o: $(SRC)/printf.c
106 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
107 +le.o: $(SRC)/le.c $(SRC)/dma.h $(SRC)/system.h $(SRC)/netpriv.h $(SRC)/romlib.h $(SRC)/general.h $(SRC)/net.h $(SRC)/phys_jj.h
108 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
110 +arp.o: $(SRC)/arp.c $(SRC)/general.h $(SRC)/net.h $(SRC)/romlib.h $(SRC)/netpriv.h $(SRC)/arp.h
111 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
112 +netinit.o: $(SRC)/netinit.c $(SRC)/general.h $(SRC)/net.h $(SRC)/romlib.h $(SRC)/netpriv.h $(SRC)/arp.h $(SRC)/ip.h $(SRC)/udp.h
113 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
114 +tftp.o: $(SRC)/tftp.c $(SRC)/general.h $(SRC)/net.h $(SRC)/arpa.h $(SRC)/romlib.h $(SRC)/tftp.h
115 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
116 +udp.o: $(SRC)/udp.c $(SRC)/general.h $(SRC)/net.h $(SRC)/romlib.h $(SRC)/netpriv.h $(SRC)/arp.h $(SRC)/ip.h $(SRC)/udp.h
117 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
118 +packet.o: $(SRC)/packet.c $(SRC)/general.h $(SRC)/net.h $(SRC)/romlib.h $(SRC)/netpriv.h
119 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
120 +sched_4m.o: $(SRC)/sched_4m.c $(SRC)/system.h $(SRC)/general.h $(SRC)/romlib.h $(SRC)/phys_jj.h
121 + $(CROSSCC) $(CFLAGS) -c $(SRC)/$*.c
122 +bootp.o: $(SRC)/bootp.c $(SRC)/general.h $(SRC)/net.h \
123 + $(SRC)/arpa.h $(SRC)/romlib.h $(SRC)/system.h $(SRC)/bootp.h
124 + $(CROSSCC) $(CFLAGS) -DNOBPEXT=1 -c $(SRC)/$*.c
126 +wuf.o: $(SRC)/wuf.S
127 + $(CROSSCC) $(ASFLAGS) -o $*.o -c $(SRC)/$*.S
128 +wof.o: $(SRC)/wof.S
129 + $(CROSSCC) $(ASFLAGS) -o $*.o -c $(SRC)/$*.S
131 +#genlab.o: genlab.c
132 +# $(CC) -c $*.c
134 +#genlab: genlab.o
135 +# $(CC) -o genlab genlab.o
137 +clean:
138 + $(RM) $(OBJS)
139 + $(RM) $(PROLLEXE) proll.aout
141 +proll.aout: $(PROLLEXE)
142 + $(ELFTOAOUT) -o proll.aout $(PROLLEXE)
143 diff -ruN proll_18.orig/qemu/head.S proll-patch8/qemu/head.S
144 --- proll_18.orig/qemu/head.S 1970-01-01 00:00:00.000000000 +0000
145 +++ proll-patch8/qemu/head.S 2005-03-02 15:30:47.000000000 +0000
146 @@ -0,0 +1,539 @@
147 +/**
148 + ** Standalone startup code for Linux PROM emulator.
149 + ** Copyright 1999 Pete A. Zaitcev
150 + ** This code is licensed under GNU General Public License.
151 + **/
153 + * $Id: proll.patch,v 1.4 2005/04/06 20:45:26 bellard Exp $
154 + */
156 +#include <psr.h>
157 +#include <asi.h>
158 +#include <crs.h>
159 +/* #include <asm/head.h> */ /* Trap entries. Do not use. */
160 +#include "phys_jj.h"
162 +#define C_LABEL(name) name
163 +#define REGWIN_SZ 0x40
165 +#define WRITE_PAUSE nop; nop; nop; /* Have to do this after %wim/%psr chg */
167 + /* 22 is 24-2, (va)>>(SRMMU_PGDIR_SHIFT-PTESIZESHFT) */
168 +#define VATOPGDOFF(va) (((va)>>22)&0x3FC)
169 +#define VATOPMDOFF(va) (((va)>>16)&0xFC)
171 +#define NOP_INSN 0x01000000 /* Used to patch sparc_save_state */
173 +/* Here are some trap goodies */
175 +#if 0
176 +/* Generic trap entry. */
177 +#define TRAP_ENTRY(type, label) \
178 + rd %psr, %l0; b label; rd %wim, %l3; nop;
179 +#endif
181 +/* Data/text faults. */
182 +#define SRMMU_TFAULT rd %psr, %l0; rd %wim, %l3; b C_LABEL(srmmu_fault); mov 1, %l7;
183 +#define SRMMU_DFAULT rd %psr, %l0; rd %wim, %l3; b C_LABEL(srmmu_fault); mov 0, %l7;
185 +#if 0
186 +/* This is for traps we should NEVER get. */
187 +#define BAD_TRAP(num) \
188 + rd %psr, %l0; mov num, %l7; b bad_trap_handler; rd %wim, %l3;
190 +/* This is for traps when we want just skip the instruction which caused it */
191 +#define SKIP_TRAP(type, name) \
192 + jmpl %l2, %g0; rett %l2 + 4; nop; nop;
194 +/* Notice that for the system calls we pull a trick. We load up a
195 + * different pointer to the system call vector table in %l7, but call
196 + * the same generic system call low-level entry point. The trap table
197 + * entry sequences are also HyperSparc pipeline friendly ;-)
198 + */
200 +/* Software trap for Linux system calls. */
201 +#define LINUX_SYSCALL_TRAP \
202 + sethi %hi(C_LABEL(sys_call_table)), %l7; \
203 + or %l7, %lo(C_LABEL(sys_call_table)), %l7; \
204 + b linux_sparc_syscall; \
205 + rd %psr, %l0;
207 +/* Software trap for SunOS4.1.x system calls. */
208 +#define SUNOS_SYSCALL_TRAP \
209 + rd %psr, %l0; \
210 + sethi %hi(C_LABEL(sunos_sys_table)), %l7; \
211 + b linux_sparc_syscall; \
212 + or %l7, %lo(C_LABEL(sunos_sys_table)), %l7;
214 +/* Software trap for Slowaris system calls. */
215 +#define SOLARIS_SYSCALL_TRAP \
216 + b solaris_syscall; \
217 + rd %psr, %l0; \
218 + nop; \
219 + nop;
221 +#define INDIRECT_SOLARIS_SYSCALL(x) \
222 + mov x, %g1; \
223 + b solaris_syscall; \
224 + rd %psr, %l0; \
225 + nop;
227 +#define BREAKPOINT_TRAP \
228 + b breakpoint_trap; \
229 + rd %psr,%l0; \
230 + nop; \
231 + nop;
233 +/* Software trap for Sparc-netbsd system calls. */
234 +#define NETBSD_SYSCALL_TRAP \
235 + sethi %hi(C_LABEL(sys_call_table)), %l7; \
236 + or %l7, %lo(C_LABEL(sys_call_table)), %l7; \
237 + b bsd_syscall; \
238 + rd %psr, %l0;
240 +/* The Get Condition Codes software trap for userland. */
241 +#define GETCC_TRAP \
242 + b getcc_trap_handler; mov %psr, %l0; nop; nop;
244 +/* The Set Condition Codes software trap for userland. */
245 +#define SETCC_TRAP \
246 + b setcc_trap_handler; mov %psr, %l0; nop; nop;
248 +/* This is for hard interrupts from level 1-14, 15 is non-maskable (nmi) and
249 + * gets handled with another macro.
250 + */
251 +#define TRAP_ENTRY_INTERRUPT(int_level) \
252 + mov int_level, %l7; rd %psr, %l0; b real_irq_entry; rd %wim, %l3;
254 +/* NMI's (Non Maskable Interrupts) are special, you can't keep them
255 + * from coming in, and basically if you get one, the shows over. ;(
256 + * On the sun4c they are usually asynchronous memory errors, on the
257 + * the sun4m they could be either due to mem errors or a software
258 + * initiated interrupt from the prom/kern on an SMP box saying "I
259 + * command you to do CPU tricks, read your mailbox for more info."
260 + */
261 +#define NMI_TRAP \
262 + rd %wim, %l3; b linux_trap_nmi_sun4c; mov %psr, %l0; nop;
264 +#endif
266 +/* Window overflows/underflows are special and we need to try to be as
267 + * efficient as possible here....
268 + */
269 +#define WINDOW_SPILL \
270 + rd %psr, %l0; rd %wim, %l3; b spill_window_entry; nop;
272 +#define WINDOW_FILL \
273 + rd %psr, %l0; rd %wim, %l3; b fill_window_entry; nop;
275 +#define STUB_TRAP ba stub_trap; nop; nop; nop;
277 +#define TRAP_ENTRY(a,b) STUB_TRAP
278 +#define SKIP_TRAP(a,b) STUB_TRAP
279 +#define SUNOS_SYSCALL_TRAP STUB_TRAP
280 +#define SOLARIS_SYSCALL_TRAP STUB_TRAP
281 +#define NETBSD_SYSCALL_TRAP STUB_TRAP
282 +#define LINUX_SYSCALL_TRAP STUB_TRAP
283 +#define BREAKPOINT_TRAP STUB_TRAP
284 +#define NMI_TRAP STUB_TRAP
285 +#define GETCC_TRAP STUB_TRAP
286 +#define SETCC_TRAP STUB_TRAP
287 +#define BAD_TRAP(n) STUB_TRAP
288 +#define TRAP_ENTRY_INTERRUPT(i) STUB_TRAP
289 +#define INDIRECT_SOLARIS_SYSCALL(i) STUB_TRAP
291 + .section ".text"
292 + .globl start, _start
293 +_start:
294 +start:
295 + .globl spill_window_entry, fill_window_entry
297 +#define EXPORT_TRAP(trap) \
298 + .globl trap; \
299 + .type trap,function; \
300 + .size trap, 16
302 +EXPORT_TRAP(t_zero)
303 +EXPORT_TRAP(t_wovf)
304 +EXPORT_TRAP(t_wunf)
305 +EXPORT_TRAP(t_irq1)
306 +EXPORT_TRAP(t_irq2)
307 +EXPORT_TRAP(t_irq3)
308 +EXPORT_TRAP(t_irq4)
309 +EXPORT_TRAP(t_irq5)
310 +EXPORT_TRAP(t_irq6)
311 +EXPORT_TRAP(t_irq7)
312 +EXPORT_TRAP(t_irq8)
313 +EXPORT_TRAP(t_irq9)
314 +EXPORT_TRAP(t_irq10)
315 +EXPORT_TRAP(t_irq11)
316 +EXPORT_TRAP(t_irq12)
317 +EXPORT_TRAP(t_irq13)
318 +EXPORT_TRAP(t_irq14)
319 +EXPORT_TRAP(t_irq15)
321 +C_LABEL(trapbase):
322 +t_zero: b goprol; nop; nop; nop;
323 +t_tflt: SRMMU_TFAULT /* Inst. Access Exception */
324 +t_bins: TRAP_ENTRY(0x2, bad_instruction) /* Illegal Instruction */
325 +t_pins: TRAP_ENTRY(0x3, priv_instruction) /* Privileged Instruction */
326 +t_fpd: TRAP_ENTRY(0x4, fpd_trap_handler) /* Floating Point Disabled */
327 +t_wovf: WINDOW_SPILL /* Window Overflow */
328 +t_wunf: WINDOW_FILL /* Window Underflow */
329 +t_mna: TRAP_ENTRY(0x7, mna_handler) /* Memory Address Not Aligned */
330 +t_fpe: TRAP_ENTRY(0x8, fpe_trap_handler) /* Floating Point Exception */
331 +t_dflt: SRMMU_DFAULT /* Data Miss Exception */
332 +t_tio: TRAP_ENTRY(0xa, do_tag_overflow) /* Tagged Instruction Ovrflw */
333 +t_wpt: TRAP_ENTRY(0xb, do_watchpoint) /* Watchpoint Detected */
334 +t_badc: BAD_TRAP(0xc) BAD_TRAP(0xd) BAD_TRAP(0xe) BAD_TRAP(0xf) BAD_TRAP(0x10)
335 +t_irq1: TRAP_ENTRY_INTERRUPT(1) /* IRQ Software/SBUS Level 1 */
336 +t_irq2: TRAP_ENTRY_INTERRUPT(2) /* IRQ SBUS Level 2 */
337 +t_irq3: TRAP_ENTRY_INTERRUPT(3) /* IRQ SCSI/DMA/SBUS Level 3 */
338 +t_irq4: TRAP_ENTRY_INTERRUPT(4) /* IRQ Software Level 4 */
339 +t_irq5: TRAP_ENTRY_INTERRUPT(5) /* IRQ SBUS/Ethernet Level 5 */
340 +t_irq6: TRAP_ENTRY_INTERRUPT(6) /* IRQ Software Level 6 */
341 +t_irq7: TRAP_ENTRY_INTERRUPT(7) /* IRQ Video/SBUS Level 5 */
342 +t_irq8: TRAP_ENTRY_INTERRUPT(8) /* IRQ SBUS Level 6 */
343 +t_irq9: TRAP_ENTRY_INTERRUPT(9) /* IRQ SBUS Level 7 */
344 +t_irq10:TRAP_ENTRY_INTERRUPT(10) /* IRQ Timer #1 (one we use) */
345 +t_irq11:TRAP_ENTRY_INTERRUPT(11) /* IRQ Floppy Intr. */
346 +t_irq12:TRAP_ENTRY_INTERRUPT(12) /* IRQ Zilog serial chip */
347 +t_irq13:TRAP_ENTRY_INTERRUPT(13) /* IRQ Audio Intr. */
348 +t_irq14:TRAP_ENTRY_INTERRUPT(14) /* IRQ Timer #2 */
349 +t_nmi: NMI_TRAP /* Level 15 (NMI) */
350 +t_racc: TRAP_ENTRY(0x20, do_reg_access) /* General Register Access Error */
351 +t_iacce:BAD_TRAP(0x21) /* Instr Access Error */
352 +t_bad22:BAD_TRAP(0x22) BAD_TRAP(0x23)
353 +t_cpdis:TRAP_ENTRY(0x24, do_cp_disabled) /* Co-Processor Disabled */
354 +t_uflsh:SKIP_TRAP(0x25, unimp_flush) /* Unimplemented FLUSH inst. */
355 +t_bad26:BAD_TRAP(0x26) BAD_TRAP(0x27)
356 +t_cpexc:TRAP_ENTRY(0x28, do_cp_exception) /* Co-Processor Exception */
357 +t_dacce:SRMMU_DFAULT /* Data Access Error */
358 +t_hwdz: TRAP_ENTRY(0x2a, do_hw_divzero) /* Division by zero, you lose... */
359 +t_dserr:BAD_TRAP(0x2b) /* Data Store Error */
360 +t_daccm:BAD_TRAP(0x2c) /* Data Access MMU-Miss */
361 +t_bad2d: BAD_TRAP(0x2d) BAD_TRAP(0x2e) BAD_TRAP(0x2f)
362 + BAD_TRAP(0x30) BAD_TRAP(0x31) BAD_TRAP(0x32) BAD_TRAP(0x33)
363 + BAD_TRAP(0x34) BAD_TRAP(0x35) BAD_TRAP(0x36) BAD_TRAP(0x37)
364 + BAD_TRAP(0x38) BAD_TRAP(0x39) BAD_TRAP(0x3a) BAD_TRAP(0x3b)
365 +t_iaccm:BAD_TRAP(0x3c) /* Instr Access MMU-Miss */
366 + BAD_TRAP(0x3d) BAD_TRAP(0x3e) BAD_TRAP(0x3f)
367 + BAD_TRAP(0x40) BAD_TRAP(0x41) BAD_TRAP(0x42) BAD_TRAP(0x43)
368 + BAD_TRAP(0x44) BAD_TRAP(0x45) BAD_TRAP(0x46) BAD_TRAP(0x47)
369 + BAD_TRAP(0x48) BAD_TRAP(0x49) BAD_TRAP(0x4a) BAD_TRAP(0x4b)
370 + BAD_TRAP(0x4c) BAD_TRAP(0x4d) BAD_TRAP(0x4e) BAD_TRAP(0x4f)
371 + BAD_TRAP(0x50) BAD_TRAP(0x51) BAD_TRAP(0x52) BAD_TRAP(0x53)
372 + BAD_TRAP(0x54) BAD_TRAP(0x55) BAD_TRAP(0x56) BAD_TRAP(0x57)
373 + BAD_TRAP(0x58) BAD_TRAP(0x59) BAD_TRAP(0x5a) BAD_TRAP(0x5b)
374 + BAD_TRAP(0x5c) BAD_TRAP(0x5d) BAD_TRAP(0x5e) BAD_TRAP(0x5f)
375 + BAD_TRAP(0x60) BAD_TRAP(0x61) BAD_TRAP(0x62) BAD_TRAP(0x63)
376 + BAD_TRAP(0x64) BAD_TRAP(0x65) BAD_TRAP(0x66) BAD_TRAP(0x67)
377 + BAD_TRAP(0x68) BAD_TRAP(0x69) BAD_TRAP(0x6a) BAD_TRAP(0x6b)
378 + BAD_TRAP(0x6c) BAD_TRAP(0x6d) BAD_TRAP(0x6e) BAD_TRAP(0x6f)
379 + BAD_TRAP(0x70) BAD_TRAP(0x71) BAD_TRAP(0x72) BAD_TRAP(0x73)
380 + BAD_TRAP(0x74) BAD_TRAP(0x75) BAD_TRAP(0x76) BAD_TRAP(0x77)
381 + BAD_TRAP(0x78) BAD_TRAP(0x79) BAD_TRAP(0x7a) BAD_TRAP(0x7b)
382 + BAD_TRAP(0x7c) BAD_TRAP(0x7d) BAD_TRAP(0x7e) BAD_TRAP(0x7f)
383 +t_sunos:SUNOS_SYSCALL_TRAP /* SunOS System Call */
384 +t_sbkpt:BREAKPOINT_TRAP /* Software Breakpoint/KGDB */
385 +t_divz: BAD_TRAP(0x82) /* Divide by zero trap */
386 +t_flwin:TRAP_ENTRY(0x83, do_flush_windows) /* Flush Windows Trap */
387 +t_clwin:BAD_TRAP(0x84) /* Clean Windows Trap */
388 +t_rchk: BAD_TRAP(0x85) /* Range Check */
389 +t_funal:BAD_TRAP(0x86) /* Fix Unaligned Access Trap */
390 +t_iovf: BAD_TRAP(0x87) /* Integer Overflow Trap */
391 +t_slowl:SOLARIS_SYSCALL_TRAP /* Slowaris System Call */
392 +t_netbs:NETBSD_SYSCALL_TRAP /* Net-B.S. System Call */
393 +t_bad8a:BAD_TRAP(0x8a) BAD_TRAP(0x8b) BAD_TRAP(0x8c) BAD_TRAP(0x8d)
394 + BAD_TRAP(0x8e) BAD_TRAP(0x8f)
395 +t_linux:LINUX_SYSCALL_TRAP /* Linux System Call */
396 +t_bad91:BAD_TRAP(0x91) BAD_TRAP(0x92) BAD_TRAP(0x93)
397 + BAD_TRAP(0x94) BAD_TRAP(0x95) BAD_TRAP(0x96) BAD_TRAP(0x97)
398 + BAD_TRAP(0x98) BAD_TRAP(0x99) BAD_TRAP(0x9a) BAD_TRAP(0x9b) BAD_TRAP(0x9c) BAD_TRAP(0x9d) BAD_TRAP(0x9e) BAD_TRAP(0x9f)
399 +t_getcc:GETCC_TRAP /* Get Condition Codes */
400 +t_setcc:SETCC_TRAP /* Set Condition Codes */
401 +t_bada2:BAD_TRAP(0xa2) BAD_TRAP(0xa3)
402 + BAD_TRAP(0xa4) BAD_TRAP(0xa5) BAD_TRAP(0xa6)
403 +t_slowi:INDIRECT_SOLARIS_SYSCALL(156)
404 + BAD_TRAP(0xa8) BAD_TRAP(0xa9) BAD_TRAP(0xaa) BAD_TRAP(0xab)
405 + BAD_TRAP(0xac) BAD_TRAP(0xad) BAD_TRAP(0xae) BAD_TRAP(0xaf)
406 + BAD_TRAP(0xb0) BAD_TRAP(0xb1) BAD_TRAP(0xb2) BAD_TRAP(0xb3)
407 + BAD_TRAP(0xb4) BAD_TRAP(0xb5) BAD_TRAP(0xb6) BAD_TRAP(0xb7)
408 + BAD_TRAP(0xb8) BAD_TRAP(0xb9) BAD_TRAP(0xba) BAD_TRAP(0xbb)
409 + BAD_TRAP(0xbc) BAD_TRAP(0xbd) BAD_TRAP(0xbe) BAD_TRAP(0xbf)
410 +t_badc0:BAD_TRAP(0xc0) BAD_TRAP(0xc1) BAD_TRAP(0xc2) BAD_TRAP(0xc3)
411 + BAD_TRAP(0xc4) BAD_TRAP(0xc5) BAD_TRAP(0xc6) BAD_TRAP(0xc7)
412 + BAD_TRAP(0xc8) BAD_TRAP(0xc9) BAD_TRAP(0xca) BAD_TRAP(0xcb)
413 + BAD_TRAP(0xcc) BAD_TRAP(0xcd) BAD_TRAP(0xce) BAD_TRAP(0xcf)
414 + BAD_TRAP(0xd0) BAD_TRAP(0xd1) BAD_TRAP(0xd2) BAD_TRAP(0xd3)
415 +t_badd4:BAD_TRAP(0xd4) BAD_TRAP(0xd5) BAD_TRAP(0xd6) BAD_TRAP(0xd7)
416 + BAD_TRAP(0xd8) BAD_TRAP(0xd9) BAD_TRAP(0xda) BAD_TRAP(0xdb)
417 + BAD_TRAP(0xdc) BAD_TRAP(0xdd) BAD_TRAP(0xde) BAD_TRAP(0xdf)
418 + BAD_TRAP(0xe0) BAD_TRAP(0xe1) BAD_TRAP(0xe2) BAD_TRAP(0xe3)
419 + BAD_TRAP(0xe4) BAD_TRAP(0xe5) BAD_TRAP(0xe6) BAD_TRAP(0xe7)
420 +t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb)
421 + BAD_TRAP(0xec) BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef)
422 + BAD_TRAP(0xf0) BAD_TRAP(0xf1) BAD_TRAP(0xf2) BAD_TRAP(0xf3)
423 + BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6) BAD_TRAP(0xf7)
424 + BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
425 +t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd)
426 +dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */
427 +dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */
429 +stub_trap:
430 + set (PHYS_JJ_TCX_FB + 0xbf0), %g5 /* 2 cells from side */
431 + set 0x00ffffff, %g4
432 + sta %g4, [%g5] ASI_M_BYPASS
433 +1: ba 1b; nop
435 + .section ".bss"
436 + .align 8
437 +bss_start:
438 + .align 0x1000 ! PAGE_SIZE
439 + .globl C_LABEL(bootup_user_stack)
440 + .type bootup_user_stack,#object
441 + .size bootup_user_stack,0x2000
442 +C_LABEL(bootup_user_stack): .skip 0x2000
444 + .section ".text"
446 +goprol:
447 + ! %g1 contains end of memory
448 + set PHYS_JJ_EEPROM + 0x30, %g1
449 + lda [%g1] ASI_M_BYPASS, %g1
450 + ! map PROLDATA to PROLBASE+PROLSIZE to end of ram
451 + set PROLSIZE+0x1000-PROLDATA+PROLBASE, %g2 ! add 0x1000 for temp tables
452 + sub %g1, %g2, %g2 ! start of private memory
453 + srl %g2, 0x4, %g7 ! ctx table at s+0x0
454 + add %g2, 0x400, %g3 ! l1 table at s+0x400
455 + srl %g3, 0x4, %g3
456 + or %g3, 0x1, %g3
457 + sta %g3, [%g2] ASI_M_BYPASS
458 + add %g2, 0x400, %g2 ! s+0x400
459 + add %g2, 0x800, %g3 ! l2 table for ram (00xxxxxx) at s+0x800
460 + srl %g3, 0x4, %g3
461 + or %g3, 0x1, %g3
462 + sta %g3, [%g2] ASI_M_BYPASS
463 + add %g2, 0x500, %g3 ! l2 table for rom (ffxxxxxx) at s+0x900
464 + add %g2, 0x3fc, %g2 ! s+0x7fc
465 + srl %g3, 0x4, %g3
466 + or %g3, 0x1, %g3
467 + sta %g3, [%g2] ASI_M_BYPASS
468 + add %g2, 0x4, %g2 ! s+0x800
469 + set ((7 << 2) | 2), %g3 ! 7 = U: --- S: RWX (main memory)
470 + sta %g3, [%g2] ASI_M_BYPASS
471 + add %g2, 0x200, %g3 ! l3 table for rom at s+0xa00
472 + add %g2, 0x1d0, %g2 ! s+0x9d0
473 + srl %g3, 0x4, %g3
474 + or %g3, 0x1, %g3
475 + sta %g3, [%g2] ASI_M_BYPASS
476 + add %g2, 0x30, %g2 ! s+0xa00
478 + set PROLBASE, %g3
479 + set 0x1000, %g5
480 + set (PROLDATA-PROLBASE)/0x1000, %g6 ! # of .text pages
481 +1: srl %g3, 0x4, %g4
482 + or %g4, ((7 << 2) | 2), %g4 ! 4 = U: --X S: --X (rom, execute only)
483 + sta %g4, [%g2] ASI_M_BYPASS
484 + add %g2, 4, %g2
485 + add %g3, %g5, %g3
486 + deccc %g6
487 + bne 1b
488 + nop
489 +#if 0
490 + set (PROLDATA-PROLRODATA)/0x1000, %g6 ! # of .rodata pages
491 +1: srl %g3, 0x4, %g4
492 + or %g4, ((0 << 2) | 2), %g4 ! 0 = U: R-- S: R-- (rom, read only)
493 + sta %g4, [%g2] ASI_M_BYPASS
494 + add %g2, 4, %g2
495 + add %g3, %g5, %g3
496 + deccc %g6
497 + bne 1b
498 + nop
499 +#endif
500 + set (PROLBASE+PROLSIZE-PROLDATA)/0x1000, %g6 ! # of .bss pages
501 + set 0x1000, %g4
502 + sll %g7, 0x4, %g3
503 + add %g4, %g3, %g3
504 +1: srl %g3, 0x4, %g4
505 + or %g4, ((7 << 2) | 2), %g4 ! 5 = U: R-- S: RW- (data area, read/write)
506 + sta %g4, [%g2] ASI_M_BYPASS
507 + add %g2, 4, %g2
508 + add %g3, %g5, %g3
509 + deccc %g6
510 + bne 1b
511 + nop
513 + mov %g1, %g3
515 + set AC_M_CTPR, %g2
516 + sta %g7, [%g2] ASI_M_MMUREGS ! set ctx table ptr
517 + set 1, %g1
518 + sta %g1, [%g0] ASI_M_MMUREGS ! enable mmu
520 + /*
521 + * The code which enables traps is a simplified version of
522 + * kernel head.S.
524 + * We know number of windows as 8 so we do not calculate them.
525 + * The deadwood is here for any case.
526 + */
528 + /* Turn on Supervisor, EnableFloating, and all the PIL bits.
529 + * Also puts us in register window zero with traps off.
530 + */
531 + set (PSR_PS | PSR_S | PSR_PIL | PSR_EF), %g2
532 + wr %g2, 0x0, %psr
533 + WRITE_PAUSE
535 + /* I want a kernel stack NOW! */
536 + set C_LABEL(bootup_user_stack), %g1
537 + set (0x2000 - REGWIN_SZ), %g2
538 + add %g1, %g2, %sp
539 + mov 0, %fp /* And for good luck */
541 + /* Zero out our BSS section. */
542 + set C_LABEL(bss_start) , %o0 ! First address of BSS
543 + set C_LABEL(end) , %o1 ! Last address of BSS
544 + ba 2f
545 + nop
547 + st %g0, [%o0]
549 + subcc %o0, %o1, %g0
550 + bl 1b
551 + add %o0, 0x4, %o0
553 + mov 2, %g1
554 + wr %g1, 0x0, %wim ! make window 1 invalid
555 + WRITE_PAUSE
557 +#if 0
558 + wr %g0, 0x0, %wim
559 + WRITE_PAUSE
560 + save
561 + rd %psr, %g3
562 + restore
563 + and %g3, PSR_CWP, %g3
564 + add %g3, 0x1, %g3
565 +#else
566 + or %g0, 8, %g3
567 +#endif
569 +#if 0
570 + sethi %hi( C_LABEL(cputyp) ), %o0
571 + st %g7, [%o0 + %lo( C_LABEL(cputyp) )]
573 + sethi %hi( C_LABEL(nwindows) ), %g4
574 + st %g3, [%g4 + %lo( C_LABEL(nwindows) )]
576 + sub %g3, 0x1, %g3
577 + sethi %hi( C_LABEL(nwindowsm1) ), %g4
578 + st %g3, [%g4 + %lo( C_LABEL(nwindowsm1) )]
579 +#endif
581 + /* Here we go, start using Linux's trap table... */
582 + set C_LABEL(trapbase), %g3
583 + wr %g3, 0x0, %tbr
584 + WRITE_PAUSE
586 + /* Finally, turn on traps so that we can call c-code. */
587 + rd %psr, %g3
588 + wr %g3, 0x0, %psr
589 + WRITE_PAUSE
591 + wr %g3, PSR_ET, %psr
592 + WRITE_PAUSE
594 + .globl prolmain
595 + call C_LABEL(prolmain)
596 + nop
599 + b 3b
600 + nop
603 + * Memory access trap handler
604 + * %l0 program %psr from trap table entry
605 + * %l1 program %pc from hardware
606 + * %l2 program %npc from hardware
607 + * %l3 program %wim from trap table entry
608 + * %l4
609 + * %l5
610 + * %l6
611 + * %l7 text flag from trap table entry
612 + */
614 + .section ".text"
615 + .globl srmmu_fault
616 +C_LABEL(srmmu_fault):
618 + set AC_M_SFAR, %l6
619 + set AC_M_SFSR, %l5
620 + lda [%l6] ASI_M_MMUREGS, %l6
621 + lda [%l5] ASI_M_MMUREGS, %l5
623 + set ignore_fault, %l5
624 + ld [%l5], %l5
625 + subcc %l5, %g0, %g0 /* NULL pointer trap faults always */
626 + be 3f
627 + nop
628 + subcc %l5, %l6, %g0
629 + be 2f
630 + nop
633 + set (PHYS_JJ_TCX_FB + 0xbf0), %g5 /* 2 cells from side */
634 + set 0x00ffffff, %g4
635 + sta %g4, [%g5] ASI_M_BYPASS
636 + add %g5, 8, %g5 /* On right side */
637 + sta %g4, [%g5] ASI_M_BYPASS
638 +1: ba 1b; nop
641 + set C_LABEL(fault_ignored), %l5
642 + mov 1, %l6
643 + st %l6, [%l5]
645 + /*
646 + * Skip the faulting instruction.
647 + * I think it works when next instruction is a branch even.
648 + */
649 + or %l2, 0, %l1
650 + add %l2, 4, %l2
652 + wr %l0, 0, %psr
653 + WRITE_PAUSE
654 + jmp %l1
655 + rett %l2
658 + * Slow external versions of st_bypass and ld_bypass.
659 + * rconsole.c uses inlines. We call these in places which are not speed
660 + * critical, to avoid compiler bugs.
661 + */
662 + .globl C_LABEL(st_bypass)
663 +C_LABEL(st_bypass):
664 + retl
665 + sta %o1, [%o0] ASI_M_BYPASS
666 + .globl C_LABEL(ld_bypass)
667 +C_LABEL(ld_bypass):
668 + retl
669 + lda [%o0] ASI_M_BYPASS, %o0
670 + .globl C_LABEL(sth_bypass)
671 +C_LABEL(sth_bypass):
672 + retl
673 + stha %o1, [%o0] ASI_M_BYPASS
674 + .globl C_LABEL(ldh_bypass)
675 +C_LABEL(ldh_bypass):
676 + retl
677 + lduha [%o0] ASI_M_BYPASS, %o0
678 + .globl C_LABEL(stb_bypass)
679 +C_LABEL(stb_bypass):
680 + retl
681 + stba %o1, [%o0] ASI_M_BYPASS
682 + .globl C_LABEL(ldb_bypass)
683 +C_LABEL(ldb_bypass):
684 + retl
685 + lduba [%o0] ASI_M_BYPASS, %o0
686 diff -ruN proll_18.orig/qemu/main.c proll-patch8/qemu/main.c
687 --- proll_18.orig/qemu/main.c 1970-01-01 00:00:00.000000000 +0000
688 +++ proll-patch8/qemu/main.c 2005-04-03 11:58:46.000000000 +0000
689 @@ -0,0 +1,173 @@
690 +/**
691 + ** Proll (PROM replacement)
692 + ** Copyright 1999 Pete Zaitcev
693 + ** This code is licensed under GNU General Public License.
694 + **/
695 +#include <stdarg.h>
697 +// #include <asm/contregs.h>
698 +#include <asi.h>
699 +#include "pgtsrmmu.h"
700 +#include "iommu.h" /* Typical SBus IOMMU for sun4m */
701 +#include "phys_jj.h"
702 +#include "vconsole.h"
703 +#include "version.h"
704 +#include <general.h> /* __P() */
705 +#include <net.h> /* init_net() */
706 +#include <romlib.h> /* we are a provider for part of this. */
707 +#include <netpriv.h> /* myipaddr */
708 +#include <arpa.h>
709 +#include <system.h> /* our own prototypes */
711 +void *init_openprom_qemu(int bankc, struct bank *bankv, unsigned hiphybas, const char *cmdline, char boot_device, int nographic);
712 +int vcon_zs_init(struct vconterm *t, unsigned int a0);
713 +int vcon_zs_write(struct vconterm *t, char *data, int leng);
715 +static void init_idprom(void);
717 +struct vconterm dp0;
718 +struct mem cmem; /* Current memory, virtual */
719 +struct mem cio; /* Current I/O space */
720 +struct phym pmem; /* Current phys. mem. */
721 +struct iommu ciommu; /* Our IOMMU on sun4m */
723 +static struct {
724 + const char id[16];
725 + unsigned int version;
726 + char pad1[0x1c]; // Pad to 0x30
727 + unsigned int ram_size;
728 + char boot_device;
729 + unsigned int load_addr, kernel_size;
730 + unsigned int cmdline, cmdline_len;
731 + char pad2[0x0c]; // Pad to 0x54
732 + unsigned short width, height, depth;
733 +} *hw_idprom;
735 +int ignore_fault, fault_ignored;
736 +void *printk_fn;
737 +unsigned int q_height, q_width;
740 + */
741 +void prolmain()
743 + static char fname[14];
744 + static struct banks bb;
745 + unsigned int hiphybas;
746 + const void *romvec;
747 + unsigned int ram_size;
748 + char nographic;
750 + nographic = ldb_bypass(PHYS_JJ_EEPROM + 0x2F);
751 + if (!nographic) {
752 + q_width = ldh_bypass(PHYS_JJ_EEPROM + 0x54);
753 + q_height = ldh_bypass(PHYS_JJ_EEPROM + 0x56);
754 + vcon_init(&dp0, PHYS_JJ_TCX_FB);
755 + printk_fn = vcon_write;
757 + else {
758 + vcon_zs_init(&dp0, 0x71100004);
759 + printk_fn = vcon_zs_write;
763 + printk("PROLL %s QEMU\n", PROLL_VERSION_STRING);
764 + ram_size = ld_bypass(PHYS_JJ_EEPROM + 0x30);
765 + printk("%d MB total\n", ram_size/(1024*1024));
767 + bb.nbanks = 1;
768 + bb.bankv[0].start = 0;
769 + bb.bankv[0].length = ram_size;
771 + hiphybas = ram_size - PROLSIZE;
773 + mem_init(&cmem, (char *) &_end, (char *)(PROLBASE+PROLSIZE));
774 + makepages(&pmem, hiphybas);
775 + init_mmu_swift((unsigned int)pmem.pctp - PROLBASE + hiphybas);
777 + mem_init(&cio, (char *)(PROLBASE+PROLSIZE),
778 + (char *)(PROLBASE+PROLSIZE+IOMAPSIZE));
780 + iommu_init(&ciommu, hiphybas);
782 + /*
783 + */
784 + init_idprom();
785 + printk("NVRAM: id %s version %d\n", hw_idprom->id, hw_idprom->version);
786 + if (!nographic)
787 + printk("Prom console: TCX %dx%d\n", q_width, q_height);
788 + else
789 + printk("Prom console: serial\n");
790 + sched_init();
791 + le_probe();
792 + init_net();
794 + printk("Boot device: %c\n", hw_idprom->boot_device);
795 + if (hw_idprom->boot_device == 'n') {
796 + if (bootp() != 0) fatal();
797 + /*
798 + * boot_rec.bp_file cannot be used because system PROM
799 + * uses it to locate ourselves. If we load from boot_rec.bp_file,
800 + * we will loop reloading PROLL over and over again.
801 + * Thus we use traditional PROLL scheme HEXIPADDR.PROL (single L).
802 + */
803 + xtoa(myipaddr, fname, 8);
804 + fname[9] = '.';
805 + fname[10] = 'P';
806 + fname[11] = 'R';
807 + fname[12] = 'O';
808 + fname[13] = 'L';
809 + fname[14] = 0;
811 + if (load(boot_rec.bp_siaddr, fname) != 0) fatal();
814 + romvec = init_openprom_qemu(bb.nbanks, bb.bankv, hiphybas,
815 + (void *)hw_idprom->cmdline, hw_idprom->boot_device, nographic);
817 + printk("Memory used: virt 0x%x:0x%x[%dK] iomap 0x%x:0x%x\n",
818 + PROLBASE, (int)cmem.curp, ((unsigned) cmem.curp - PROLBASE)/1024,
819 + (int)cio.start, (int)cio.curp);
822 + void (*entry)(const void *, int, int, int, int) = (void *) hw_idprom->load_addr;
823 + printk("Kernel loaded at 0x%x, size %dK, command line = '%s'\n",
824 + *entry, hw_idprom->kernel_size/1024, hw_idprom->cmdline);
825 + entry(romvec, 0, 0, 0, 0);
828 + mem_fini(&cmem);
829 + vcon_fini(&dp0);
833 + * dvma_alloc over iommu_alloc.
834 + */
835 +void *dvma_alloc(int size, unsigned int *pphys)
837 + return iommu_alloc(&ciommu, size, pphys);
841 + */
842 +void udelay(unsigned long usecs)
844 + // Qemu hardware is perfect and does not need any delays!
847 +static void init_idprom()
849 + void *va_prom;
851 + if ((va_prom = map_io(PHYS_JJ_EEPROM, PHYS_JJ_EEPROM_SIZE)) == NULL) {
852 + printk("init_idprom: cannot map eeprom\n");
853 + fatal();
855 + bcopy(va_prom + PHYS_JJ_IDPROM_OFF, idprom, IDPROM_SIZE);
856 + /*
857 + * hw_idprom is not used anywhere.
858 + * It's just as we hate to leave hanging pointers (I/O page here).
859 + */
860 + hw_idprom = va_prom;
863 diff -ruN proll_18.orig/qemu/openprom.c proll-patch8/qemu/openprom.c
864 --- proll_18.orig/qemu/openprom.c 1970-01-01 00:00:00.000000000 +0000
865 +++ proll-patch8/qemu/openprom.c 2005-04-06 16:53:31.000000000 +0000
866 @@ -0,0 +1,665 @@
868 + * PROM interface support
869 + * Copyright 1996 The Australian National University.
870 + * Copyright 1996 Fujitsu Laboratories Limited
871 + * Copyright 1999 Pete A. Zaitcev
872 + * This software may be distributed under the terms of the Gnu
873 + * Public License version 2 or later
874 + */
876 +#include <openprom.h>
877 +#include <general.h>
878 +#include <romlib.h>
879 +#include <system.h>
880 +#include <vconsole.h>
881 +#include "phys_jj.h"
883 +//#define DEBUG_OBP
885 +struct property {
886 + const char *name;
887 + const char *value;
888 + const int length;
891 +struct node {
892 + const struct property *properties;
893 + /* short */ const int sibling;
894 + /* short */ const int child;
897 +static int obp_nextnode(int node);
898 +static int obp_child(int node);
899 +static int obp_proplen(int node, char *name);
900 +static int obp_getprop(int node, char *name, char *val);
901 +static int obp_setprop(int node, char *name, char *val, int len);
902 +static const char *obp_nextprop(int node, char *name);
904 +static char obp_idprom[IDPROM_SIZE];
905 +static const struct property null_properties = { NULL, NULL, -1 };
906 +static const int prop_true = -1;
908 +static const struct property propv_root[] = {
909 + {"name", "SUNW,JavaStation-1", sizeof("SUNW,JavaStation-1") },
910 + {"idprom", obp_idprom, IDPROM_SIZE},
911 + {"banner-name", "JavaStation", sizeof("JavaStation")},
912 + {"compatible", "sun4m", 6},
913 + {NULL, NULL, -1}
916 +static const int prop_iommu_reg[] = {
917 + 0x0, 0x10000000, 0x00000300,
919 +static const struct property propv_iommu[] = {
920 + {"name", "iommu", sizeof("iommu")},
921 + {"reg", (char*)&prop_iommu_reg[0], sizeof(prop_iommu_reg) },
922 + {NULL, NULL, -1}
925 +static const int prop_sbus_ranges[] = {
926 + 0x0, 0x0, 0x0, 0x30000000, 0x10000000,
927 + 0x1, 0x0, 0x0, 0x40000000, 0x10000000,
928 + 0x2, 0x0, 0x0, 0x50000000, 0x10000000,
929 + 0x3, 0x0, 0x0, 0x60000000, 0x10000000,
930 + 0x4, 0x0, 0x0, 0x70000000, 0x10000000,
932 +static const struct property propv_sbus[] = {
933 + {"name", "sbus", 5},
934 + {"ranges", (char*)&prop_sbus_ranges[0], sizeof(prop_sbus_ranges)},
935 + {"device_type", "hierarchical", sizeof("hierarchical") },
936 + {NULL, NULL, -1}
939 +static const int prop_tcx_regs[] = {
940 + 0x2, 0x00800000, 0x00100000,
941 + 0x2, 0x02000000, 0x00000001,
942 + 0x2, 0x04000000, 0x00800000,
943 + 0x2, 0x06000000, 0x00800000,
944 + 0x2, 0x0a000000, 0x00000001,
945 + 0x2, 0x0c000000, 0x00000001,
946 + 0x2, 0x0e000000, 0x00000001,
947 + 0x2, 0x00700000, 0x00001000,
948 + 0x2, 0x00200000, 0x00000004,
949 + 0x2, 0x00300000, 0x0000081c,
950 + 0x2, 0x00000000, 0x00010000,
951 + 0x2, 0x00240000, 0x00000004,
952 + 0x2, 0x00280000, 0x00000001,
955 +#if 1 /* Zaitcev */
956 +static const int pixfreq = 0x03dfd240;
957 +static const int hbporch = 0xa0;
958 +static const int vfreq = 0x3c;
959 +#endif
960 +#if 0 /* Kevin Boone - 70Hz refresh */
961 +static const int pixfreq = 0x047868C0;
962 +static const int hbporch = 0x90;
963 +static const int vfreq = 0x46;
964 +#endif
966 +static const int vbporch = 0x1d;
967 +static const int vsync = 0x6;
968 +static const int hsync = 0x88;
969 +static const int vfporch = 0x3;
970 +static const int hfporch = 0x18;
971 +static const int height = 0x300;
972 +static const int width = 0x400;
973 +static const int linebytes = 0x400;
974 +static const int depth = 8;
975 +static const int tcx_intr[] = { 5, 0 };
976 +static const int tcx_interrupts = 5;
977 +static const struct property propv_sbus_tcx[] = {
978 + {"name", "SUNW,tcx", sizeof("SUNW,tcx")},
979 + {"vbporch", (char*)&vbporch, sizeof(int)},
980 + {"hbporch", (char*)&hbporch, sizeof(int)},
981 + {"vsync", (char*)&vsync, sizeof(int)},
982 + {"hsync", (char*)&hsync, sizeof(int)},
983 + {"vfporch", (char*)&vfporch, sizeof(int)},
984 + {"hfporch", (char*)&hfporch, sizeof(int)},
985 + {"pixfreq", (char*)&pixfreq, sizeof(int)},
986 + {"vfreq", (char*)&vfreq, sizeof(int)},
987 + {"height", (char*)&height, sizeof(int)},
988 + {"width", (char*)&width, sizeof(int)},
989 + {"linebytes", (char*)&linebytes, sizeof(int)},
990 + {"depth", (char*)&depth, sizeof(int)},
991 + {"reg", (char*)&prop_tcx_regs[0], sizeof(prop_tcx_regs)},
992 + {"tcx-8-bit", (char*)&prop_true, 0},
993 + {"intr", (char*)&tcx_intr[0], sizeof(tcx_intr)},
994 + {"interrupts", (char*)&tcx_interrupts, sizeof(tcx_interrupts)},
995 + {"device_type", "display", sizeof("display")},
996 + {NULL, NULL, -1}
999 +static const int prop_cs4231_reg[] = {
1000 + 0x3, 0x0C000000, 0x00000040
1002 +static const int cs4231_interrupts = 5;
1003 +static const int cs4231_intr[] = { 5, 0 };
1005 +static const struct property propv_sbus_cs4231[] = {
1006 + {"name", "SUNW,CS4231", sizeof("SUNW,CS4231") },
1007 + {"intr", (char*)&cs4231_intr[0], sizeof(cs4231_intr) },
1008 + {"interrupts", (char*)&cs4231_interrupts, sizeof(cs4231_interrupts) },
1009 + {"reg", (char*)&prop_cs4231_reg[0], sizeof(prop_cs4231_reg) },
1010 + {"device_type", "serial", sizeof("serial") },
1011 + {"alias", "audio", sizeof("audio") },
1012 + {NULL, NULL, -1}
1015 +static const int cpu_nctx = NCTX_SWIFT;
1016 +static const int cpu_cache_line_size = 0x20;
1017 +static const int cpu_cache_nlines = 0x200;
1018 +static const struct property propv_cpu[] = {
1019 + {"name", "STP1012PGA", sizeof("STP1012PGA") },
1020 + {"device_type", "cpu", 4 },
1021 + {"mmu-nctx", (char*)&cpu_nctx, sizeof(int)},
1022 + {"cache-line-size", (char*)&cpu_cache_line_size, sizeof(int)},
1023 + {"cache-nlines", (char*)&cpu_cache_nlines, sizeof(int)},
1024 + {NULL, NULL, -1}
1027 +static const int prop_obio_ranges[] = {
1028 + 0x0, 0x0, 0x0, 0x71000000, 0x01000000,
1030 +static const struct property propv_obio[] = {
1031 + {"name", "obio", 5 },
1032 + {"ranges", (char*)&prop_obio_ranges[0], sizeof(prop_obio_ranges) },
1033 + {"device_type", "hierarchical", sizeof("hierarchical") },
1034 + {NULL, NULL, -1}
1037 +static const int prop_auxio_reg[] = {
1038 + 0x0, 0x00900000, 0x00000001,
1040 +static const struct property propv_obio_auxio[] = {
1041 + {"name", "auxio", sizeof("auxio") },
1042 + {"reg", (char*)&prop_auxio_reg[0], sizeof(prop_auxio_reg) },
1043 + {NULL, NULL, -1}
1046 +static const int prop_int_reg[] = {
1047 + 0x0, 0x00e00000, 0x00000010,
1048 + 0x0, 0x00e10000, 0x00000010,
1050 +static const struct property propv_obio_int[] = {
1051 + {"name", "interrupt", sizeof("interrupt")},
1052 + {"reg", (char*)&prop_int_reg[0], sizeof(prop_int_reg) },
1053 + {NULL, NULL, -1}
1056 +static const int prop_cnt_reg[] = {
1057 + 0x0, 0x00d00000, 0x00000010,
1058 + 0x0, 0x00d10000, 0x00000010,
1060 +static const struct property propv_obio_cnt[] = {
1061 + {"name", "counter", sizeof("counter")},
1062 + {"reg", (char*)&prop_cnt_reg[0], sizeof(prop_cnt_reg) },
1063 + {NULL, NULL, -1}
1066 +static const int prop_eeprom_reg[] = {
1067 + 0x0, 0x00200000, 0x00002000,
1069 +static const struct property propv_obio_eep[] = {
1070 + {"name", "eeprom", sizeof("eeprom")},
1071 + {"reg", (char*)&prop_eeprom_reg[0], sizeof(prop_eeprom_reg) },
1072 + {"model", "mk48t08", sizeof("mk48t08")},
1073 + {NULL, NULL, -1}
1076 +static const int prop_su_reg[] = {
1077 + 0x0, 0x003002f8, 0x00000008,
1079 +static const struct property propv_obio_su[] = {
1080 + {"name", "su", sizeof("su")},
1081 + {"reg", (char*)&prop_su_reg[0], sizeof(prop_su_reg) },
1082 + {NULL, NULL, -1}
1085 +static const int prop_zs_intr[] = { 0x2c, 0x0 };
1086 +static const int prop_zs_reg[] = {
1087 + 0x0, 0x00000000, 0x00000008,
1089 +static const int prop_zs_slave[] = { 1 };
1090 +static void *prop_zs_addr;
1091 +static const struct property propv_obio_zs[] = {
1092 + {"name", "zs", sizeof("zs")},
1093 + {"reg", (char*)&prop_zs_reg[0], sizeof(prop_zs_reg) },
1094 + {"slave", (char*)&prop_zs_slave[0], sizeof(prop_zs_slave) },
1095 + {"device_type", "serial", sizeof("serial") },
1096 + {"intr", (char*)&prop_zs_intr[0], sizeof(prop_zs_intr) },
1097 + {"address", (char*)&prop_zs_addr, sizeof(prop_zs_addr) },
1098 + {NULL, NULL, -1}
1101 +static const int prop_zs1_intr[] = { 0x2c, 0x0 };
1102 +static const int prop_zs1_reg[] = {
1103 + 0x0, 0x00100000, 0x00000008,
1105 +static void *prop_zs1_addr;
1106 +static const int prop_zs1_slave[] = { 0 };
1107 +static const struct property propv_obio_zs1[] = {
1108 + {"name", "zs", sizeof("zs")},
1109 + {"reg", (char*)&prop_zs1_reg[0], sizeof(prop_zs1_reg) },
1110 + {"slave", (char*)&prop_zs1_slave[0], sizeof(prop_zs1_slave) },
1111 + {"device_type", "serial", sizeof("serial") },
1112 + {"intr", (char*)&prop_zs1_intr[0], sizeof(prop_zs1_intr) },
1113 + {"address", (char*)&prop_zs1_addr, sizeof(prop_zs1_addr) },
1114 + {NULL, NULL, -1}
1117 +static const int prop_ledma_reg[] = {
1118 + 0x4, 0x08400010, 0x00000020,
1120 +static const int prop_ledma_burst = 0x3f;
1121 +static const struct property propv_sbus_ledma[] = {
1122 + {"name", "ledma", sizeof("ledma")},
1123 + {"reg", (char*)&prop_ledma_reg[0], sizeof(prop_ledma_reg) },
1124 + {"burst-sizes", (char*)&prop_ledma_burst, sizeof(int) },
1125 + {NULL, NULL, -1}
1128 +static const int prop_le_reg[] = {
1129 + 0x4, 0x08c00000, 0x00000004,
1131 +static const int prop_le_busmaster_regval = 0x7;
1132 +static const int prop_le_intr[] = { 0x26, 0x0 };
1133 +static const struct property propv_sbus_ledma_le[] = {
1134 + {"name", "le", sizeof("le")},
1135 + {"reg", (char*)&prop_le_reg[0], sizeof(prop_le_reg) },
1136 + {"busmaster-regval", (char*)&prop_le_busmaster_regval, sizeof(int)},
1137 + {"intr", (char*)&prop_le_intr[0], sizeof(prop_le_intr) },
1138 + {NULL, NULL, -1}
1141 +static const int prop_espdma_reg[] = {
1142 + 0x4, 0x08400000, 0x00000010,
1145 +static const struct property propv_sbus_espdma[] = {
1146 + {"name", "espdma", sizeof("espdma")},
1147 + {"reg", (char*)&prop_espdma_reg[0], sizeof(prop_espdma_reg) },
1148 + {NULL, NULL, -1}
1151 +static const int prop_esp_reg[] = {
1152 + 0x4, 0x08800000, 0x00000040,
1154 +static const int prop_esp_intr[] = { 0x24, 0x0 };
1155 +static const struct property propv_sbus_espdma_esp[] = {
1156 + {"name", "esp", sizeof("esp")},
1157 + {"reg", (char*)&prop_esp_reg[0], sizeof(prop_esp_reg) },
1158 + {"intr", (char*)&prop_esp_intr[0], sizeof(prop_esp_intr) },
1159 + {NULL, NULL, -1}
1162 +static const int prop_bpp_reg[] = {
1163 + 0x4, 0x0c800000, 0x0000001c,
1165 +static const int prop_bpp_intr[] = { 0x33, 0x0 };
1166 +static const struct property propv_sbus_bpp[] = {
1167 + {"name", "SUNW,bpp", sizeof("SUNW,bpp")},
1168 + {"reg", (char*)&prop_bpp_reg[0], sizeof(prop_bpp_reg) },
1169 + {"intr", (char*)&prop_bpp_intr[0], sizeof(prop_bpp_intr) },
1170 + {NULL, NULL, -1}
1173 +static const int prop_fd_intr[] = { 0x2b, 0x0 };
1174 +static const int prop_fd_reg[] = {
1175 + 0x0, 0x00400000, 0x0000000f,
1177 +static const struct property propv_obio_fd[] = {
1178 + {"name", "SUNW,fdtwo", sizeof("SUNW,fdtwo")},
1179 + {"reg", (char*)&prop_fd_reg[0], sizeof(prop_fd_reg) },
1180 + {"device_type", "block", sizeof("block") },
1181 + {"intr", (char*)&prop_fd_intr[0], sizeof(prop_fd_intr) },
1182 + {NULL, NULL, -1}
1185 +static const int prop_pw_intr[] = { 0x22, 0x0 };
1186 +static const int prop_pw_reg[] = {
1187 + 0x0, 0x00910000, 0x00000001,
1189 +static const struct property propv_obio_pw[] = {
1190 + {"name", "power", sizeof("power")},
1191 + {"reg", (char*)&prop_pw_reg[0], sizeof(prop_pw_reg) },
1192 + {"intr", (char*)&prop_pw_intr[0], sizeof(prop_pw_intr) },
1193 + {NULL, NULL, -1}
1196 +static const int prop_cf_reg[] = {
1197 + 0x0, 0x00800000, 0x00000001,
1199 +static const struct property propv_obio_cf[] = {
1200 + {"name", "slavioconfig", sizeof("slavioconfig")},
1201 + {"reg", (char*)&prop_cf_reg[0], sizeof(prop_cf_reg) },
1202 + {NULL, NULL, -1}
1205 +static const struct property propv_options[] = {
1206 + {"name", "options", sizeof("options")},
1207 + {"screen-#columns", "80", sizeof("80")},
1208 + {"screen-#rows", "25", sizeof("25")},
1209 + {"tpe-link-test?", "true", sizeof("true")},
1210 + {"ttya-mode", "9600,8,n,1,-", sizeof("9600,8,n,1,-")},
1211 + {"ttya-ignore-cd", "true", sizeof("true")},
1212 + {"ttya-rts-dtr-off", "false", sizeof("false")},
1213 + {"ttyb-mode", "9600,8,n,1,-", sizeof("9600,8,n,1,-")},
1214 + {"ttyb-ignore-cd", "true", sizeof("true")},
1215 + {"ttyb-rts-dtr-off", "false", sizeof("false")},
1216 + {NULL, NULL, -1}
1219 +static const struct node nodes[] = {
1220 + { &null_properties, 1, 0 }, /* 0 = big brother of root */
1221 + { propv_root, 0, 2 }, /* 1 "/" */
1222 + { propv_iommu, 11, 3 }, /* 2 "/iommu" */
1223 + { propv_sbus, 0, 4 }, /* 3 "/iommu/sbus" */
1224 + { propv_sbus_tcx, 5, 0 }, /* 4 "/iommu/sbus/SUNW,tcx" */
1225 + { propv_sbus_ledma, 7, 6 }, /* 5 "/iommu/sbus/ledma" */
1226 + { propv_sbus_ledma_le, 0, 0 }, /* 6 "/iommu/sbus/ledma/le" */
1227 + { propv_sbus_cs4231, 8, 0 }, /* 7 "/iommu/sbus/SUNW,CS4231 */
1228 + { propv_sbus_bpp, 9, 0 }, /* 8 "/iommu/sbus/SUNW,bpp */
1229 + { propv_sbus_espdma, 0, 10 }, /* 9 "/iommu/sbus/espdma" */
1230 + { propv_sbus_espdma_esp, 0, 0 }, /* 10 "/iommu/sbus/espdma/esp" */
1231 + { propv_cpu, 12, 0 }, /* 11 "/STP1012PGA" */
1232 + { propv_obio, 22, 13 }, /* 12 "/obio" */
1233 + { propv_obio_int, 14, 0 }, /* 13 "/obio/interrupt" */
1234 + { propv_obio_cnt, 15, 0 }, /* 14 "/obio/counter" */
1235 + { propv_obio_eep, 16, 0 }, /* 15 "/obio/eeprom" */
1236 + { propv_obio_auxio, 17, 0 }, /* 16 "/obio/auxio" */
1237 + { propv_obio_zs1, 18, 0 }, /* 17 "/obio/zs@0,100000"
1238 + Must be before zs@0,0! */
1239 + { propv_obio_zs, 19, 0 }, /* 18 "/obio/zs@0,0" */
1240 + { propv_obio_fd, 20, 0 }, /* 19 "/obio/SUNW,fdtwo" */
1241 + { propv_obio_pw, 21, 0 }, /* 20 "/obio/power" */
1242 + { propv_obio_cf, 0, 0 }, /* 21 "/obio/slavioconfig@0,800000" */
1243 + { propv_options, 0, 0 }, /* 22 "/options" */
1246 +static struct linux_mlist_v0 totphys[MAX_BANKS];
1247 +static struct linux_mlist_v0 totmap[1];
1248 +static struct linux_mlist_v0 totavail[MAX_BANKS];
1250 +static struct linux_mlist_v0 *ptphys;
1251 +static struct linux_mlist_v0 *ptmap;
1252 +static struct linux_mlist_v0 *ptavail;
1254 +static const struct linux_nodeops nodeops0 = {
1255 + obp_nextnode, /* int (*no_nextnode)(int node); */
1256 + obp_child, /* int (*no_child)(int node); */
1257 + obp_proplen, /* int (*no_proplen)(int node, char *name); */
1258 + obp_getprop, /* int (*no_getprop)(int node,char *name,char *val); */
1259 + obp_setprop, /* int (*no_setprop)(int node, char *name,
1260 + char *val, int len); */
1261 + obp_nextprop /* char * (*no_nextprop)(int node, char *name); */
1264 +static struct linux_arguments_v0 obp_arg;
1265 +static const struct linux_arguments_v0 * const obp_argp = &obp_arg;
1267 +static void (*synch_hook)(void);
1268 +static char obp_stdin, obp_stdout;
1270 +static int obp_nbgetchar(void);
1271 +static int obp_nbputchar(int ch);
1272 +static void obp_reboot(char *);
1273 +static void obp_abort(void);
1274 +static void obp_halt(void);
1275 +static int obp_devopen(char *str);
1276 +static int obp_devclose(int dev_desc);
1277 +static int obp_rdblkdev(int dev_desc, int num_blks, int blk_st, char *buf);
1279 +static void doublewalk(unsigned ptab1, unsigned va)
1281 +unsigned int proc_tablewalk(int ctx, unsigned int va);
1282 +unsigned int mem_tablewalk(unsigned int pa, unsigned int va);
1284 + proc_tablewalk(0, va);
1285 + if (ptab1 != 0) mem_tablewalk(ptab1, va);
1288 +static struct linux_romvec romvec0;
1290 +void *
1291 +init_openprom_qemu(int bankc, struct bank *bankv, unsigned hiphybas,
1292 + const char *cmdline, char boot_device, int nographic)
1294 + int i;
1296 + /*
1297 + * Avoid data segment allocations
1298 + */
1299 + ptphys = totphys;
1300 + ptmap = totmap;
1301 + ptavail = totavail;
1302 + /*
1303 + * Form memory descriptors.
1304 + */
1305 + for (i = 0; i < bankc; i++) {
1306 + totphys[i].theres_more = &totphys[i+1];
1307 + totphys[i].start_adr = (char*) bankv[i].start;
1308 + totphys[i].num_bytes = bankv[i].length;
1310 + totphys[i-1].theres_more = 0;
1312 + /*
1313 + * XXX Merged in normal PROM when full banks touch.
1314 + */
1315 + for (i = 0; i < bankc; i++) {
1316 + unsigned bankbase = bankv[i].start;
1317 + unsigned banksize = bankv[i].length;
1318 + if (hiphybas > bankbase &&
1319 + hiphybas < bankbase + banksize) {
1320 + banksize = hiphybas - bankbase;
1322 + totavail[i].theres_more = &totavail[i+1];
1323 + totavail[i].start_adr = (char*) bankbase;
1324 + totavail[i].num_bytes = banksize;
1326 + totavail[i-1].theres_more = 0;
1328 + totmap[0].theres_more = 0;
1329 + totmap[0].start_adr = (char*) PROLBASE;
1330 + totmap[0].num_bytes = PROLSIZE;
1332 + /*
1333 + * idprom
1334 + */
1335 + bcopy(idprom, obp_idprom, IDPROM_SIZE);
1337 + // Linux wants a R/W romvec table
1338 + romvec0.pv_magic_cookie = LINUX_OPPROM_MAGIC;
1339 + romvec0.pv_plugin_revision = 77;
1340 + romvec0.pv_printrev = 0x10203;
1341 + romvec0.pv_v0mem.v0_totphys = &ptphys;
1342 + romvec0.pv_v0mem.v0_prommap = &ptmap;
1343 + romvec0.pv_v0mem.v0_available = &ptavail;
1344 + romvec0.pv_nodeops = &nodeops0;
1345 + romvec0.pv_bootstr = (void *)doublewalk;
1346 + romvec0.pv_v0devops.v0_devopen = &obp_devopen;
1347 + romvec0.pv_v0devops.v0_devclose = &obp_devclose;
1348 + romvec0.pv_v0devops.v0_rdblkdev = &obp_rdblkdev;
1349 + romvec0.pv_stdin = &obp_stdin;
1350 + romvec0.pv_stdout = &obp_stdout;
1351 + romvec0.pv_getchar = obp_nbgetchar;
1352 + romvec0.pv_putchar = (void (*)(int))obp_nbputchar;
1353 + romvec0.pv_nbgetchar = obp_nbgetchar;
1354 + romvec0.pv_nbputchar = obp_nbputchar;
1355 + romvec0.pv_reboot = obp_reboot;
1356 + romvec0.pv_abort = obp_abort;
1357 + romvec0.pv_halt = obp_halt;
1358 + romvec0.pv_synchook = &synch_hook;
1359 + romvec0.pv_v0bootargs = &obp_argp;
1360 + switch(boot_device) {
1361 + default:
1362 + case 'a':
1363 + obp_arg.argv[0] = "fd()";
1364 + break;
1365 + case 'c':
1366 + obp_arg.argv[0] = "sd()";
1367 + break;
1368 + case 'n':
1369 + obp_arg.argv[0] = "le()";
1370 + break;
1372 + obp_arg.argv[1] = cmdline;
1374 + if (nographic) {
1375 + obp_stdin = PROMDEV_TTYA;
1376 + obp_stdout = PROMDEV_TTYA;
1377 + } else {
1378 + obp_stdin = PROMDEV_KBD;
1379 + obp_stdout = PROMDEV_SCREEN;
1381 + prop_zs_addr = map_io(0x71000000, 8);
1382 + prop_zs1_addr = map_io(0x71100000, 8);
1383 + return &romvec0;
1386 +static const struct property *find_property(int node,char *name)
1388 + const struct property *prop = &nodes[node].properties[0];
1389 + while (prop && prop->name) {
1390 + if (bcmp(prop->name, name, 128) == 0) return prop;
1391 + prop++;
1393 + return NULL;
1396 +static int obp_nextnode(int node)
1398 +#ifdef DEBUG_OBP
1399 + printk("obp_nextnode(%d) = %d\n", node, nodes[node].sibling);
1400 +#endif
1401 + return nodes[node].sibling;
1404 +static int obp_child(int node)
1406 +#ifdef DEBUG_OBP
1407 + printk("obp_child(%d) = %d\n", node, nodes[node].child);
1408 +#endif
1409 + return nodes[node].child;
1412 +static int obp_proplen(int node, char *name)
1414 + const struct property *prop = find_property(node,name);
1415 + if (prop) {
1416 +#ifdef DEBUG_OBP
1417 + printk("obp_proplen(%d, %s) = %d\n", node, name, prop->length);
1418 +#endif
1419 + return prop->length;
1421 +#ifdef DEBUG_OBP
1422 + printk("obp_proplen(%d, %s) (no prop)\n", node, name);
1423 +#endif
1424 + return -1;
1427 +static int obp_getprop(int node, char *name, char *value)
1429 + const struct property *prop;
1431 + if (!name) {
1432 + // NULL name means get first property
1433 +#ifdef DEBUG_OBP
1434 + printk("obp_getprop(%d, %x (NULL)) = %s\n", node, name,
1435 + nodes[node].properties[0].name);
1436 +#endif
1437 + return (int)nodes[node].properties[0].name;
1439 + prop = find_property(node,name);
1440 + if (prop) {
1441 + memcpy(value,prop->value,prop->length);
1442 +#ifdef DEBUG_OBP
1443 + printk("obp_getprop(%d, %s) = %s\n", node, name, value);
1444 +#endif
1445 + return prop->length;
1447 +#ifdef DEBUG_OBP
1448 + printk("obp_getprop(%d, %s): not found\n", node, name);
1449 +#endif
1450 + return -1;
1453 +static int obp_setprop(int node, char *name, char *value, int len)
1455 +#ifdef DEBUG_OBP
1456 + printk("obp_setprop(%d, %s) = %s (%d)\n", node, name, value, len);
1457 +#endif
1458 + return -1;
1461 +static const char *obp_nextprop(int node,char *name)
1463 + const struct property *prop;
1465 + if (!name || *name == '\0') {
1466 + // NULL name means get first property
1467 +#ifdef DEBUG_OBP
1468 + printk("obp_nextprop(%d, NULL) = %s\n", node,
1469 + nodes[node].properties[0].name);
1470 +#endif
1471 + return nodes[node].properties[0].name;
1473 + prop = find_property(node,name);
1474 + if (prop && prop[1].name) {
1475 +#ifdef DEBUG_OBP
1476 + printk("obp_nextprop(%d, %s) = %s\n", node, name, prop[1].name);
1477 +#endif
1478 + return prop[1].name;
1480 +#ifdef DEBUG_OBP
1481 + printk("obp_nextprop(%d, %s): not found\n", node, name);
1482 +#endif
1483 + return (const char *)-1;
1486 +static int obp_nbgetchar(void) {
1487 + extern struct vconterm dp0;
1488 + return vcon_getch(&dp0);
1491 +static int obp_nbputchar(int ch) {
1492 + printk("%c", ch);
1493 + return 0;
1496 +static void obp_reboot(char *str) {
1497 + printk("rebooting (%s): not implemented, freezing\n", str);
1498 + for (;;) {}
1501 +static void obp_abort() {
1502 + printk("abort, freezing\n");
1503 + for (;;) {}
1506 +static void obp_halt() {
1507 + printk("halt, freezing\n");
1508 + for (;;) {}
1511 +static int obp_devopen(char *str) {
1512 +#ifdef DEBUG_OBP
1513 + printk("open %s\n", str);
1514 +#endif
1515 + return 0;
1518 +static int obp_devclose(int dev_desc) {
1519 +#ifdef DEBUG_OBP
1520 + printk("close %d\n", dev_desc);
1521 +#endif
1522 + return 0;
1525 +static int obp_rdblkdev(int dev_desc, int num_blks, int blk_st, char *buf) {
1526 +#ifdef DEBUG_OBP
1527 + printk("rdblkdev: fd %d, num_blks %d, blk_st %d, buf 0x%x\n", dev_desc, num_blks, blk_st, buf);
1528 +#endif
1529 + //buf[8] = 'L';
1530 + return num_blks;
1532 diff -ruN proll_18.orig/qemu/system_qemu.c proll-patch8/qemu/system_qemu.c
1533 --- proll_18.orig/qemu/system_qemu.c 1970-01-01 00:00:00.000000000 +0000
1534 +++ proll-patch8/qemu/system_qemu.c 2005-03-02 16:10:20.000000000 +0000
1535 @@ -0,0 +1,416 @@
1536 +/**
1537 + ** Proll (PROM replacement)
1538 + ** system.c: shared miscallenea.
1539 + ** Copyright 1999 Pete Zaitcev
1540 + ** This code is licensed under GNU General Public License.
1541 + **/
1542 +#include <stdarg.h>
1543 +#include <asi.h>
1544 +#include <crs.h>
1545 +#ifndef NULL
1546 +#define NULL ((void*)0)
1547 +#endif
1549 +#include "pgtsrmmu.h"
1551 +#include "vconsole.h"
1552 +#include <timer.h> /* Local copy of 2.2 style include */
1553 +#include <general.h> /* __P() */
1554 +#include <net.h> /* init_net() */
1555 +#include <romlib.h> /* we are a provider for part of this. */
1556 +#include <netpriv.h> /* myipaddr */
1557 +#include <arpa.h>
1558 +#include <system.h> /* our own prototypes */
1561 + * We export this.
1562 + */
1563 +char idprom[IDPROM_SIZE];
1567 + * Create an I/O mapping to pa[size].
1568 + * Returns va of the mapping or 0 if unsuccessful.
1569 + */
1570 +void *
1571 +map_io(unsigned pa, int size)
1573 + void *va;
1574 + unsigned int npages;
1575 + unsigned int off;
1576 + unsigned int mva;
1578 + off = pa & (PAGE_SIZE-1);
1579 + npages = (off + size + (PAGE_SIZE-1)) / PAGE_SIZE;
1580 + pa &= ~(PAGE_SIZE-1);
1582 + va = mem_alloc(&cio, npages*PAGE_SIZE, PAGE_SIZE);
1583 + if (va == 0) return va;
1585 + mva = (unsigned int) va;
1586 + /* printk("map_io: va 0x%x pa 0x%x off 0x%x npages %d\n", va, pa, off, npages); */ /* P3 */
1587 + while (npages-- != 0) {
1588 + map_page(pmem.pl1, mva, pa, 1, pmem.pbas);
1589 + mva += PAGE_SIZE;
1590 + pa += PAGE_SIZE;
1593 + return (void *)((unsigned int)va + off);
1597 + * Tablewalk routine used for testing.
1598 + * Returns PTP/PTE.
1599 + */
1600 +unsigned int
1601 +proc_tablewalk(int ctx, unsigned int va)
1603 + unsigned int pa1;
1605 + __asm__ __volatile__ ("lda [%1] %2, %0" :
1606 + "=r" (pa1) :
1607 + "r" (AC_M_CTPR), "i" (ASI_M_MMUREGS));
1608 + /* printk(" ctpr %x ctx %x\n", pa1, ctx); */ /* P3 */
1609 + pa1 <<= 4;
1610 + pa1 = ld_bypass(pa1 + (ctx << 2));
1611 + if ((pa1 & 0x03) == 0) goto invalid;
1612 + return mem_tablewalk((pa1 & 0xFFFFFFF0) << 4, va);
1614 +invalid:
1615 + printk(" invalid %x\n", pa1);
1616 + return 0;
1620 + * Walk the tables in memory, starting at physical address pa.
1621 + */
1622 +unsigned int
1623 +mem_tablewalk(unsigned int pa, unsigned int va)
1625 + unsigned int pa1;
1627 + printk("pa %x va %x", pa, va);
1628 + pa1 = ld_bypass(pa + (((va&0xFF000000)>>24) << 2));
1629 + if ((pa1 & 0x03) == 0) goto invalid;
1630 + printk(" l1 %x", pa1);
1631 + pa1 <<= 4; pa1 &= 0xFFFFFF00;
1632 + pa1 = ld_bypass(pa1 + (((va&0x00FC0000)>>18) << 2));
1633 + if ((pa1 & 0x03) == 0) goto invalid;
1634 + printk(" l2 %x", pa1);
1635 + pa1 <<= 4; pa1 &= 0xFFFFFF00;
1636 + pa1 = ld_bypass(pa1 + (((va&0x0003F000)>>12) << 2));
1637 + if ((pa1 & 0x03) == 0) goto invalid;
1638 + printk(" l3 %x", pa1);
1639 + printk(" off %x\n", va&0x00000FFF);
1640 + return pa1;
1641 +invalid:
1642 + printk(" invalid %x\n", pa1);
1643 + return 0;
1647 + * Make CPU page tables.
1648 + * Returns pointer to context table.
1649 + * Here we ignore memory allocation errors which "should not happen"
1650 + * because we cannot print anything anyways if memory initialization fails.
1651 + */
1652 +void makepages(struct phym *t, unsigned int highbase)
1654 + unsigned int *ctp, *l1, pte;
1655 + int i;
1656 + unsigned int pa, va;
1658 + ctp = mem_zalloc(&cmem, NCTX_SWIFT*sizeof(int), NCTX_SWIFT*sizeof(int));
1659 + l1 = mem_zalloc(&cmem, 256*sizeof(int), 256*sizeof(int));
1661 + pte = SRMMU_ET_PTD | (((unsigned int)l1 - PROLBASE + highbase) >> 4);
1662 + for (i = 0; i < NCTX_SWIFT; i++) {
1663 + ctp[i] = pte;
1666 + pa = PROLBASE;
1667 + for (va = PROLBASE; va < PROLDATA; va += PAGE_SIZE) {
1668 + map_page(l1, va, pa, 0, highbase);
1669 + pa += PAGE_SIZE;
1671 + pa = highbase + PROLDATA - PROLBASE;
1672 + for (va = PROLDATA; va < PROLBASE + PROLSIZE; va += PAGE_SIZE) {
1673 + map_page(l1, va, pa, 0, highbase);
1674 + pa += PAGE_SIZE;
1677 + /* We need to start from LOADBASE, but kernel wants PAGE_SIZE. */
1678 + pa = 0;
1679 + for (va = 0; va < LOWMEMSZ; va += PAGE_SIZE) {
1680 + map_page(l1, va, pa, 0, highbase);
1681 + pa += PAGE_SIZE;
1684 + t->pctp = ctp;
1685 + t->pl1 = l1;
1686 + t->pbas = highbase;
1690 + * Create a memory mapping from va to epa in page table pgd.
1691 + * highbase is used for v2p translation.
1692 + */
1693 +int
1694 +map_page(unsigned int *pgd, unsigned int va,
1695 + unsigned int epa, int type, unsigned int highbase)
1697 + unsigned int pte;
1698 + unsigned int *p;
1699 + unsigned int pa;
1701 + pte = pgd[((va)>>SRMMU_PGDIR_SHIFT) & (SRMMU_PTRS_PER_PGD-1)];
1702 + if ((pte & SRMMU_ET_MASK) == SRMMU_ET_INVALID) {
1703 + p = mem_zalloc(&cmem, SRMMU_PTRS_PER_PMD*sizeof(int),
1704 + SRMMU_PTRS_PER_PMD*sizeof(int));
1705 + if (p == 0) goto drop;
1706 + pte = SRMMU_ET_PTD |
1707 + (((unsigned int)p - PROLBASE + highbase) >> 4);
1708 + pgd[((va)>>SRMMU_PGDIR_SHIFT) & (SRMMU_PTRS_PER_PGD-1)] = pte;
1709 + /* barrier() */
1712 + pa = ((pte & 0xFFFFFFF0) << 4);
1713 + pa += (((va)>>SRMMU_PMD_SHIFT & (SRMMU_PTRS_PER_PMD-1)) << 2);
1714 + pte = ld_bypass(pa);
1715 + if ((pte & SRMMU_ET_MASK) == SRMMU_ET_INVALID) {
1716 + p = mem_zalloc(&cmem, SRMMU_PTRS_PER_PTE*sizeof(int),
1717 + SRMMU_PTRS_PER_PTE*sizeof(int));
1718 + if (p == 0) goto drop;
1719 + pte = SRMMU_ET_PTD |
1720 + (((unsigned int)p - PROLBASE + highbase) >> 4);
1721 + st_bypass(pa, pte);
1724 + pa = ((pte & 0xFFFFFFF0) << 4);
1725 + pa += (((va)>>PAGE_SHIFT & (SRMMU_PTRS_PER_PTE-1)) << 2);
1727 + pte = SRMMU_ET_PTE | ((epa & PAGE_MASK) >> 4);
1728 + if (type) { /* I/O */
1729 + pte |= SRMMU_REF;
1730 + /* SRMMU cannot make Supervisor-only, but not exectutable */
1731 + pte |= SRMMU_PRIV;
1732 + } else { /* memory */
1733 + pte |= SRMMU_REF|SRMMU_CACHE;
1734 + pte |= SRMMU_PRIV; /* Supervisor only access */
1736 + st_bypass(pa, pte);
1737 + return 0;
1739 +drop:
1740 + return -1;
1744 + * Switch page tables.
1745 + */
1746 +void
1747 +init_mmu_swift(unsigned int ctp_phy)
1749 + unsigned int addr;
1751 + /*
1752 + * Flush cache
1753 + */
1754 + for (addr = 0; addr < 0x2000; addr += 0x10) {
1755 + __asm__ __volatile__ ("sta %%g0, [%0] %1\n\t" : :
1756 + "r" (addr), "i" (ASI_M_DATAC_TAG));
1757 + __asm__ __volatile__ ("sta %%g0, [%0] %1\n\t" : :
1758 + "r" (addr<<1), "i" (ASI_M_TXTC_TAG));
1761 + /*
1762 + * Switch ctx table
1763 + */
1764 + ctp_phy >>= 4;
1765 + /* printk("done flushing, switching to %x\n", ctp_phy); */
1766 + __asm__ __volatile__ ("sta %0, [%1] %2\n\t" : :
1767 + "r" (ctp_phy), "r" (AC_M_CTPR), "i" (ASI_M_MMUREGS));
1769 + /*
1770 + * Flush old page table references
1771 + */
1772 + __asm__ __volatile__ ("sta %%g0, [%0] %1\n\t" : :
1773 + "r" (0x400), "i" (ASI_M_FLUSH_PROBE) : "memory");
1777 + * add_timer, del_timer
1778 + * This should go into sched.c, but we have it split for different archs.
1779 + */
1780 +struct timer_list_head {
1781 + struct timer_list *head, *tail;
1784 +static struct timer_list_head timers; /* Anonymous heap of timers */
1786 +void add_timer(struct timer_list *timer) {
1787 + struct timer_list *p;
1788 + if (timer->prev != NULL || timer->next != NULL) {
1789 + printk("bug: kernel timer added twice at 0x%x.\n",
1790 + __builtin_return_address(0));
1791 + return;
1793 + if ((p = timers.tail) != NULL) {
1794 + timer->prev = p;
1795 + p->next = timer;
1796 + timers.tail = timer;
1797 + } else {
1798 + timers.head = timer;
1799 + timers.tail = timer;
1801 + return;
1804 +int del_timer(struct timer_list *timer) {
1805 + struct timer_list *p;
1806 + int ret;
1808 + if (timers.head == timer) timers.head = timer->next;
1809 + if (timers.tail == timer) timers.tail = timer->prev;
1810 + if ((p = timer->prev) != NULL) p->next = timer->next;
1811 + if ((p = timer->next) != NULL) p->prev = timer->prev;
1812 + ret = timer->next != 0 || timer->prev != 0;
1813 + timer->next = NULL;
1814 + timer->prev = NULL;
1815 + return ret;
1818 +void run_timers() {
1819 + struct timer_list *p;
1821 + p = timers.head;
1822 + while (p != NULL) {
1823 + if (p->expires < jiffies) {
1824 + del_timer(p); /* XXX make nonstatic member */
1825 + (*p->function)(p->data);
1826 + p = timers.head;
1827 + } else {
1828 + p = p->next;
1834 + * Allocate memory. This is reusable.
1835 + */
1836 +void mem_init(struct mem *t, char *begin, char *limit)
1838 + t->start = begin;
1839 + t->uplim = limit;
1840 + t->curp = begin;
1843 +void mem_fini(struct mem *t)
1845 + t->curp = 0;
1848 +void *mem_alloc(struct mem *t, int size, int align)
1850 + char *p;
1852 + p = (char *)((((unsigned int)t->curp) + (align-1)) & ~(align-1));
1853 + if (p >= t->uplim || p + size > t->uplim) return 0;
1854 + t->curp = p + size;
1855 + return p;
1858 +void *mem_zalloc(struct mem *t, int size, int align)
1860 + char *p;
1862 + if ((p = mem_alloc(t, size, align)) != 0) bzero(p, size);
1863 + return p;
1867 + * Library functions
1868 + */
1869 +void bzero(void *s, int len) {
1870 + while (len--) *((char *)s)++ = 0;
1873 +void bcopy(const void *f, void *t, int len) {
1874 + while (len--) *((char *)t)++ = *((char *)f)++;
1877 +/* Comparison is 7-bit */
1878 +int bcmp(const void *s1, const void *s2, int len)
1880 + int i;
1881 + char ch;
1883 + while (len--) {
1884 + ch = *((char *)s1)++;
1885 + if ((i = ch - *((char *)s2)++) != 0)
1886 + return i;
1887 + if (ch == 0)
1888 + return 0;
1890 + return 0;
1893 +int strlen(const char *s) {
1894 + const char *p;
1895 + for (p = s; *p != 0; p++) { }
1896 + return p - s;
1899 +extern void *printk_fn;
1901 +void printk(char *fmt, ...)
1903 + struct prf_fp {
1904 + void *xfp;
1905 + void (*write)(void *, char *, int);
1906 + } prfa;
1907 + extern void prf(struct prf_fp *, char *fmt, va_list adx);
1908 + va_list x1;
1910 + va_start(x1, fmt);
1911 + prfa.xfp = &dp0;
1912 + prfa.write = printk_fn;
1913 + prf(&prfa, fmt, x1);
1914 + va_end(x1);
1917 +void fatal()
1919 + printk("fatal.");
1920 +loop: goto loop;
1924 + * Get the highest bit number from the mask.
1925 + */
1926 +int highc(int mask, int size)
1928 + int m1;
1930 + m1 = 1 << size;
1931 + while (size != 0) {
1932 + size--;
1933 + m1 >>= 1;
1934 + if (m1 & mask) break;
1936 + return size;
1940 + */
1941 +unsigned int ld_bp_swap(unsigned int ptr) {
1942 + unsigned int n;
1943 + n = ld_bypass(ptr);
1944 + n = (n>>24 & 0xFF) | (n>>8 & 0xFF00) | ((n&0xFF00) << 8) | (n<<24);
1945 + return n;
1948 +void st_bp_swap(unsigned int ptr, unsigned int n) {
1949 + n = (n>>24 & 0xFF) | (n>>8 & 0xFF00) | ((n&0xFF00) << 8) | (n<<24);
1950 + st_bypass(ptr, n);
1952 diff -ruN proll_18.orig/src/arp.c proll-patch8/src/arp.c
1953 --- proll_18.orig/src/arp.c 2001-12-24 05:12:31.000000000 +0000
1954 +++ proll-patch8/src/arp.c 2004-11-13 15:50:49.000000000 +0000
1955 @@ -45,7 +45,7 @@
1956 #endif
1957 static struct arp_cache arp_list[ARPNUM]; /* ARP address cache */
1958 static int next_arp; /* next table entry */
1959 -static t_ipaddr def_gw = IP_ANY; /* default routing */
1960 +static t_ipaddr def_gw; /* default routing */
1964 @@ -144,7 +144,7 @@
1966 * Resolve IP address and return pointer to hardware address.
1968 -unsigned char *ip_resolve(ip)
1969 +const unsigned char *ip_resolve(ip)
1970 t_ipaddr ip;
1972 int i;
1973 @@ -230,14 +230,11 @@
1975 int init_arp()
1977 - /* Set name of module for error messages */
1978 - net_module_name = "arp";
1980 #ifndef NOARP
1981 /* Register ARP packet type and set send buffer pointer */
1982 if ((arpbuf = (struct arphdr *)reg_type(htons(ETH_P_ARP), arp_recv)) == NULL)
1983 return(FALSE);
1984 #endif
1986 + def_gw = IP_ANY;
1987 return(TRUE);
1989 diff -ruN proll_18.orig/src/arp.h proll-patch8/src/arp.h
1990 --- proll_18.orig/src/arp.h 1999-03-18 03:39:43.000000000 +0000
1991 +++ proll-patch8/src/arp.h 2004-11-13 15:50:49.000000000 +0000
1992 @@ -104,7 +104,7 @@
1993 extern int init_arp __P((void));
1995 /* Resolve IP address and return pointer to hardware address */
1996 -extern unsigned char *ip_resolve __P((t_ipaddr ip));
1997 +extern const unsigned char *ip_resolve __P((t_ipaddr ip));
1999 /* Add a new antry to the ARP cache */
2000 extern void addcache __P((unsigned char *ha, t_ipaddr ip));
2001 diff -ruN proll_18.orig/src/hconsole.c proll-patch8/src/hconsole.c
2002 --- proll_18.orig/src/hconsole.c 2002-07-23 05:52:48.000000000 +0000
2003 +++ proll-patch8/src/hconsole.c 2005-03-02 17:03:09.000000000 +0000
2004 @@ -29,6 +29,10 @@
2005 struct raster r_master; /* For a case of resize, whole fb */
2006 struct raster r_0; /* malloc() erzatz */
2008 +#ifdef QEMU
2009 +extern unsigned int q_height, q_width;
2010 +#endif
2012 int hcon_init(struct hconsole *t, unsigned int a0)
2014 struct raster *q, *r;
2015 @@ -42,7 +46,11 @@
2016 * No probing sequence or argument passing, hardcode everything. XXX
2018 raster8_cons_a(q, 768, 1024, (char *)a0);
2019 +#ifndef QEMU
2020 raster_cons_2(r, q, 768-(24*11)-1, 1024-(8*80)-1, (24*11), (8*80));
2021 +#else
2022 + raster_cons_2(r, q, 0, 0, q_height, q_width);
2023 +#endif
2024 t->r_ = r;
2025 t->r0_ = q;
2026 t->f_ = &f_master;
2027 diff -ruN proll_18.orig/src/lat7_2.bm proll-patch8/src/lat7_2.bm
2028 --- proll_18.orig/src/lat7_2.bm 1999-02-27 05:48:54.000000000 +0000
2029 +++ proll-patch8/src/lat7_2.bm 2004-11-13 15:50:49.000000000 +0000
2030 @@ -1,6 +1,6 @@
2031 #define lat7_2_width 128
2032 #define lat7_2_height 88
2033 -static unsigned char lat7_2_bits[] = {
2034 +static unsigned const char lat7_2_bits[] = {
2035 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2036 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x12, 0x1e, 0x0c, 0x02, 0x70, 0x18,
2037 0x22, 0x22, 0x18, 0x00, 0x00, 0x18, 0x18, 0xff, 0x18, 0x00, 0x12, 0x02,
2038 diff -ruN proll_18.orig/src/lat7_2_swapped.bm proll-patch8/src/lat7_2_swapped.bm
2039 --- proll_18.orig/src/lat7_2_swapped.bm 1970-01-01 00:00:00.000000000 +0000
2040 +++ proll-patch8/src/lat7_2_swapped.bm 2004-11-13 15:50:49.000000000 +0000
2041 @@ -0,0 +1,121 @@
2042 +#define lat7_2_width 128
2043 +#define lat7_2_height 88
2044 +static unsigned const char lat7_2_bits[] = {
2045 + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00,
2046 + 0x55, 0x00, 0x2a, 0x00, 0x55, 0x00, 0x2a, 0x00, 0x55, 0x00, 0x00, 0x48,
2047 + 0x48, 0x78, 0x48, 0x5f, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x78, 0x40,
2048 + 0x70, 0x40, 0x4f, 0x08, 0x0e, 0x08, 0x08, 0x00, 0x00, 0x30, 0x40, 0x40,
2049 + 0x40, 0x3e, 0x09, 0x0e, 0x0a, 0x09, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40,
2050 + 0x7f, 0x08, 0x0e, 0x08, 0x08, 0x00, 0x00, 0x0e, 0x0a, 0x0e, 0x00, 0x00,
2051 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00,
2052 + 0x7e, 0x00, 0x00, 0x00, 0x00, 0x44, 0x64, 0x54, 0x4c, 0x54, 0x10, 0x10,
2053 + 0x10, 0x1f, 0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x1f, 0x04, 0x04, 0x04,
2054 + 0x04, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x00, 0x00, 0x00, 0x00,
2055 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x00,
2056 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
2057 + 0x18, 0x18, 0x18, 0x18, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
2058 + 0x18, 0x18, 0x18, 0xff, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0xff, 0x00,
2059 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
2060 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2061 + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2062 + 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2063 + 0x00, 0x00, 0xff, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18,
2064 + 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18,
2065 + 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00,
2066 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, 0x00,
2067 + 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00,
2068 + 0x06, 0x0c, 0x18, 0x30, 0x18, 0x6c, 0x36, 0x18, 0x0c, 0x00, 0x00, 0x60,
2069 + 0x30, 0x18, 0x0c, 0x18, 0x36, 0x6c, 0x18, 0x30, 0x00, 0x00, 0x7f, 0x36,
2070 + 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x7e,
2071 + 0x18, 0x7e, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x36, 0x30, 0x78,
2072 + 0x30, 0x72, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18,
2073 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42,
2074 + 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2075 + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00,
2076 + 0x00, 0x00, 0x00, 0x66, 0x66, 0x22, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00,
2077 + 0x00, 0x00, 0x36, 0x7f, 0x36, 0x36, 0x36, 0x7f, 0x36, 0x00, 0x00, 0x00,
2078 + 0x00, 0x66, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00,
2079 + 0x72, 0x56, 0x6c, 0x18, 0x36, 0x6a, 0x4e, 0x00, 0x00, 0x00, 0x00, 0x18,
2080 + 0x24, 0x28, 0x30, 0x4a, 0x44, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18,
2081 + 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x18,
2082 + 0x18, 0x18, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x18, 0x18,
2083 + 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0x7e, 0x3c,
2084 + 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18,
2085 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18,
2086 + 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
2087 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
2088 + 0x00, 0x00, 0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x40, 0x00, 0x00, 0x00,
2089 + 0x00, 0x3c, 0x46, 0x4e, 0x5a, 0x72, 0x62, 0x3c, 0x00, 0x00, 0x00, 0x00,
2090 + 0x18, 0x38, 0x58, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x3c,
2091 + 0x66, 0x06, 0x0c, 0x18, 0x32, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66,
2092 + 0x06, 0x1c, 0x06, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30,
2093 + 0x66, 0x7e, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x60, 0x7c, 0x66,
2094 + 0x06, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x60, 0x7c, 0x66, 0x66,
2095 + 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x46, 0x06, 0x0c, 0x18, 0x30,
2096 + 0x30, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x66, 0x66, 0x3c,
2097 + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x3c, 0x00,
2098 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00,
2099 + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x08, 0x10, 0x00,
2100 + 0x00, 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00,
2101 + 0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
2102 + 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66,
2103 + 0x06, 0x0c, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, 0x5e,
2104 + 0x56, 0x5e, 0x40, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, 0x66,
2105 + 0x7e, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x66, 0x66, 0x7c, 0x66,
2106 + 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x60, 0x66,
2107 + 0x3c, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c,
2108 + 0x00, 0x00, 0x00, 0x00, 0x7e, 0x62, 0x60, 0x78, 0x60, 0x62, 0x7e, 0x00,
2109 + 0x00, 0x00, 0x00, 0x7e, 0x62, 0x60, 0x78, 0x60, 0x60, 0x60, 0x00, 0x00,
2110 + 0x00, 0x00, 0x3c, 0x66, 0x60, 0x6e, 0x66, 0x66, 0x3e, 0x00, 0x00, 0x00,
2111 + 0x00, 0x66, 0x66, 0x66, 0x7e, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00,
2112 + 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x7e,
2113 + 0x46, 0x06, 0x06, 0x06, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6c,
2114 + 0x78, 0x70, 0x78, 0x6c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x60,
2115 + 0x60, 0x60, 0x62, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x41, 0x63, 0x77, 0x7f,
2116 + 0x6b, 0x63, 0x63, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x76, 0x7e, 0x6e,
2117 + 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x66,
2118 + 0x3c, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60,
2119 + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x6e, 0x3c, 0x02,
2120 + 0x00, 0x00, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x00, 0x00,
2121 + 0x00, 0x00, 0x3c, 0x66, 0x60, 0x3c, 0x06, 0x66, 0x3c, 0x00, 0x00, 0x00,
2122 + 0x00, 0x7e, 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
2123 + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x66,
2124 + 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x63, 0x63,
2125 + 0x63, 0x6b, 0x6b, 0x7f, 0x36, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x3c,
2126 + 0x18, 0x3c, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x3c,
2127 + 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x46, 0x0c, 0x18, 0x30,
2128 + 0x62, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30,
2129 + 0x3c, 0x00, 0x00, 0x00, 0x00, 0x40, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02,
2130 + 0x00, 0x00, 0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00,
2131 + 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2132 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
2133 + 0x00, 0x08, 0x10, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2134 + 0x00, 0x3c, 0x06, 0x3e, 0x66, 0x66, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x60,
2135 + 0x60, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2136 + 0x3c, 0x66, 0x60, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06,
2137 + 0x3e, 0x66, 0x66, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66,
2138 + 0x7e, 0x60, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x36, 0x30, 0x30, 0x78,
2139 + 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x66, 0x66, 0x66,
2140 + 0x3e, 0x06, 0x3c, 0x00, 0x00, 0x60, 0x60, 0x60, 0x7c, 0x66, 0x66, 0x66,
2141 + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x1c, 0x00,
2142 + 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x6c, 0x38,
2143 + 0x00, 0x00, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x7c, 0x66, 0x00, 0x00, 0x00,
2144 + 0x00, 0x60, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00,
2145 + 0x00, 0x00, 0x76, 0x7f, 0x6b, 0x6b, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00,
2146 + 0x00, 0x6c, 0x76, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2147 + 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c,
2148 + 0x66, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x66,
2149 + 0x66, 0x66, 0x3e, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x72, 0x60,
2150 + 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x60, 0x3c, 0x06,
2151 + 0x3c, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x78, 0x30, 0x30, 0x36, 0x1c,
2152 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3a, 0x00,
2153 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00,
2154 + 0x00, 0x00, 0x00, 0x00, 0x63, 0x6b, 0x6b, 0x6b, 0x36, 0x00, 0x00, 0x00,
2155 + 0x00, 0x00, 0x00, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00,
2156 + 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x3c, 0x00, 0x00, 0x00,
2157 + 0x00, 0x7e, 0x0c, 0x18, 0x30, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18,
2158 + 0x18, 0x30, 0x18, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18,
2159 + 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x30, 0x18, 0x18, 0x0c,
2160 + 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6c, 0x00, 0x00, 0x00,
2161 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x42, 0x00, 0x00, 0x00, 0x00,
2162 + 0x00, 0x00, 0x00, 0x00};
2163 diff -ruN proll_18.orig/src/le.c proll-patch8/src/le.c
2164 --- proll_18.orig/src/le.c 2002-07-23 05:52:49.000000000 +0000
2165 +++ proll-patch8/src/le.c 2004-11-13 15:50:49.000000000 +0000
2166 @@ -185,8 +185,6 @@
2167 unsigned short rap; /* register address port */
2170 -int sparc_lance_debug = 2;
2172 /* The Lance uses 24 bit addresses */
2173 /* On the Sun4c the DVMA will provide the remaining bytes for us */
2174 /* On the Sun4m we have to instruct the ledma to provide them */
2175 diff -ruN proll_18.orig/src/netinit.c proll-patch8/src/netinit.c
2176 --- proll_18.orig/src/netinit.c 2002-09-13 21:53:33.000000000 +0000
2177 +++ proll-patch8/src/netinit.c 2004-11-13 15:50:49.000000000 +0000
2178 @@ -49,13 +49,20 @@
2179 unsigned char myhwaddr[ETH_ALEN]; /* my own hardware addr */
2180 t_ipaddr myipaddr; /* my own IP address */
2181 t_ipaddr mynetmask; /* my own netmask */
2182 - char *net_module_name; /* name of init module */
2183 t_ipaddr servaddr; /* IP of RARP&TFTP server */
2185 /* Broadcast hardware address */
2186 -unsigned char bcasthw[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2187 +const unsigned char bcasthw[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
2190 +unsigned int seed;
2192 +/* This is taken from x86 to be used in network kernel. Returns 15 bits. */
2193 +short int random()
2195 + seed = (seed + 23968)*0x015A4E35 >> 1;
2196 + return seed & 0x7FFF;
2200 **************************************************************************
2201 @@ -104,10 +111,17 @@
2203 void init_net()
2205 + /* Avoid data segment allocations */
2206 + seed = 151;
2208 /* Initialize the different network layer modules */
2209 init_packet();
2210 - if (!init_arp() || !init_udp()) {
2211 - printf("\nERROR: init_%s\n", net_module_name);
2212 + if (!init_arp()) {
2213 + printf("\nERROR: init_arp\n");
2214 + fatal();
2216 + if (!init_udp()) {
2217 + printf("\nERROR: init_udp\n");
2218 fatal();
2221 diff -ruN proll_18.orig/src/netpriv.h proll-patch8/src/netpriv.h
2222 --- proll_18.orig/src/netpriv.h 1999-04-27 05:39:37.000000000 +0000
2223 +++ proll-patch8/src/netpriv.h 2004-11-13 15:50:49.000000000 +0000
2224 @@ -130,10 +130,9 @@
2227 extern unsigned char myhwaddr[ETH_ALEN]; /* my own hardware address */
2228 -extern unsigned char bcasthw[ETH_ALEN]; /* broadcast hardware addr */
2229 +extern const unsigned char bcasthw[ETH_ALEN]; /* broadcast hardware addr */
2230 extern t_ipaddr myipaddr; /* my own IP address */
2231 extern t_ipaddr mynetmask; /* netmask for my network */
2232 -extern char *net_module_name; /* initialized module's name */
2233 extern t_ipaddr servaddr; /* server IP address */
2236 @@ -150,7 +149,7 @@
2237 extern unsigned char *reg_type __P((int typeval, int (* receive)()));
2239 /* Write a packet to the network */
2240 -extern int write_packet __P((int bufsize, int typeval, unsigned char *addr));
2241 +extern int write_packet __P((int bufsize, int typeval, const unsigned char *addr));
2243 /* Empty read buffer */
2244 extern void empty_buf __P((void));
2245 diff -ruN proll_18.orig/src/openprom.h proll-patch8/src/openprom.h
2246 --- proll_18.orig/src/openprom.h 2002-07-14 02:26:30.000000000 +0000
2247 +++ proll-patch8/src/openprom.h 2004-11-13 15:50:49.000000000 +0000
2248 @@ -54,20 +54,20 @@
2251 struct linux_mem_v0 {
2252 - struct linux_mlist_v0 **v0_totphys;
2253 - struct linux_mlist_v0 **v0_prommap;
2254 - struct linux_mlist_v0 **v0_available; /* What we can use */
2255 + struct linux_mlist_v0 * const *v0_totphys;
2256 + struct linux_mlist_v0 * const *v0_prommap;
2257 + struct linux_mlist_v0 * const *v0_available; /* What we can use */
2260 /* Arguments sent to the kernel from the boot prompt. */
2261 struct linux_arguments_v0 {
2262 - char *argv[8];
2263 + const char *argv[8];
2264 char args[100];
2265 char boot_dev[2];
2266 int boot_dev_ctrl;
2267 int boot_dev_unit;
2268 int dev_partition;
2269 - char *kernel_file_name;
2270 + const char *kernel_file_name;
2271 void *aieee1; /* XXX */
2274 @@ -91,13 +91,13 @@
2275 struct linux_mem_v0 pv_v0mem;
2277 /* Node operations. */
2278 - struct linux_nodeops *pv_nodeops;
2279 + const struct linux_nodeops *pv_nodeops;
2281 char **pv_bootstr;
2282 struct linux_dev_v0_funcs pv_v0devops;
2284 - char *pv_stdin;
2285 - char *pv_stdout;
2286 + const char *pv_stdin;
2287 + const char *pv_stdout;
2288 #define PROMDEV_KBD 0 /* input from keyboard */
2289 #define PROMDEV_SCREEN 0 /* output to screen */
2290 #define PROMDEV_TTYA 1 /* in/out to ttya */
2291 @@ -127,7 +127,7 @@
2292 void (*v2_eval)(char *str);
2293 } pv_fortheval;
2295 - struct linux_arguments_v0 **pv_v0bootargs;
2296 + const struct linux_arguments_v0 * const *pv_v0bootargs;
2298 /* Get ether address. */
2299 unsigned int (*pv_enaddr)(int d, char *enaddr);
2300 @@ -175,7 +175,7 @@
2301 int (*no_proplen)(int node, char *name);
2302 int (*no_getprop)(int node, char *name, char *val);
2303 int (*no_setprop)(int node, char *name, char *val, int len);
2304 - char * (*no_nextprop)(int node, char *name);
2305 + const char * (*no_nextprop)(int node, char *name);
2308 /* More fun PROM structures for device probing. */
2309 diff -ruN proll_18.orig/src/packet.c proll-patch8/src/packet.c
2310 --- proll_18.orig/src/packet.c 2000-02-11 04:56:45.000000000 +0000
2311 +++ proll-patch8/src/packet.c 2004-11-13 15:50:49.000000000 +0000
2312 @@ -41,7 +41,7 @@
2313 int aligner;
2314 } wbuf;
2315 static struct sk_buff *rskb;
2316 -static int nqskb = 0;
2317 +static int nqskb;
2320 void init_packet()
2321 @@ -62,6 +62,8 @@
2322 for (i = 0; i < MAXSKBS; i++) {
2323 skev[i].skb.allocn = i;
2326 + nqskb = 0;
2329 unsigned char *reg_type(int ptype, int (*func)())
2330 @@ -81,7 +83,7 @@
2331 return wbuf.s;
2334 -int write_packet(int leng, int type, unsigned char *dst)
2335 +int write_packet(int leng, int type, const unsigned char *dst)
2337 struct sk_buff *skb;
2338 unsigned char *s;
2339 diff -ruN proll_18.orig/src/printf.c proll-patch8/src/printf.c
2340 --- proll_18.orig/src/printf.c 1999-03-19 07:03:59.000000000 +0000
2341 +++ proll-patch8/src/printf.c 2004-11-13 15:50:49.000000000 +0000
2342 @@ -19,7 +19,7 @@
2343 static void printn(struct prf_fp *, unsigned long, unsigned int);
2344 static void putchar(char, struct prf_fp *);
2346 -static char hextab[] = "0123456789ABCDEF";
2347 +static const char hextab[] = "0123456789ABCDEF";
2350 * Scaled down version of C Library printf.
2351 @@ -41,7 +41,7 @@
2352 void
2353 prf(struct prf_fp *filog, char *fmt, va_list adx)
2355 - register c;
2356 + register int c;
2357 char *s;
2359 for(;;) {
2360 @@ -60,7 +60,7 @@
2361 putchar(va_arg(adx,unsigned), filog);
2362 } else if(c == 's') {
2363 s = va_arg(adx,char*);
2364 - while(c = *s++)
2365 + while((c = *s++))
2366 putchar(c,filog);
2367 } else if (c == 'l' || c == 'O') {
2368 printn(filog, (long)va_arg(adx,long), c=='l'?10:8);
2369 diff -ruN proll_18.orig/src/rconsole.c proll-patch8/src/rconsole.c
2370 --- proll_18.orig/src/rconsole.c 1999-01-16 07:16:55.000000000 +0000
2371 +++ proll-patch8/src/rconsole.c 2004-11-13 15:50:49.000000000 +0000
2372 @@ -28,12 +28,18 @@
2373 * move to California. Only plain lat7 survived.
2374 * I recreated lat7-1 changes in lat7-2. --zaitcev
2376 +#ifdef ORIG
2377 #include "lat7_2.bm" /* lat7_1.bm */
2378 +#else
2379 +#include "lat7_2_swapped.bm" /* lat7_1.bm */
2380 +#endif
2381 #define LAT7_NCHARS 128
2382 #define LAT7_HEIGHT 11
2383 #define LAT7_WIDTH 8
2385 +#ifdef ORIG
2386 static Rf_scan lat7_body[ LAT7_NCHARS*LAT7_HEIGHT ];
2387 +#endif
2389 #if 1
2391 @@ -94,6 +100,7 @@
2393 #endif
2395 +#ifdef ORIG
2396 static inline int swapbits(int w0)
2398 int w1 = 0;
2399 @@ -105,13 +112,16 @@
2401 return w1;
2403 +#endif
2405 void font_cons_7(struct rfont *p)
2407 +#ifdef ORIG
2408 int x;
2409 int col = 0;
2410 int row = 0;
2411 int erow = 0;
2413 for (x = 0; x < LAT7_NCHARS*LAT7_HEIGHT; x++ ) {
2414 lat7_body[ (erow * lat7_2_width/8 + col) * LAT7_HEIGHT + row ] =
2415 swapbits(lat7_2_bits[x]) & 0xFF;
2416 @@ -124,6 +134,9 @@
2419 p->body_ = lat7_body;
2420 +#else
2421 + p->body_ = lat7_2_bits;
2422 +#endif
2423 p->nchars_ = LAT7_NCHARS;
2424 p->width_ = LAT7_WIDTH;
2425 p->height_ = LAT7_HEIGHT;
2426 diff -ruN proll_18.orig/src/rconsole.h proll-patch8/src/rconsole.h
2427 --- proll_18.orig/src/rconsole.h 1999-01-16 05:00:59.000000000 +0000
2428 +++ proll-patch8/src/rconsole.h 2004-11-13 15:50:49.000000000 +0000
2429 @@ -13,10 +13,10 @@
2432 #define RF_MAXWIDTH 16
2433 -typedef unsigned short Rf_scan; /* __w16 to be used */
2434 +typedef unsigned char Rf_scan; /* __w16 to be used */
2436 struct rfont {
2437 - Rf_scan *body_;
2438 + const Rf_scan *body_;
2439 int nchars_; /* 128 for ASCII ... 65536 for Unicode */
2440 int width_; /* [Pixels]. Maximum size is 16. */
2441 int height_; /* [Pixels == scan lines]. */
2442 diff -ruN proll_18.orig/src/romlib.h proll-patch8/src/romlib.h
2443 --- proll_18.orig/src/romlib.h 1999-04-20 04:26:45.000000000 +0000
2444 +++ proll-patch8/src/romlib.h 2004-11-13 15:50:49.000000000 +0000
2445 @@ -73,12 +73,12 @@
2446 #define memcpy(dst, src, len) bcopy(src, dst, len)
2447 #define memcmp(x1, x2, len) bcmp(x1, x2, len)
2448 #define memset(p, len, zero) bzero(p, len)
2449 -extern void bcopy(void *b1, void *b2, int length);
2450 -extern int bcmp(void *b1, void *b2, int length);
2451 +extern void bcopy(const void *b1, void *b2, int length);
2452 +extern int bcmp(const void *b1, const void *b2, int length);
2453 extern void bzero(void *b, int c);
2454 /* gcc complains about "conflicting types for builtin function strlen". */
2455 #define strlen(s) ssize(s)
2456 -extern int ssize(char *s);
2457 +extern int ssize(const char *s);
2461 diff -ruN proll_18.orig/src/sched_4m.c proll-patch8/src/sched_4m.c
2462 --- proll_18.orig/src/sched_4m.c 1999-04-27 05:48:51.000000000 +0000
2463 +++ proll-patch8/src/sched_4m.c 2004-11-13 15:50:49.000000000 +0000
2464 @@ -108,7 +108,7 @@
2465 static int set_bolt; /* Tick counter limit */
2466 static struct handsc hndv[16];
2468 -static unsigned int intr_to_mask[16] = {
2469 +static unsigned const int intr_to_mask[16] = {
2470 0, 0, 0, 0, 0, 0, SUN4M_INT_ETHERNET, 0,
2471 0, 0, 0, 0, 0, 0, 0, 0,
2473 diff -ruN proll_18.orig/src/swap.c proll-patch8/src/swap.c
2474 --- proll_18.orig/src/swap.c 1970-01-01 00:00:00.000000000 +0000
2475 +++ proll-patch8/src/swap.c 2004-11-13 15:50:49.000000000 +0000
2476 @@ -0,0 +1,21 @@
2477 +// Convert the lat7 font so that no conversion is needed at runtime.
2478 +#define ORIG
2479 +#include "rconsole.c"
2481 +#include <stdio.h>
2483 +int main()
2485 + struct rfont p;
2486 + int i;
2488 + font_cons_7(&p);
2490 + printf(" ");
2491 + for (i = 0; i < LAT7_NCHARS*LAT7_HEIGHT; i++) {
2492 + printf("0x%02x, ", p.body_[i]);
2493 + if ((i % 12) == 11)
2494 + printf("\n ");
2496 + printf("\n");
2498 diff -ruN proll_18.orig/src/system.c proll-patch8/src/system.c
2499 --- proll_18.orig/src/system.c 2002-07-23 05:52:49.000000000 +0000
2500 +++ proll-patch8/src/system.c 2004-11-13 15:50:49.000000000 +0000
2501 @@ -298,8 +298,8 @@
2504 /* We need to start from LOADBASE, but kernel wants PAGE_SIZE. */
2505 - pa = PAGE_SIZE;
2506 - for (va = PAGE_SIZE; va < LOWMEMSZ; va += PAGE_SIZE) {
2507 + pa = 0;
2508 + for (va = 0; va < LOWMEMSZ; va += PAGE_SIZE) {
2509 map_page(l1, va, pa, 0, highbase);
2510 pa += PAGE_SIZE;
2512 @@ -518,12 +518,12 @@
2513 while (len--) *((char *)s)++ = 0;
2516 -void bcopy(void *f, void *t, int len) {
2517 +void bcopy(const void *f, void *t, int len) {
2518 while (len--) *((char *)t)++ = *((char *)f)++;
2521 /* Comparison is 7-bit */
2522 -int bcmp(void *s1, void *s2, int len)
2523 +int bcmp(const void *s1, const void *s2, int len)
2525 int i;
2526 char ch;
2527 @@ -538,8 +538,8 @@
2528 return 0;
2531 -int strlen(char *s) {
2532 - char *p;
2533 +int strlen(const char *s) {
2534 + const char *p;
2535 for (p = s; *p != 0; p++) { }
2536 return p - s;
2538 @@ -560,14 +560,6 @@
2539 va_end(x1);
2542 -/* This is taken from x86 to be used in network kernel. Returns 15 bits. */
2543 -short int random()
2545 - static unsigned int seed = 151;
2546 - seed = (seed + 23968)*0x015A4E35 >> 1;
2547 - return seed & 0x7FFF;
2550 void fatal()
2552 printk("fatal.");
2553 diff -ruN proll_18.orig/src/system.h proll-patch8/src/system.h
2554 --- proll_18.orig/src/system.h 2002-09-13 21:53:32.000000000 +0000
2555 +++ proll-patch8/src/system.h 2004-11-13 15:50:49.000000000 +0000
2556 @@ -16,7 +16,7 @@
2557 #define IOMAPSIZE (1*1024*1024) /* 1 Meg maximum: we do not map framebuffer. */
2558 #define NCTX_SWIFT 0x100
2560 -#define MAX_BANKS 3 /* Allocation for all machines */
2561 +#define MAX_BANKS 8 /* Allocation for all machines */
2563 #ifndef __ASSEMBLY__
2564 struct bank {
2565 diff -ruN proll_18.orig/src/udp.c proll-patch8/src/udp.c
2566 --- proll_18.orig/src/udp.c 2001-12-24 05:12:53.000000000 +0000
2567 +++ proll-patch8/src/udp.c 2004-11-13 15:50:49.000000000 +0000
2568 @@ -81,7 +81,7 @@
2569 int source;
2570 int dest;
2572 - register unsigned char *addr;
2573 + const register unsigned char *addr;
2575 /* Set global variables */
2576 usource = source;
2577 @@ -299,9 +299,6 @@
2579 int init_udp()
2581 - /* Set module name for error handling */
2582 - net_module_name = "udp";
2584 /* Register IP packet type and set write buffer pointer */
2585 if ((writebuf = reg_type(htons(ETH_P_IP), ip_recv)) == NULL)
2586 return(FALSE);
2587 diff -ruN proll_18.orig/src/vcons_zs.c proll-patch8/src/vcons_zs.c
2588 --- proll_18.orig/src/vcons_zs.c 1970-01-01 00:00:00.000000000 +0000
2589 +++ proll-patch8/src/vcons_zs.c 2005-03-20 10:25:39.000000000 +0000
2590 @@ -0,0 +1,68 @@
2591 +/**
2592 + ** Console over 'zs' (Zilog serial port)
2593 + ** Copyright 1999 Pete Zaitcev
2594 + ** This code is licensed under GNU General Public License.
2595 + **/
2597 +#include "vconsole.h"
2598 +#include <system.h>
2600 +#define ZS_DATA 0x02
2602 +int vcon_zs_init(struct vconterm *t, unsigned int a0)
2605 + t->impl = (void *) a0;
2607 + t->vc_x = 0; t->vc_y = 0;
2608 + t->backp = 0; t->backc = 0;
2610 + stb_bypass(a0, 3); // reg 3
2611 + stb_bypass(a0, 1); // enable rx
2613 + stb_bypass(a0, 5); // reg 5
2614 + stb_bypass(a0, 8); // enable tx
2616 + return 0;
2619 +int vcon_zs_putch(struct vconterm *t, char c)
2621 + unsigned zs_ptr = (unsigned) t->impl;
2623 + //while ((ldb_bypass(zs_ptr + ZS_LSR) & 0x60) != 0x60) { }
2624 + stb_bypass(zs_ptr + ZS_DATA, c);
2625 + return 0;
2628 +int vcon_zs_write(struct vconterm *t, char *data, int leng)
2630 + while (leng != 0) {
2631 + leng--;
2632 + vcon_zs_putch(t, *data++);
2634 + return leng;
2637 +int vcon_zs_read(struct vconterm *t, char *data, int leng)
2639 + unsigned zs_ptr = (unsigned) t->impl;
2641 + while ((ldb_bypass(zs_ptr) & 1) != 1) { }
2642 + *data = ldb_bypass(zs_ptr + ZS_DATA);
2643 + return 0;
2646 +int vcon_zs_getch(struct vconterm *t)
2648 + unsigned zs_ptr = (unsigned) t->impl;
2650 + while ((ldb_bypass(zs_ptr) & 1) != 1) { }
2651 + return ldb_bypass(zs_ptr + ZS_DATA);
2654 +void vcon_zs_fini(struct vconterm *t)
2656 + /* violent crash in the end */
2659 diff -ruN proll_18.orig/src/vconsole.c proll-patch8/src/vconsole.c
2660 --- proll_18.orig/src/vconsole.c 1999-11-08 03:10:28.000000000 +0000
2661 +++ proll-patch8/src/vconsole.c 2005-03-02 14:29:05.000000000 +0000
2662 @@ -13,6 +13,10 @@
2664 struct hconsole hcons0;
2666 +enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
2667 + EShash, ESsetG0, ESsetG1, ESpercent, ESignore, ESnonstd,
2668 + ESpalette };
2670 int vcon_init(struct vconterm *t, unsigned int a0)
2672 struct hconsole *hconp;
2673 @@ -25,11 +29,49 @@
2675 t->vc_x = 0; t->vc_y = 0;
2676 t->backp = 0; t->backc = 0;
2677 + t->vc_state = ESnormal;
2679 hcon_clear(hconp, 0, 0, hconp->ydim_, hconp->xdim_);
2680 return 0;
2684 + * gotoxy() must verify all boundaries, because the arguments
2685 + * might also be negative. If the given position is out of
2686 + * bounds, the cursor is placed at the nearest margin.
2687 + */
2688 +static void gotoxy(struct vconterm *vc, int new_x, int new_y)
2690 + int max_x, max_y;
2691 + struct hconsole *hconp = vc->impl;
2693 + max_x = hcon_qxdim(hconp);
2694 + max_y = hcon_qydim(hconp);
2696 + if (new_x < 0)
2697 + vc->vc_x = 0;
2698 + else {
2699 + if (new_x >= max_x)
2700 + vc->vc_x = max_x - 1;
2701 + else
2702 + vc->vc_x = new_x;
2705 + if (new_y < 0)
2706 + vc->vc_y = 0;
2707 + else if (new_y >= max_y)
2708 + vc->vc_y = max_y - 1;
2709 + else
2710 + vc->vc_y = new_y;
2714 +/* for absolute user moves, when decom is set */
2715 +static void gotoxay(struct vconterm *t, int new_x, int new_y)
2717 + gotoxy(t, new_x, new_y);
2720 int vcon_write(struct vconterm *t, char *data, int leng)
2722 int l = leng;
2723 @@ -40,29 +82,84 @@
2724 if (l <= 0) break;
2725 c = *data++; --l;
2727 - switch (c) {
2728 - case 0x07: /* Bell */
2729 - vcon_i_backflush(t);
2730 - break;
2731 - case 0x0A: /* Linefeed */
2732 - vcon_i_backflush(t);
2733 - vcon_i_cursfeed(t);
2734 + switch(t->vc_state) {
2735 + case ESesc:
2736 + t->vc_state = ESnormal;
2737 + switch (c) {
2738 + case '[':
2739 + t->vc_state = ESsquare;
2740 + break;
2741 + case 'M':
2742 + hcon_scroll(hconp, 0, hcon_qydim(hconp), SM_UP, 1);
2743 + break;
2745 break;
2746 - case 0x0D: /* Return */
2747 - vcon_i_backflush(t);
2748 - t->vc_x = 0;
2749 + case ESsquare:
2750 + for(t->vc_npar = 0 ; t->vc_npar < NPAR ; t->vc_npar++)
2751 + t->vc_par[t->vc_npar] = 0;
2752 + t->vc_npar = 0;
2753 + t->vc_state = ESgetpars;
2754 + case ESgetpars:
2755 + if (c==';' && t->vc_npar<NPAR-1) {
2756 + t->vc_npar++;
2757 + break;
2758 + } else if (c>='0' && c<='9') {
2759 + t->vc_par[t->vc_npar] *= 10;
2760 + t->vc_par[t->vc_npar] += c-'0';
2761 + break;
2762 + } else t->vc_state=ESgotpars;
2763 + case ESgotpars:
2764 + t->vc_state = ESnormal;
2765 + switch(c) {
2766 + case 'H': case 'f':
2767 + if (t->vc_par[0]) t->vc_par[0]--;
2768 + if (t->vc_par[1]) t->vc_par[1]--;
2769 + gotoxay(t, t->vc_par[1], t->vc_par[0]);
2770 + break;
2771 + case 'M':
2772 + hcon_scroll(hconp, 0, hcon_qydim(hconp), SM_UP, 1);
2773 + break;
2775 break;
2776 default:
2777 - if (t->backp == 0) {
2778 - t->backc = 1;
2779 - t->backp = data-1;
2780 - } else {
2781 - t->backc++;
2783 - if (t->vc_x + t->backc >= hcon_qxdim(hconp)) {
2784 + t->vc_state = ESnormal;
2785 + switch (c) {
2786 + case 0x07: /* Bell */
2787 + vcon_i_backflush(t);
2788 + break;
2789 + case 0x08: /* BS */
2790 + vcon_i_backflush(t);
2791 + if (t->vc_x > 0)
2792 + t->vc_x--;
2793 + break;
2794 + case 0x0A: /* Linefeed */
2795 vcon_i_backflush(t);
2796 - t->vc_x = 0;
2797 vcon_i_cursfeed(t);
2798 + break;
2799 + case 0x0D: /* Return */
2800 + vcon_i_backflush(t);
2801 + t->vc_x = 0;
2802 + break;
2803 + case 24: case 26:
2804 + vcon_i_backflush(t);
2805 + t->vc_state = ESnormal;
2806 + break;
2807 + case 27:
2808 + vcon_i_backflush(t);
2809 + t->vc_state = ESesc;
2810 + break;
2811 + default:
2812 + if (t->backp == 0) {
2813 + t->backc = 1;
2814 + t->backp = data-1;
2815 + } else {
2816 + t->backc++;
2818 + if (t->vc_x + t->backc >= hcon_qxdim(hconp)) {
2819 + vcon_i_backflush(t);
2820 + t->vc_x = 0;
2821 + vcon_i_cursfeed(t);
2826 diff -ruN proll_18.orig/src/vconsole.h proll-patch8/src/vconsole.h
2827 --- proll_18.orig/src/vconsole.h 1999-11-08 00:58:13.000000000 +0000
2828 +++ proll-patch8/src/vconsole.h 2005-03-02 12:40:12.000000000 +0000
2829 @@ -6,6 +6,8 @@
2830 #ifndef VCONSOLE_H
2831 #define VCONSOLE_H
2833 +#define NPAR 16
2835 struct vconterm {
2836 void *impl;
2838 @@ -13,6 +15,8 @@
2839 int backc; /* Same, count */
2841 int vc_x, vc_y; /* XXX Make vcon_xxx() to use cellmap->xpos_ */
2842 + int vc_state;
2843 + unsigned int vc_npar,vc_par[NPAR]; /* Parameters of current escape sequence */
2846 int vcon_init(struct vconterm *t, unsigned int a0);