]> Cypherpunks repositories - gostls13.git/commitdiff
combined pchw and embedded into tiny. added section on arm to README
authorKai Backman <kaib@golang.org>
Fri, 19 Feb 2010 07:33:21 +0000 (23:33 -0800)
committerRuss Cox <rsc@golang.org>
Fri, 19 Feb 2010 07:33:21 +0000 (23:33 -0800)
R=rsc
CC=golang-dev
https://golang.org/cl/194151

21 files changed:
src/pkg/runtime/embedded/README [deleted file]
src/pkg/runtime/embedded/mem.c [deleted file]
src/pkg/runtime/pchw/386/signal.c [deleted file]
src/pkg/runtime/pchw/os.h [deleted file]
src/pkg/runtime/pchw/thread.c [deleted file]
src/pkg/runtime/tiny/386/defs.h [moved from src/pkg/runtime/embedded/arm/defs.h with 100% similarity]
src/pkg/runtime/tiny/386/rt0.s [moved from src/pkg/runtime/pchw/386/rt0.s with 100% similarity]
src/pkg/runtime/tiny/386/signal.c [new file with mode: 0644]
src/pkg/runtime/tiny/386/sys.s [moved from src/pkg/runtime/pchw/386/sys.s with 100% similarity]
src/pkg/runtime/tiny/README [moved from src/pkg/runtime/pchw/README with 60% similarity]
src/pkg/runtime/tiny/arm/defs.h [moved from src/pkg/runtime/pchw/386/defs.h with 100% similarity]
src/pkg/runtime/tiny/arm/rt0.s [moved from src/pkg/runtime/embedded/arm/rt0.s with 100% similarity]
src/pkg/runtime/tiny/arm/signal.c [moved from src/pkg/runtime/embedded/arm/signal.c with 100% similarity]
src/pkg/runtime/tiny/arm/sys.s [moved from src/pkg/runtime/embedded/arm/sys.s with 100% similarity]
src/pkg/runtime/tiny/bootblock [moved from src/pkg/runtime/pchw/bootblock with 100% similarity]
src/pkg/runtime/tiny/dot-bochsrc [moved from src/pkg/runtime/pchw/dot-bochsrc with 100% similarity]
src/pkg/runtime/tiny/io.go [moved from src/pkg/runtime/pchw/io.go with 100% similarity]
src/pkg/runtime/tiny/mem.c [moved from src/pkg/runtime/pchw/mem.c with 100% similarity]
src/pkg/runtime/tiny/os.h [moved from src/pkg/runtime/embedded/os.h with 100% similarity]
src/pkg/runtime/tiny/signals.h [moved from src/pkg/runtime/pchw/signals.h with 100% similarity]
src/pkg/runtime/tiny/thread.c [moved from src/pkg/runtime/embedded/thread.c with 97% similarity]

diff --git a/src/pkg/runtime/embedded/README b/src/pkg/runtime/embedded/README
deleted file mode 100644 (file)
index 6ca7985..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-small embedded target for arm
-define the c function write to make debug output work
-
-
diff --git a/src/pkg/runtime/embedded/mem.c b/src/pkg/runtime/embedded/mem.c
deleted file mode 100644 (file)
index 0232c6c..0000000
+++ /dev/null
@@ -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);
-}
-
diff --git a/src/pkg/runtime/pchw/386/signal.c b/src/pkg/runtime/pchw/386/signal.c
deleted file mode 100644 (file)
index 5df7576..0000000
+++ /dev/null
@@ -1 +0,0 @@
-// nothing to see here
diff --git a/src/pkg/runtime/pchw/os.h b/src/pkg/runtime/pchw/os.h
deleted file mode 100644 (file)
index 5df7576..0000000
+++ /dev/null
@@ -1 +0,0 @@
-// nothing to see here
diff --git a/src/pkg/runtime/pchw/thread.c b/src/pkg/runtime/pchw/thread.c
deleted file mode 100644 (file)
index 4feb9a5..0000000
+++ /dev/null
@@ -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");
-}
-
diff --git a/src/pkg/runtime/tiny/386/signal.c b/src/pkg/runtime/tiny/386/signal.c
new file mode 100644 (file)
index 0000000..a39a481
--- /dev/null
@@ -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;
+}
similarity index 60%
rename from src/pkg/runtime/pchw/README
rename to src/pkg/runtime/tiny/README
index 4987f58ff2e9197f6368b17ecefc0ace202fc3c0..1a39e4251e965dd9387d9b2454ee29fafb7b90a5 100755 (executable)
@@ -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
+
+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 bootblock is from MIT's xv6 project and carries this notice:
+The 386 bootblock is from MIT's xv6 project and carries this notice:
 
     The xv6 software is:
     
similarity index 97%
rename from src/pkg/runtime/embedded/thread.c
rename to src/pkg/runtime/tiny/thread.c
index 49b764b6d9d3822530ad95aee07084eee03a78cb..e3e8a34b601f641f9e4fe46e87e4ea5fb65161bc 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "runtime.h"
 
-int8 *goos = "embedded";
+int8 *goos = "tiny";
 
 void
 minit(void)