OpenBSD/sgi on octane2 - cpu1デバッグ用のcom1向け簡易printfの実装 その2
printf関係ないけど、要らんコードをちょっと捨てた。
#define COM_NPORTS 8 #define COMBBUF_SIZE 2048 int combfreq = 22000000 / 3; int combrate = (B9600); bus_addr_t combaddr = 0x500000 + IOC3_UARTB_BASE; bus_space_tag_t combiot = &sys_config.console_io; bus_space_handle_t combioh; char combbuf[COMBBUF_SIZE] = {0}; void cominit(bus_space_tag_t iot, bus_space_handle_t ioh, int rate, int frequency); static void combinit(void) { if (bus_space_map(combiot, combaddr, COM_NPORTS, 0, &combioh)) panic("comcninit: mapping failed"); cominit(combiot, combioh, combrate, combfreq); } static void combputc(int c) { com_common_putc(combiot, combioh, c); } static int combprintf(const char *fmt, ...) { int i; va_list ap; va_start(ap, fmt); vsnprintf(combbuf, COMBBUF_SIZE, fmt, ap); va_end(ap); for(i = 0; i < COMBBUF_SIZE; i++) if(combbuf[i] == '\0') break; else combputc(combbuf[i]); return 0; }