Skip to content

Instantly share code, notes, and snippets.

@tsutsui
Created November 4, 2019 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsutsui/63252468cd7a01c5c434bcf6184cb2f4 to your computer and use it in GitHub Desktop.
Save tsutsui/63252468cd7a01c5c434bcf6184cb2f4 to your computer and use it in GitHub Desktop.
Make NetBSD/zaurus 9.0_BETA kernel use symbol table strings loaded by zbsdmod.o loader and stop using options COPY_SYMTAB to reduce kernel size.
Index: conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/conf/GENERIC,v
retrieving revision 1.86
diff -u -p -d -r1.86 GENERIC
--- conf/GENERIC 26 Jul 2019 07:09:47 -0000 1.86
+++ conf/GENERIC 4 Nov 2019 13:54:44 -0000
@@ -143,19 +143,17 @@ options WS_KERNEL_FG=WSCOL_GREEN
# compatibility to other console drivers
options WSDISPLAY_COMPAT_PCVT # emulate some ioctls
options WSDISPLAY_COMPAT_USL # wsconscfg VT handling
-# options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
+options WSDISPLAY_COMPAT_RAWKBD # can get raw scancodes
# Development and Debugging options
options DIAGNOSTIC # internal consistency checks
#options DEBUG
-#options VERBOSE_INIT_ARM # verbose bootstraping messages
-#options DDB # in-kernel debugger
-#options DDB_HISTORY_SIZE=100 # Enable history editing in DDB
+options VERBOSE_INIT_ARM # verbose bootstraping messages
+options DDB # in-kernel debugger
+options DDB_HISTORY_SIZE=100 # Enable history editing in DDB
#options KGDB
#makeoptions DEBUG="-g" # compile full symbol table
-makeoptions COPY_SYMTAB=1
-
# Kernel root file system and dump configuration.
config netbsd root on ? type ?
Index: dev/zrc.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/dev/zrc.c,v
retrieving revision 1.9
diff -u -p -d -r1.9 zrc.c
--- dev/zrc.c 27 Oct 2012 17:18:14 -0000 1.9
+++ dev/zrc.c 4 Nov 2019 13:54:44 -0000
@@ -17,6 +17,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include "opt_wsdisplay_compat.h"
+
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zrc.c,v 1.9 2012/10/27 17:18:14 chs Exp $");
@@ -131,6 +133,11 @@ static const keysym_t zrc_keydesc[] = {
};
#ifdef WSDISPLAY_COMPAT_RAWKBD
+/* XXX see OpenBSD's <sys/dev/wscons/wskbdraw.h> */
+#define RAWKEY_Null 0x00
+#define RAWKEY_AudioMute 0x85
+#define RAWKEY_AudioLower 0x86
+#define RAWKEY_AudioRaise 0x87
#define RAWKEY_AudioRewind 0xa0
#define RAWKEY_AudioForward 0xa1
#define RAWKEY_AudioPlay 0xa2
Index: stand/zbsdmod/zbsdmod.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/stand/zbsdmod/zbsdmod.c,v
retrieving revision 1.9.34.1
diff -u -p -d -r1.9.34.1 zbsdmod.c
--- stand/zbsdmod/zbsdmod.c 3 Nov 2019 11:36:56 -0000 1.9.34.1
+++ stand/zbsdmod/zbsdmod.c 4 Nov 2019 13:54:45 -0000
@@ -139,8 +139,8 @@ elf32bsdboot(void)
if (maxv < posv)
maxv = posv;
}
- if (IS_DATA(phdr[i]) && IS_BSS(phdr[i])) {
- posv += phdr[i].p_memsz;
+ if (IS_BSS(phdr[i])) {
+ posv += phdr[i].p_memsz - phdr[i].p_filesz;
if (maxv < posv)
maxv = posv;
}
Index: zaurus/autoconf.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/zaurus/autoconf.c,v
retrieving revision 1.12
diff -u -p -d -r1.12 autoconf.c
--- zaurus/autoconf.c 29 Jul 2012 18:05:47 -0000 1.12
+++ zaurus/autoconf.c 4 Nov 2019 13:54:45 -0000
@@ -43,6 +43,8 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
#include <sys/disk.h>
#include <sys/kauth.h>
+#include <dev/i2c/i2cvar.h>
+
#include <machine/intr.h>
#include <machine/bootconfig.h>
#include <machine/bootinfo.h>
@@ -219,5 +221,13 @@ void
device_register(device_t dev, void *aux)
{
- /* Nothing to do */
+ /*
+ * I2C bus conntected to pxaiic(4) for zaudio(4) devices has
+ * limited capabilities.
+ */
+ if (device_is_a(dev, "iic") &&
+ device_is_a(dev->dv_parent, "ziic")) {
+ (void)prop_dictionary_set_cstring_nocopy(device_properties(dev),
+ I2C_PROP_INDIRECT_PROBE_STRATEGY, I2C_PROBE_STRATEGY_NONE);
+ }
}
Index: zaurus/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/zaurus/zaurus/machdep.c,v
retrieving revision 1.42
diff -u -p -d -r1.42 machdep.c
--- zaurus/machdep.c 16 Jul 2019 14:41:49 -0000 1.42
+++ zaurus/machdep.c 4 Nov 2019 13:54:46 -0000
@@ -247,6 +247,12 @@ struct bootinfo _bootinfo;
struct bootinfo *bootinfo;
struct btinfo_howto *bi_howto;
+extern char etext[], end[];
+extern void *esym;
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+#include <sys/exec_elf.h>
+#endif
+
#define KERNEL_BASE_PHYS ((paddr_t)&KERNEL_BASE_phys)
#define BOOTINFO_PAGE (KERNEL_BASE_PHYS - PAGE_SIZE)
@@ -647,6 +653,9 @@ initarm(void *arg)
psize_t memsize;
struct pxa2x0_gpioconf **zaurus_gpioconf;
u_int *magicaddr;
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+ u_int symbolsize;
+#endif
/* Get ready for zaurus_restart() */
pxa2x0_memctl_bootstrap(PXA2X0_MEMCTL_BASE);
@@ -772,7 +781,7 @@ initarm(void *arg)
#ifdef VERBOSE_INIT_ARM
/* Tell the user about the memory */
- printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem,
+ printf("physmemory: %ld pages at 0x%08lx -> 0x%08lx\n", physmem,
physical_start, physical_end - 1);
#endif
@@ -921,12 +930,51 @@ initarm(void *arg)
printf("Mapping kernel\n");
#endif
+ esym = end;
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+ symbolsize = 0;
+ Elf_Ehdr *eh = (Elf_Ehdr *)end;
+#ifdef VERBOSE_INIT_ARM
+ printf("Check ELF MAGIC at end: %02x %02x %02x %02x\n",
+ end[0], end[1], end[2], end[3]);
+#endif
+ if (memcmp(eh->e_ident, ELFMAG, SELFMAG) == 0) {
+ Elf_Shdr *sh;
+#ifdef VERBOSE_INIT_ARM
+ printf("ELF header found at end[]\n");
+#endif
+ sh = (Elf_Shdr *)((char *)end + eh->e_shoff);
+ for (loop = 0; loop < eh->e_shnum; loop++, sh++) {
+ printf("Checking ELF header %d\n", loop);
+ if (sh->sh_type != SHT_SYMTAB &&
+ sh->sh_type != SHT_STRTAB) {
+ continue;
+ }
+#ifdef VERBOSE_INIT_ARM
+ printf("Section[%2d]: offset = %d, size = %d\n",
+ loop, sh->sh_offset, sh->sh_size);
+#endif
+ if (sh->sh_offset > 0 &&
+ (sh->sh_offset + sh->sh_size) > symbolsize) {
+ symbolsize = sh->sh_offset + sh->sh_size;
+ }
+#ifdef VERBOSE_INIT_ARM
+ printf("Updating symbolsize = %d\n", symbolsize);
+#endif
+ }
+ esym = (char *)esym + symbolsize;
+ }
+#ifdef VERBOSE_INIT_ARM
+ printf("Symbol size = %d\n", symbolsize);
+#endif
+#endif
+
/* Now we fill in the L2 pagetable for the kernel static code/data
* and the symbol table. */
{
- extern char etext[], _end[];
+
size_t textsize = (uintptr_t) etext - KERNEL_TEXT_BASE;
- size_t totalsize = (uintptr_t) _end - KERNEL_TEXT_BASE;
+ size_t totalsize = (uintptr_t) esym - KERNEL_TEXT_BASE;
u_int logical;
textsize = (textsize + PGOFSET) & ~PGOFSET;
@@ -1012,10 +1060,9 @@ initarm(void *arg)
* variables.
*/
{
- extern char _end[];
physical_freestart = physical_start +
- ((((uintptr_t) _end + PGOFSET) & ~PGOFSET) - KERNEL_BASE);
+ ((((uintptr_t) esym + PGOFSET) & ~PGOFSET) - KERNEL_BASE);
physical_freeend = physical_end;
free_pages =
(physical_freeend - physical_freestart) / PAGE_SIZE;
@@ -1109,13 +1156,9 @@ initarm(void *arg)
md_root_setconf(memory_disk, sizeof memory_disk);
#endif
-#if NKSYMS || defined(MODULAR)
-# ifdef DDB
- ddb_init(0, NULL, NULL);
-# else
- /* Firmware doesn't load symbols. */
- ksyms_addsyms_elf(0, NULL, NULL);
-# endif
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+ if (symbolsize > 0)
+ ksyms_addsyms_elf(symbolsize, &end, esym);
#endif
#ifdef KGDB
NAND LOADER ... in NOR
built on Oct 15 2002 at 19:18:18
func= 00000000
(0) Jump to NAND!
**** LoadAndJump ****
store_adr = 00000000
load_adr = 00210000
size = 00040000
func = ffffffff
**** JUMP ! ****
[ 1.0000000] NetBSD/zaurus booting ...
[ 1.0000000] initarm: Configuring system ...
[ 1.0000000] physmemory: 8192 pages at 0xa0000000 -> 0xa1ffffff
[ 1.0000000] Allocating page tables
[ 1.0000000] freestart = 0xa0009000, free_pages = 1014 (0x000003f6)
[ 1.0000000] IRQ stack: p0xa03ef000 v0xc03ef000
[ 1.0000000] ABT stack: p0xa03ee000 v0xc03ee000
[ 1.0000000] UND stack: p0xa03ed000 v0xc03ed000
[ 1.0000000] SVC stack: p0xa03eb000 v0xc03eb000
[ 1.0000000] minidataclean: p0xa03ea000 v0xc03ea000, size = 2048
[ 1.0000000] bootinfo_pg: p0xa03ff000 v0xc03ff000
[ 1.0000000] Creating L1 page table at 0xa03f8000
[ 1.0000000] Mapping kernel
[ 1.0000000] Check ELF MAGIC at end: 7f 45 4c 46
[ 1.0000000] ELF header found at end[]
[ 1.0000000] Checking ELF header 0
[ 1.0000000] Checking ELF header 1
[ 1.0000000] Checking ELF header 2
[ 1.0000000] Checking ELF header 3
[ 1.0000000] Checking ELF header 4
[ 1.0000000] Checking ELF header 5
[ 1.0000000] Checking ELF header 6
[ 1.0000000] Checking ELF header 7
[ 1.0000000] Checking ELF header 8
[ 1.0000000] Checking ELF header 9
[ 1.0000000] Checking ELF header 10
[ 1.0000000] Checking ELF header 11
[ 1.0000000] Checking ELF header 12
[ 1.0000000] Checking ELF header 13
[ 1.0000000] Checking ELF header 14
[ 1.0000000] Checking ELF header 15
[ 1.0000000] Checking ELF header 16
[ 1.0000000] Checking ELF header 17
[ 1.0000000] Checking ELF header 18
[ 1.0000000] Checking ELF header 19
[ 1.0000000] Checking ELF header 20
[ 1.0000000] Checking ELF header 21
[ 1.0000000] Checking ELF header 22
[ 1.0000000] Section[22]: offset = 1052, size = 253808
[ 1.0000000] Updating symbolsize = 254860
[ 1.0000000] Checking ELF header 23
[ 1.0000000] Section[23]: offset = 254860, size = 249095
[ 1.0000000] Updating symbolsize = 503955
[ 1.0000000] Checking ELF header 24
[ 1.0000000] Section[24]: offset = 503956, size = 319
[ 1.0000000] Updating symbolsize = 504275
[ 1.0000000] Symbol size = 504275
[ 1.0000000] SSSLLLLLLLLPPPPPPPPPPPPPP
[ 1.0000000] PPLLLLLLLLLLPPPPPPPPPPP
[ 1.0000000] Constructing L2 page tables
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] PP
[ 1.0000000] PPPP
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] P
[ 1.0000000] devmap: 40e00000 -> 40efffff @ fd000000
[ 1.0000000] S
[ 1.0000000] devmap: 41300000 -> 413fffff @ fd100000
[ 1.0000000] S
[ 1.0000000] devmap: 40d00000 -> 40dfffff @ fd200000
[ 1.0000000] S
[ 1.0000000] devmap: 48000000 -> 480fffff @ fd300000
[ 1.0000000] S
[ 1.0000000] devmap: 10800000 -> 108fffff @ fd400000
[ 1.0000000] S
[ 1.0000000] devmap: 08800000 -> 088fffff @ fd500000
[ 1.0000000] S
[ 1.0000000] devmap: 40100000 -> 401fffff @ fd600000
[ 1.0000000] S
[ 1.0000000] devmap: 40200000 -> 402fffff @ fd700000
[ 1.0000000] S
[ 1.0000000] devmap: 40700000 -> 407fffff @ fd800000
[ 1.0000000] S
[ 1.0000000] devmap: 40f00000 -> 40ffffff @ fd900000
[ 1.0000000] S
[ 1.0000000] freestart = 0xa083b000, free_pages = 6085 (0x17c5)
[ 1.0000000] switching to new L1 page table @0xa03f8000...bootstrap done.
[ 1.0000000] init subsystems: stacks vectors undefined page pmap kpm locks l1pt cache(l1pt) specials pools
[ 1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
[ 1.0000000] 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
[ 1.0000000] 2018, 2019 The NetBSD Foundation, Inc. All rights reserved.
[ 1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[ 1.0000000] The Regents of the University of California. All rights reserved.
[ 1.0000000] NetBSD 9.0_BETA (C700) #16: Mon Nov 4 22:35:15 JST 2019
[ 1.0000000] tsutsui@mirage:/s/netbsd-9/src/sys/arch/zaurus/compile/C700
[ 1.0000000] total memory = 32768 KB
[ 1.0000000] avail memory = 23200 KB
[ 1.0000000] mainbus0 (root)
[ 1.0000000] cpu0 at mainbus0 core 0: PXA250 step B-2 (XScale V5TE core)
[ 1.0000000] cpu0: DC enabled IC enabled WB enabled LABT branch prediction enabled
[ 1.0000000] cpu0: 32KB/32B 32-way L1 VIVT Instruction cache
[ 1.0000000] cpu0: 32KB/32B 32-way write-back-locking L1 VIVT Data cache
[ 1.0000000] pxaip0 at mainbus0: Onchip Peripheral Bus
[ 1.0000000] pxaip0: CPU clock = 398.093 MHz
[ 1.0000000] pxaip0: kernel is configured for PXA250, cpu type is PXA250
[ 1.0000000] pxaintc0 at pxaip0 addr 0x40d00000-0x40d0001f: Interrupt Controller
[ 1.0000000] pxagpio0 at pxaip0 addr 0x40e00000-0x40e0006f: GPIO Controller
[ 1.0000000] pxagpio0: no GPIO configured in kernel
[ 1.0000000] com0 at pxaip0 addr 0x40100000-0x4010001f intr 22: ns16550a, working fifo
[ 1.0000000] com0: console
[ 1.0000000] com1 at pxaip0 addr 0x40200000-0x4020001f intr 21: ns16550a, working fifo
[ 1.0000000] com2 at pxaip0 addr 0x40700000-0x4070001f intr 20: ns16550a, working fifo
[ 1.0000000] saost0 at pxaip0 addr 0x40a00000-0x40a0001f
[ 1.0000000] saost0: SA-11x0 OS Timer
[ 1.0000000] pxadmac0 at pxaip0 addr 0x40000000-0x400002ff intr 25: DMA Controller
[ 1.0000000] pxapcic0 at pxaip0: 1 slot
[ 1.0000000] pcmcia0 at pxapcic0
[ 1.0000000] pxartc0 at pxaip0 addr 0x40900000-0x4090000f: Real-time Clock
[ 1.0000000] pxamci0 at pxaip0 addr 0x41100000-0x41100047: MMC/SD Controller
[ 1.0000000] pxamci0: using DMA transfer
[ 1.0000000] sdmmc0 at pxamci0
[ 1.0000000] ziic0 at pxaip0 addr 0x40300000-0x403016a3: I2C controller
[ 1.0000000] iic0 at ziic0: I2C bus
[ 1.0000000] zaudio0 at iic0 addr 0x1b: I2S, WM8731 Audio
[ 1.0000000] audio0 at zaudio0: playback, capture, half duplex
[ 1.0000000] audio0: slinear_le:16 2ch 48000Hz, blk 40ms for playback
[ 1.0000000] audio0: slinear_le:16 2ch 48000Hz, blk 40ms for recording
[ 1.0000000] spkr0 at audio0: PC Speaker (synthesized)
[ 1.0000000] wsbell at spkr0 not configured
[ 1.0000000] scoop0 at pxaip0: PCMCIA/GPIO controller
[ 1.0000000] zssp0 at pxaip0
[ 1.0000000] lcdctl0 at zssp0
[ 1.0000000] ztp0 at zssp0
[ 1.0000000] wsmouse0 at ztp0 mux 0
[ 1.0000000] w100lcd0 at pxaip0: ATI Imageon100 LCD controller
[ 1.0000000] wsdisplay0 at w100lcd0 kbdmux 1
[ 1.0000000] zkbd0 at pxaip0
[ 1.0000000] wskbd0 at zkbd0 mux 1
[ 1.0000080] clock: hz=100 stathz=64
[ 1.3298903] ld0 at sdmmc0: <0x1d:0x4144:SD :0x10:0x2110021a:0x0bc>
[ 1.4098086] ld0: 7887 MB, 4006 cyl, 64 head, 63 sec, 512 bytes/sect x 16152576 sectors
[ 1.5146130] ld0: 1-bit width, 20.000 MHz
[ 1.5931555] boot device: ld0
[ 1.6321353] root on ld0a dumps on ld0b
[ 1.7025256] root file system type: ffs
[ 1.7465032] kern.module.path=/stand/zaurus/9.0/modules
[ 1.8152595] WARNING: clock lost 2855 days
[ 1.8631691] WARNING: using filesystem time
[ 1.9121117] WARNING: CHECK AND RESET THE DATE!
Enter pathname of shell or RETURN for /bin/sh:
We recommend that you create a non-root account and use su(1) for root access.
# Stopped in pid 0.2 (system) at netbsd:cpu_Debugger+0x4: bx r14
db> bt
0xc37caee4: netbsd:comintr+0xc
0xc37caf0c: netbsd:pxa2x0_irq_handler+0x80
0xc37caf74: netbsd:irq_entry+0x98
0xc37cafac: netbsd:idle_loop+0x204
db> c
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment