Make sun3 work again.
Subsystems (2)
cover Make sun3 work again.
Short version: Have a QEMU fork that can emulate all of the supported m68k machines via the magic of LLM. LLM also fixed the ones that had bit rotten. This series makes sun3 work again. Commits are cleaned up but I have intentially left most of the comments intact as the LLM debugged it not me.
Longer version:
I am reworking some stuff in my m68k tree and have added SMP etc. I wanted something to test I haven't regressed all of the other machines so I gave claude the qemu and kernel sources and told it "emulate all of the supported m68k machines, try to boot their native OS first, netbsd if there is a port and then linux."
It took a few weeks from what I remember (emulating 030 macs is hard apparently...) but it was able to do it mostly. Some of the natives OSes use the MMU in weird ways and it gave up trying to model some of that in QEMU. It's pretty sure it can boot Linux on anything with an m68k CPU now. It even created Palm Pilot emulators and tested the 68000 Palm Pilot support.
While doing the QEMU work it also fixed up some of the machines so they work again. I sent a patch for Apollo a few weeks ago.
This series fixes sun3 to the point you should be able to get something to print out over serial.
With some further patches to add a real serial driver and it gets to my nolibc based userspace:
https://gist.github.com/fifteenhex/e97322216d5e85e7a54a2adfcba08e32
The real serial driver is a lot of code so I have kept that out of this series.
Daniel Palmer (2):
m68k: sun3: register RAM with memblock and set the low pfn limits
m68k: sun3: add an early boot console over the PROM
arch/m68k/sun3/config.c | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
Signature · 1 line
2.55.0
PATCH 1/2 m68k: sun3: register RAM with memblock and set the low pfn limits
The sun3 memory init never talked to memblock, so paging_init() and the first slab allocation found no memory at all:
* register physical RAM with memblock_add() and reserve the kernel image (and embedded initramfs) below memory_start. The generic m68k_setup_node() no longer does this, and sun3's paging_init() allocates its page tables straight out of memblock, so without it memblock is empty and paging_init() panics;
* memblock_set_bottom_up(true): paging_init() runs while only the low RAM the PROM handed us is mapped, so its page-table allocations must come from just above the kernel rather than the unmapped top of RAM;
* set min_low_pfn/max_low_pfn: memblock_free_all() clamps the pages it releases into the buddy allocator to [min_low_pfn, max_low_pfn); with them left 0 the whole of RAM stayed reserved and the first slab allocation BUG'd.
--- arch/m68k/sun3/config.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/m68k/sun3/config.c +24 -0
@@ -118,6 +118,30 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start, high_memory = (void *)memory_end; availmem = memory_start; +/* +* memblock_free_all() clamps the pages it releases into the buddy +* allocator to [min_low_pfn, max_low_pfn); without these set the +* whole of RAM stays reserved and the first slab allocation fails. +*/ + min_low_pfn =__pa (memory_start) >>PAGE_SHIFT ; + max_low_pfn = max_pfn; + +/* +* Register physical RAM with memblock and reserve the kernel image +* (and the embedded initramfs) below memory_start. The generic +* m68k_setup_node() no longer does this, and sun3's paging_init() +* allocates its page tables straight out of memblock, so without +* this memblock is empty and paging_init() panics. +*/ +memblock_add (0 ,__pa (memory_end)); +memblock_reserve (0 ,__pa (memory_start)); +/* +* paging_init() runs while only the low RAM the PROM handed us is +* mapped, so its page-table allocations must come from just above +* the kernel (bottom-up) rather than the unmapped top of RAM. +*/ +memblock_set_bottom_up (true); +m68k_setup_node (0 ); }
Signature · 1 line
2.55.0
PATCH 2/2 m68k: sun3: add an early boot console over the PROM
In reply to Daniel PalmerRegister a CON_BOOT console that writes through the resident PROM's polled character output (prom_putchar()).
--- arch/m68k/sun3/config.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/m68k/sun3/config.c +22 -0
@@ -145,11 +145,33 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start,m68k_setup_node (0 ); } +/* Early boot console over the resident PROM's polled character output. */ +static void sun3_early_console_write (struct console *con,const char *s, +unsigned int n) +{ +while (n-- >0 ) { +if (*s =='\n' ) +prom_putchar ('\r' ); +prom_putchar (*s++); + } +} + +static struct console sun3_early_console = { + .name ="sun3prom" , + .write = sun3_early_console_write, + .flags =CON_PRINTBUFFER |CON_BOOT , + .index =-1 , +};void __init config_sun3 (void ) {unsigned long memory_start, memory_end; +if (!sun3_early_console.data) { + sun3_early_console.data = &sun3_early_console; +register_console (&sun3_early_console); + } +pr_info ("ARCH: SUN3\n" );idprom_init ();
Signature · 1 line
2.55.0
Hi Daniel,
Quoted 5 lines · Daniel Palmer
Short version: Have a QEMU fork that can emulate all of the supported m68k machines via the magic of LLM. LLM also fixed the ones that had bit rotten. This series makes sun3 work again. Commits are cleaned up but I have intentially left most of the comments intact as the LLM debugged it not me.
Very cool! Thanks a lot for working on this and resurrecting sun-3!
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913