1
0
mirror of https://github.com/golang/go synced 2024-10-03 06:21:21 -06:00
go/src/pkg/runtime/tiny
Russ Cox d4cc557b0d runtime: use manual stack for garbage collection
Old code was using recursion to traverse object graph.
New code uses an explicit stack, cutting the per-pointer
footprint to two words during the recursion and avoiding
the standard allocator and stack splitting code.

in test/garbage:

Reduces parser runtime by 2-3%
Reduces Peano runtime by 40%
Increases tree runtime by 4-5%

R=r
CC=golang-dev
https://golang.org/cl/2150042
2010-09-07 09:57:22 -04:00
..
386 runtime: finish pchw -> tiny, added gettime for tiny 2010-06-07 14:18:42 -07:00
arm combined pchw and embedded into tiny. added section on arm to README 2010-02-18 23:33:21 -08:00
bootblock combined pchw and embedded into tiny. added section on arm to README 2010-02-18 23:33:21 -08:00
dot-bochsrc combined pchw and embedded into tiny. added section on arm to README 2010-02-18 23:33:21 -08:00
io.go combined pchw and embedded into tiny. added section on arm to README 2010-02-18 23:33:21 -08:00
mem.c runtime: use manual stack for garbage collection 2010-09-07 09:57:22 -04:00
os.h combined pchw and embedded into tiny. added section on arm to README 2010-02-18 23:33:21 -08:00
README runtime/tiny: style and doc tweaks 2010-07-13 10:47:52 +10:00
signals.h combined pchw and embedded into tiny. added section on arm to README 2010-02-18 23:33:21 -08:00
thread.c runtime/tiny: style and doc tweaks 2010-07-13 10:47:52 +10:00

This directory contains a simple example of how one might
start Go running on bare hardware. There is currently code
for 386 and arm.


386

It is very primitive but can run go/test/sieve.go, the concurrent
prime sieve, on a uniprocessor.

To run, first build the tools by running all.bash with GOARCH=386
and GOOS set to your normal GOOS (linux, darwin).  Then:

	export GOOS=tiny
	cd $GOROOT/src/pkg/runtime
	make clean
	make install
	cd tiny
	8g $GOROOT/test/sieve.go
	8l sieve.8
	8l -a sieve.8 >sieve.asm	# can consult sieve.asm for debugging
	dd if=/dev/zero of=disk count=10000
	cat bootblock 8.out | dd of=disk conv=notrunc

Use the built-in print(text string) function to print to the
console.


BOCHS

You may have to tweak the .bochsrc depending on your system,
and you may need to install the Bochs emulator.

    $ cp dot-bochsrc .bochsrc
    $ $EDITOR .bochsrc # tweak it if required
    $ bochs


ORACLE xVM VIRTUALBOX

Install VirtualBox. Then:

    Build 'disk' (described above under '386').

    $ VBoxManage convertfromraw disk go-tiny.vdi
    $ VirtualBox
        create a new VM; as disk use the go-tiny.vdi image.
        start the vm.


QEMU / KVM

This should work the same for qemu and kvm (really: qemu-kvm).

    Build 'disk' (described above under '386').

    $ qemu -hda disk


ARM

First build the toolchain using GOARCH=arm and GOOS=linux. When
you build your embedded code set GOARCH=tiny.

	export GOOS=tiny
	cd $GOROOT/src/pkg/runtime
	make clean
	make install

On arm the tiny runtime doesn't define a low level write function. You can either
define a stub if you don't need debug output, or more usefully, define it to
print to some debug serial port. Here is a sample function that prints to
the DBGU on an at91sam7s:

#define DBGU_CSR  ((uint32*)   0xFFFFF214) // (DBGU) Channel Status Register
#define US_TXRDY        ((uint32) 0x1 <<  1) // (DBGU) TXRDY Interrupt
#define DBGU_THR  ((uint32*)   0xFFFFF21C) // (DBGU) Transmitter Holding Register

int32
write(int32 fd, void* b, int32 n)
{
	uint32 i;
	uint8* s = (uint8*)b;

	for (i = 0; i < n; i++) {
		while ((*DBGU_CSR & US_TXRDY) == 0) {
		}
		*DBGU_THR = *s;
		s++;
	}
	return n;
}



The 386 bootblock is from MIT's xv6 project and carries this notice:

    The xv6 software is:
    
    Copyright (c) 2006-2009 Frans Kaashoek, Robert Morris, Russ Cox,
                            Massachusetts Institute of Technology
    
    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    "Software"), to deal in the Software without restriction, including
    without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to
    permit persons to whom the Software is furnished to do so, subject to
    the following conditions:
    
    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.
    
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

http://pdos.csail.mit.edu/6.828/xv6/