Port-macppc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Apple Network Server 700/200 screen



Hello,

On Sun, 10 Sep 2023 21:25:44 -0400
Bradley Pearce <bottleworksnet%gmail.com@localhost> wrote:

> Quite a challenge you tasked me with over this weekend.

I'm sorry, maybe I should try to sabotage console setup on one of mine
to see if the fallback still works - problem is, I don't have anything
with remotely similar OF ( it's all either 3.x which is far more
standardized and well behaved, the oldest I have are 2.x which have
their own set of weirdness )
I tried the OF calls by hand and they work as expected on a beige G3.

> I first started having:
> gcc: internal compiler error: Killed (program cc1 received signal 9)
> ...
> *** Error code 4
> It was running out of memory and I didn't have a swap setup.  I could
> never get a successful install if the hard drive had a swap partition.
> I added a 500Mb swap file and that resolved the Error code 4.

You don't need to build your kernels natively, modern day gcc is quite
a pig even with non-plusplus-C. Almost any unixlike OS will do.

> Trying again, I got an error which I don't know how to handle.  I got
> this same error with an unmodified GENERIC kernel config and the
> modified one for debug.  Both attempts did have the change to
> sys/dev/wsfb/genfb.c  , but I don't think that's causing this?
> 
> #   compile  GENERIC.STOCK/bha_pci.o
> gcc -mno-strict-align -Wa,-maltivec -msdata=none -msoft-float
> -ffreestanding -fno-zero-initialized-in-bss
> -fno-delete-null-pointer-checks -O2 -fno-strict-aliasing -fno-common
> -std=gnu99 -Werror -Wreturn-type -Wall -Wno-main
> -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes
> -Wstrict-prototypes -Wold-style-definition -Wswitch -Wshadow
> -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-pointer-sign
> -Wno-attributes -Wno-sign-compare -Dmacppc=macppc -I.
> -I../../../../external/bsd/libnv/dist
> -I../../../../../common/lib/libx86emu
> -I../../../../../common/lib/libc/misc -I../../../../../common/include
> -I../../../../arch -I../../../.. -nostdinc -DCOMPAT_UTILS
> -DZS_CONSOLE_ABORT -DCOMPAT_44 -DFORCE_FUNCTION_KEYS -D_KERNEL
> -D_KERNEL_OPT -std=gnu99
> -I../../../../lib/libkern/../../../common/lib/libc/quad
> -I../../../../lib/libkern/../../../common/lib/libc/string
> -I../../../../lib/libkern/../../../common/lib/libc/arch/powerpc/string
> -I../../../../external/isc/atheros_hal/dist
> -I../../../../external/isc/atheros_hal/ic
> -I../../../../external/bsd/libnv/dist -c ../../../../dev/pci/bha_pci.c
> -o bha_pci.o
> /tmp//ccGb3N1K.s: Assembler messages:
> /tmp//ccGb3N1K.s:733: Error: symbol `.LC1' is already defined
> *** Error code 1
> 
> Stop.
> make: stopped in /usr/src/sys/arch/macppc/compile/GENERIC.STOCK

This is very odd. Is that a plain 9.3 install? Did you build.sh tools
or do you use the native gcc?

> I noticed in the NetBSD 5.1 dmesg output, it had:
> genfb0 at pci0 dev 15 function 0: Cirrus Logic CL-GD5430
> genfb0: framebuffer at 0x82000000, size 640x480, depth 8, stride 640
> 
> Anyways, that's all I have to report for now.  It takes quite a bit of
> time to compile on the ANS 700/200.  I might install NetBSD on my
> MacBook to compile on a faster machine and speed things up.

I used to crossbuild NetBSD stuff on a G5 running Leopard ages ago.

> Until I get the kernel compiled, I've attached a photo of the screen.
> Thanks for your help!

You're reading my mind, I was just about to ask for that!
Ok, so there is kernel output in green which means:
- early console works, so no OF weirdness here and the no properties
  workaround still works
- it managed to grab the OF font
- genfb somehow screws up when taking over
The pattern looks weird, every 4th column is scribbled into.

Hmm, I think I have an idea. The address we get from frame-buffer-adr
is an OF-mapped virtual address and genfb expects a bus address. We
BAT-map the PCI bus 1:1 into kernel space so we can just use bus
addresses. We may screw up when trying to access the framebuffer
through that. Leaves the question which part of that changed since 5.1
- I don't think I messed with that code at all. Then again, 5.x was a
long time ago.

Here's a patch to try to extract the physical address of the
framebuffer from whatever OF hands us and also passing the virtual
address along ( genfb grew support for that a while ago )
I tested this on the G3 with sabotaged address property so it would
take the frame-buffer-adr route.

Index: machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/macppc/machdep.c,v
retrieving revision 1.175
diff -u -w -r1.175 machdep.c
--- machdep.c   26 Jun 2022 09:23:32 -0000      1.175
+++ machdep.c   11 Sep 2023 05:57:17 -0000
@@ -368,9 +368,14 @@
        }
        if (!of_to_uint32_prop(dict, node, "address", "address")) {
                uint32_t fbaddr = 0;
+               paddr_t fbpaddr;
                OF_interpret("frame-buffer-adr", 0, 1, &fbaddr);
-               if (fbaddr != 0)
-                       prop_dictionary_set_uint32(dict, "address", fbaddr);
+               if (fbaddr != 0) {
+                       pmap_extract(pmap_kernel(), fbaddr, &fbpaddr);
+                       printf("addr %08x %08lx\n", fbaddr, fbpaddr);
+                       prop_dictionary_set_uint32(dict, "address", fbpaddr);
+                       prop_dictionary_set_uint32(dict, "virtual_address", fbaddr);
+               }
        }
        if (of_to_dataprop(dict, node, "EDID", "EDID")) {
                aprint_debug("found EDID property...\n");

Please let me know if this helps.
If you still have trouble building kernels I'll put a GENERIC or
POWERMAC kernel on ftp.netbsd.org ( the POWERMAC config only contains
support for your typical bandit based powermac's onboard devices, much
smaller than GENERIC and should be enough to see if genfb works )

have fun
Michael


Home | Main Index | Thread Index | Old Index