2. 2
The latest version of this slide will
be available from here
http://www.slideshare.net/tetsu.koba/presentati
ons
3. 3
Who am I?
20+ years involved in embedded systems
10 years in real time OS, such as iTRON
10 years in embedded Java Virtual Machine
Now GCC, Linux, QEMU, Android, …
Blogs
http://d.hatena.ne.jp/embedded/
http://kobablog.wordpress.com/(English)
Twitter
@tetsu_koba
4. 4
Golang for ARM Linux
ツールチェインのビルド
ソースコードを入手して
$ cd go/src
$ GOOS=linux GOARCH=arm GOARM=5 ./make.bash
実行型のビルド
Go コマンドに PATH を通して
$ GOOS=linux GOARCH=arm GOARM=5 go build hello.go
5. 5
GOARM
GOARM=5
For armv5, no FPU, soft float
GOARM=6
(Default)
For armv6, VFPv1
GOARM=7
For armv7, VFPv3
20. 20
_sfloat のソースコードを追跡
_sfloat in go/src/runtime/vlop_arm.s
→ runtime ・ _sfloat2
_sfloat2 in go/src/runtime/softfloat_arm.c
→ sfloat2
21. 21
static void sfloat2(void)
{
…
while (skip = stepflt(pc, (uint32*)®s->r0)){
:
:
pc += skip
}
g->m->ptarg[0] = pc;
}
Soft float emulation inside golang
Comment is source code:
stepflt returns number of words that the fp instruction is occupying,
0 if next instruction isn't float
FPU 命令のインタープリタ
22. 22
// returns number of words that the fp instruction
// is occupying, 0 if next instruction isn't float.
static uint32
stepflt(uint32 *pc, uint32 *regs)
{
...
switch(i & 0xffff0ff0) {
default:
goto done;
case 0xeeb00a40: // F[regd] = F[regm] (MOVF)
m->freglo[regd] = m->freglo[regm];
if(trace)
runtime·printf("*** F[%d] = F[%d] %xn",
regd, regm, m->freglo[regd]);
break;
case 0xeeb00b40: // D[regd] = D[regm] (MOVD)
stepflt は FPU 命令のインタープリタ