Subject: Re: Startup code of NetBSD
To: NetBSD tech-kern <>
From: Anand Lalgondar <>
List: tech-kern
Date: 12/12/2003 15:08:40

Thank you Kunz for the information provided. I followed it and could
understand some flow, but I have look to them in detail.

If some one could help in this issue, that would be great, which will
help in testing and verification of the on-board and on-chip peripherals
of my MIPS Target Board.

First the approach...
Referring the MIPS Target Board and the MIPS processor manual I could
figure out the starting address of both on-chip and on-board peripherals.

I think the register content can be accessed as mentioned below with an

#define REGVAL(x) (*((unsigned int *)((x))))  /* Used to access the
registers */

#define BASEADDR  0xF1FF0000 /* Base address of all the on-chip
peripherals */

#define SIOBASE   0xF300     /* RS232 Serial IO peripheral offset address
#define TXFIFO    0x1C       /* Trasmit FIFO offset from SIOBASE */

so to send data out to serial port:
REGVAL(BASEADDR + SIOBASE + TXFIFO) =3D c; /* where c is some char c
initialized */

In this way I could access all the devices.

I have written a program that will output data to the serial port and I
would like to compile it with the cross-compiler tool-chain
"mipsel--netbsd-as, mipsel--netbsd-gcc and mipsel--netbsd-ld". As per my
knowledge to put a srec file you require an ld.ldscript file which
contains the stating address of your ".text .data and .bss". So below is
the files that I have written.

#define REGVAL(x)       *((unsigned int *)((x)))
#define SIOREGVAL(x)    REGVAL(x)

#define TXBASE32        0xFF1F0000              /* base address */
#define SIO0_BASE       0xF300                  /* SIO0 offset */

#define ADDR    (TXBASE32 + SIO0_BASE)          /* base address of SIO0

#define SISCISR         0x0C
#define  SISCISR_TRDY           (1 <<  2)       /* transmit ready */

#define SITFIFO         0x1C                    /* transmit FIFO register
(8 bit) */

void print (char *);
static void txsio_common_putc(int);

int main (void)
	print("Hello World\n");
	return 1;

void print(char *ptr)

static void
txsio_common_putc(int c)

 . =3D 0x80020000;
 .text : { *(.text) }
 .data : { *(.data) }
 .bss : { *(.bss) }

The file "txsio.c" compiles without problem in i386 and gives out an
txsio.o file (#make txsio). But when cross-compile using
"mipsel--netbsd-gcc" it gives out an error as:
/usr/tooldir/mipsel--netbsd/bin/ld: cannot open crt0.o: No such file or
collect2: ld returned 1 exit status

I tried writting a dummy crt0.S file and assembling it with
mipsel--netbsd-as, but nothing came out.

Well at this point I would like to know how to compile the file and get
running on my target board at the specified starting address mentioned in
ld.ldscript file.

Finally I should be able to do get an srec file, below is the command
with so many options missing that I don't know (please mentione if any is
mipsel--netbsd-ld -T ld.ldscript -o txsio.srec txsio.o

Thanks anyways.

 - Anand

On Tue, 9 Dec 2003 10:22:59 +0100, "Jochen Kunz"
<> said:
> On Tue, 09 Dec 2003 11:29:13 +0530
> "Anand Lalgondar" <> wrote:
> > Where is the starting point of the NetBSD code. Does it start from
> > machine independent (i.e /sys/kern/xxx.c) or is it machine dependent
> > (xxx.c - don't know [may be machdep.c] ).=20
> It is in machine dependent code, typically in
> src/sys/arch/<ARCH>/<ARCH>/locore.S e.g. label "start" in
> src/sys/arch/ofppc/ofppc/locore.S. It seams that the MIPS architectures
> use a platform independent locore.S in src/sys/arch/mips/mips/locore.S.
> Usually this assembler code calles a function in
> src/sys/arch/<ARCH>/<ARCH>/machdep.c to do other low level
> initialisation stuff. E.g. mach_init() in
> src/sys/arch/pmax/pmax/machdep.c or initppc() in
> src/sys/arch/ofppc/ofppc/machdep.c. When that call returns to locore.S,
> main() in src/sys/kern/init_main.c is called doing machine independent
> startup.
> > One more question -=20
> > One of my MIPS Target Board does not boot up with the NetBSD Kernel,
> > since the RTC chip onboard is burnt out. Is it compulsory to implement
> > RTC driver in the NetBSD kerenel, or can it be removed.=20
> You may not need a RTC, but a timer that deliveres the time base for
> scheduling etc. is mandatory.
> --=20
> tsch=FC=DF,
>        Jochen
> Homepage:

--=20 - Choose from over 50 domains or use your own