シリアル入出力の修正
μT-Kernel では、シリアル入出力の初期化は sio_init というルーチンで、前述の icrt0.S の中から呼ばれており、lib/libtm/src/sysdepend/機種名/sio.S ないし sio.c に定義がある。また、メッセージの表示は tm_putstring 関数を経由して sio_send_frame を呼んでいる。
Raspberry Pi では、初期化は U-Boot に任せることにして、何もしない(呼び出しだけは残してある)。移植のベースとした AT91 版では sio.S というアセンブリ言語のソースだが、Raspberry Pi 版は C 言語で記述することにした。
lib/libtm/src/sysdepend/app_raspib/sio.c は次のようになった。
void sio_init(void) { /* NOP: do nothing. already initialized by u-boot */ } void sio_send_frame(unsigned char const *buf, int size) { while (size > 0) { /* Wait until there is space in the FIFO */ while (in_w(PL011_STAT) & 0x00000020U) { /* NOP */ } out_w(PL011_IO, *buf); ++buf; --size; } } void sio_recv_frame(unsigned char *buf, int size) { while (size > 0) { /* Wait until there is data in the FIFO */ while (in_w(PL011_STAT) & 0x00000010U) { /* NOP */ } *buf = (unsigned char)in_w(PL011_IO); ++buf; --size; } }
in_w と out_w は AT91 版からあるマクロ( include/tk/sysdepend/app_at91/syslib_depend.h を参照)、PL011_??? というマクロは Raspberry Pi に合わせて include/tk/sysdepend/app_raspib/sysdef_depend.h で定義してある。sysdef.h → sysdef_common.h → sysdef_depend.h のようにインクルードされる。