とりあえず移植して割り込み処理まわりとか必要な部分を書いて、ブートだけはできるようになった。
(ブートローダーにも何箇所か手を入れた)
で、起動はできたのだけど、起動直後に落ちる。まああらかた書いたので、あとはデバッグかな。
とりあえず移植して割り込み処理まわりとか必要な部分を書いて、ブートだけはできるようになった。
(ブートローダーにも何箇所か手を入れた)
で、起動はできたのだけど、起動直後に落ちる。まああらかた書いたので、あとはデバッグかな。
diff -ruN h8_06/os/serial.c h8_07/os/serial.c
--- h8_06/os/serial.c Tue Sep 15 00:27:07 2009
+++ h8_07/os/serial.c Sat Sep 19 17:24:41 2009
@@ -1,4 +1,5 @@
#include "types.h"
+#include "interrupt.h"
#include "serial.h"
#define H8_3069F_SCI0 ((volatile struct h8_3069f_sci *)0xffffb0)
@@ -42,15 +43,35 @@
#define H8_3069F_SCI_SSR_RDRF (1<<6)
#define H8_3069F_SCI_SSR_TDRE (1<<7)
+void serial_interrupt()
+{
+ volatile struct h8_3069f_sci *sci = H8_3069F_SCI1;
+ int status, c;
+
+ status = sci->ssr;
+
+ c = serial_getc();
+ serial_putc(c);
+
+ sci->ssr = status & ~H8_3069F_SCI_SSR_RDRF;
+
+ return;
+}
+
int serial_init()
{
volatile struct h8_3069f_sci *sci = H8_3069F_SCI1;
+ /* 割り込みハンドラ登録 */
+ interrupt_sethandler(VECTYPE_RXI1, serial_interrupt);
+
sci->scr = 0;
sci->smr = 0;
sci->brr = 64; /* 20MHz 9600bps */
sci->scr = H8_3069F_SCI_SCR_RE | H8_3069F_SCI_SCR_TE;
sci->ssr = 0;
+
+ sci->scr |= H8_3069F_SCI_SCR_RIE; /* 割り込み許可 */
return 0;
}
diff -ruN h8_06/os/main.c h8_07/os/main.c
--- h8_06/os/main.c Tue Sep 15 00:27:07 2009
+++ h8_07/os/main.c Sat Sep 19 17:24:41 2009
@@ -66,6 +66,7 @@
}
#endif
+#if 0
static int gets(char *buf)
{
int i = 0, c = -1;
@@ -78,6 +79,7 @@
}
return i - 1;
}
+#endif
#if 0
static int dump(char *buf, int size)
@@ -105,7 +107,9 @@
int main()
{
+#if 0
char buf[80];
+#endif
init();
@@ -114,10 +118,12 @@
ENABLE_INTR;
while (1) {
+#if 0
puts("os> ");
gets(buf);
puts(buf);
puts("\n");
+#endif
}
return 0;
Hello World!
> load
~CLocal command? lsx hello
Sending hello, 19 blocks: Give your local XMODEM receive command now.
Bytes Sent: 2560 BPS:870
Transfer complete
eceive succeeded.
> run
starting from entry point.boot succeed!
IabIcIABICIIIIIII
--- hello/ld.scr Wed Sep 2 23:32:57 2009
+++ timer/ld.scr Mon Sep 14 22:13:00 2009
@@ -4,8 +4,11 @@
MEMORY
{
- /* reserve 256bytes space for ELF header */
- ram(rwx) : o = 0xffbf20 + 0x100, l = 0x004000 - 0x100 /* 16kb */
+ /*
+ * reserve 256bytes space for software interrupt vector
+ * and 256bytes space for ELF header.
+ */
+ ram(rwx) : o = 0xffbf20 + 0x200, l = 0x004000 - 0x200 /* 16kb */
stack(rw) : o = 0xffff00, l = 0x000010 /* end of RAM */
}
int timer_init()
{
...
interrupt_sethandler(VECTYPE_IMIA0, timer_interrupt);
...
teapot# make write
../../h8write/h8write -3069 -f20 kzload.mot
H8/3069F is ready! 2002/5/20 Yukio Mituiwa.
writing
WARNING:This Line dosen't start with"S".
Address Size seems wrong
WARNING:This Line dosen't start with"S".
Address Size seems wrong
.........................................................................
EEPROM Writing is successed.
teapot#
teapot# cu -l /dev/cuad0
Connected
Hello World!
> load
~CLocal command? lsx hello
Sending hello, 20 blocks: Give your local XMODEM receive command now.
Bytes Sent: 2688 BPS:665
Transfer complete
eceive succeeded.
> run
starting from entry point.boot succeed!
os> IIItest
test
os> IIIsampleI
sample
os> III
buffer(rwx) : o = 0xffdf20, l = 0x002000 /* 8kb */
#define BUFSIZE 4096
static unsigned char loadbuf[BUFSIZE];
--- kzload/ld.scr Fri Sep 4 00:16:17 2009
+++ os/ld.scr Fri Sep 4 00:16:35 2009
@@ -4,44 +4,38 @@
MEMORY
{
- vectors(r) : o = 0x000000, l = 0x000100 /* top of ROM */
- rom(rx) : o = 0x000100, l = 0x07ff00 /* 512kb */
- ram(rwx) : o = 0xffbf20, l = 0x004000 /* 16kb */
- buffer(rwx) : o = 0xffdf20, l = 0x002000 /* 8kb */
+ /* reserve 256bytes space for ELF header */
+ ram(rwx) : o = 0xffbf20 + 0x100, l = 0x004000 - 0x100 /* 16kb */
stack(rw) : o = 0xffff00, l = 0x000010 /* end of RAM */
}
SECTIONS
{
- .vectors : {
- vector.o(.data)
- } > vectors
-
.text : {
_text_start = . ;
*(.text)
_etext = . ;
- } > rom
+ } > ram
.rodata : {
_rodata_start = . ;
*(.strings)
*(.rodata)
_erodata = . ;
- } > rom
+ } > ram
- .data : AT(_erodata) {
+ .data : {
_data_start = . ;
*(.data)
_edata = . ;
- } > buffer
+ } > ram
.bss : {
_bss_start = . ;
*(.bss)
*(COMMON)
_ebss = . ;
- } > buffer
+ } > ram
_end = . ;
% ./make.sh clean ; ./make.sh ; ./make.sh image
% ./make.sh clean ; ./make.sh
% ./make.sh image
teapot# make write
../../h8write/h8write -3069 -f20 kzload.mot
H8/3069F is ready! 2002/5/20 Yukio Mituiwa.
writing
WARNING:This Line dosen't start with"S".
Address Size seems wrong
WARNING:This Line dosen't start with"S".
Address Size seems wrong
.......................................
EEPROM Writing is successed.
teapot#
teapot# cu -l /dev/cuad0
Connected
Hello World!
>
teapot# cu -l /dev/cuad0
Connected
Hello World!
> load
(待ち状態)
teapot# cu -l /dev/cuad0
Connected
Hello World!
> load
~CLocal command? lsx hello
> load
~CLocal command? lsx hello
Sending hello, 15 blocks: Give your local XMODEM receive command now.
Bytes Sent: 2048 BPS:586
Transfer complete
eceive succeeded.
>
> run
starting from entry point.boot succeed!
os>
> run
starting from entry point.boot succeed!
os> run
run
os> test
test
os> dump
dump
os> load
load
os> aaa
aaa
os>