mirror of
https://github.com/golang/go
synced 2024-11-24 22:37:56 -07:00
combined pchw and embedded into tiny. added section on arm to README
R=rsc CC=golang-dev https://golang.org/cl/194151
This commit is contained in:
parent
c3fa32c747
commit
c0aac20e20
@ -1,4 +0,0 @@
|
||||
small embedded target for arm
|
||||
define the c function write to make debug output work
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
// Copyright 2010 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include "runtime.h"
|
||||
#include "malloc.h"
|
||||
|
||||
// Assume there's an arbitrary amount of memory starting at "end".
|
||||
|
||||
void*
|
||||
SysAlloc(uintptr ask)
|
||||
{
|
||||
static byte *p;
|
||||
extern byte end[];
|
||||
byte *q;
|
||||
|
||||
if(p == nil) {
|
||||
p = end;
|
||||
p += 7 & -(uintptr)p;
|
||||
}
|
||||
ask += 7 & -ask;
|
||||
|
||||
q = p;
|
||||
p += ask;
|
||||
·memclr(q, ask);
|
||||
return q;
|
||||
}
|
||||
|
||||
void
|
||||
SysFree(void *v, uintptr n)
|
||||
{
|
||||
USED(v, n);
|
||||
}
|
||||
|
||||
void
|
||||
SysUnused(void *v, uintptr n)
|
||||
{
|
||||
USED(v, n);
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
// nothing to see here
|
@ -1 +0,0 @@
|
||||
// nothing to see here
|
@ -1,89 +0,0 @@
|
||||
// Copyright 2010 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
#include "runtime.h"
|
||||
|
||||
int8 *goos = "pchw";
|
||||
|
||||
extern void ·write(int32 fd, void *v, int32 len, int32 cap); // slice, spelled out
|
||||
|
||||
int32
|
||||
write(int32 fd, void *v, int32 len)
|
||||
{
|
||||
·write(fd, v, len, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
void
|
||||
minit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
osinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
initsig(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
exit(int32)
|
||||
{
|
||||
for(;;);
|
||||
}
|
||||
|
||||
// single processor, no interrupts,
|
||||
// so no need for real concurrency or atomicity
|
||||
|
||||
void
|
||||
newosproc(M *m, G *g, void *stk, void (*fn)(void))
|
||||
{
|
||||
USED(m, g, stk, fn);
|
||||
throw("newosproc");
|
||||
}
|
||||
|
||||
void
|
||||
lock(Lock *l)
|
||||
{
|
||||
if(m->locks < 0)
|
||||
throw("lock count");
|
||||
m->locks++;
|
||||
if(l->key != 0)
|
||||
throw("deadlock");
|
||||
l->key = 1;
|
||||
}
|
||||
|
||||
void
|
||||
unlock(Lock *l)
|
||||
{
|
||||
m->locks--;
|
||||
if(m->locks < 0)
|
||||
throw("lock count");
|
||||
if(l->key != 1)
|
||||
throw("unlock of unlocked lock");
|
||||
l->key = 0;
|
||||
}
|
||||
|
||||
void
|
||||
noteclear(Note *n)
|
||||
{
|
||||
n->lock.key = 0;
|
||||
}
|
||||
|
||||
void
|
||||
notewakeup(Note *n)
|
||||
{
|
||||
n->lock.key = 1;
|
||||
}
|
||||
|
||||
void
|
||||
notesleep(Note *n)
|
||||
{
|
||||
if(n->lock.key != 1)
|
||||
throw("notesleep");
|
||||
}
|
||||
|
10
src/pkg/runtime/tiny/386/signal.c
Normal file
10
src/pkg/runtime/tiny/386/signal.c
Normal file
@ -0,0 +1,10 @@
|
||||
// just the write function
|
||||
|
||||
extern void ·write(int32 fd, void *v, int32 len, int32 cap); // slice, spelled out
|
||||
|
||||
int32
|
||||
write(int32 fd, void *v, int32 len)
|
||||
{
|
||||
·write(fd, v, len, len);
|
||||
return len;
|
||||
}
|
@ -1,16 +1,22 @@
|
||||
This directory contains a simple example of how one might
|
||||
start Go running on bare hardware. It is very primitive but
|
||||
can run go/test/sieve.go, the concurrent prime sieve, on a
|
||||
uniprocessor. It has only been tested using the Bochs emulator.
|
||||
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. It has only been tested using the
|
||||
Bochs emulator.
|
||||
|
||||
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=pchw
|
||||
export GOOS=tiny
|
||||
cd $GOROOT/src/pkg/runtime
|
||||
make clean
|
||||
make install
|
||||
cd pchw
|
||||
cd tiny
|
||||
8g $GOROOT/test/sieve.go
|
||||
8l sieve.8
|
||||
8l -a sieve.8 >sieve.asm # can consult sieve.asm for debugging
|
||||
@ -22,8 +28,43 @@ You may have to tweak the .bochsrc depending on your system,
|
||||
and you may need to install the Bochs emulator.
|
||||
|
||||
|
||||
ARM
|
||||
|
||||
The bootblock is from MIT's xv6 project and carries this notice:
|
||||
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:
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "runtime.h"
|
||||
|
||||
int8 *goos = "embedded";
|
||||
int8 *goos = "tiny";
|
||||
|
||||
void
|
||||
minit(void)
|
Loading…
Reference in New Issue
Block a user