Re: Kernel Options

T <[email protected]> Sun, 7 Jun 2020 04:39:21 -0600
Newsgroups gmane.os.netbsd.ports.prep
Message-ID <[email protected]>
On 11/19/19 6:57 PM, T wrote:
> options KGDB
> #This will lead to compile errors if enabled. I was able to track down 
> the errors to some changes that were made that did not take OEA type 
> machines into consideration. I was able to move some IFDEF tags to 
> fix, although there was one error I could not figure out, but was able 
> to bypass in order to get the kernel to compile. I'll follow up with 
> more information/patch when I return to this issue.

Just an update on this specific issue, I was able to fix the error that 
caused the compile errors if the option was enabled, but upon closer 
inspection of the source code, the underlying issue is that KGDB was 
never fully added to this port. By cross-examining the source code 
against other ports, there appears to be a KGDB function call that is 
missing in PReP port source code, that is included in the other ports 
with working KGDB. Some ports have more complicated code that is tied to 
machine specific hardware, like in the macppc port, but in contrast, the 
i386 port seems more straight forward, as is the evbppc port.

There appears to be powerpc common code for KGDB, as seen here: 
"https://nxr.netbsd.org/xref/src/sys/arch/powerpc/powerpc/kgdb_machdep.c", 
but the PReP port does not call it. While investigating other ports, 
there appear to be two main factors in getting KGDB to work, 
initializing the COM port and then the actual KGDB code. The KGDB code 
looks to be there, as shown in the link above, but I'm not quite sure 
about the code for initializing the COM port. If looking at similar KGDB 
code for evbppc, setting it up is done through machine independent code 
via "/src/sys/dev/ic/com.c" using the function "com_kgdb_attach". Both 
the evbppc port and PReP port look similar in how they do that, so 
perhaps using the KGDB code for enabling it from evbppc would also work 
for PReP. Scroll down to the bottom of both of these files and you can 
see how similar they are, the evbppc file has the KGDB code, PReP does not:
"https://nxr.netbsd.org/xref/src/sys/arch/evbppc/walnut/consinit.c"
"https://nxr.netbsd.org/xref/src/sys/arch/prep/prep/consinit.c"

For trying to figure out where KGDB should be called during 
initialization with PReP port, this file in the powerpc common code 
seems to be it, it's where DDB is called if the option is enabled: 
"https://nxr.netbsd.org/xref/src/sys/arch/powerpc/oea/prep_machdep.c"
Some other ports look like this:
"https://nxr.netbsd.org/xref/src/sys/arch/i386/i386/machdep.c" line 
1412, it has KGDB, but boot process is significantly different for x86 
vs PowerPC (PReP)
"https://nxr.netbsd.org/xref/src/sys/arch/evbppc/virtex/machdep.c" line 
154, it has KGDB
"https://nxr.netbsd.org/xref/src/sys/arch/evbppc/walnut/machdep.c" line 
202 area, although KGDB is not included.

My experience with this sort of stuff is rather shallow, so if anyone 
knowledgeable can offer any suggestions, it would be appreciated. I'll 
keep tinkering with it and see if something makes it work in the meantime.