2 * Sample program for Hyper Operating System V4 Advance
5 * @brief %jp{サンプルプログラム}%en{Sample program}
7 * Copyright (C) 1998-2006 by Project HOS
8 * http://sourceforge.jp/projects/hos/
16 #include "kernel_id.h"
17 #include "system/system/system.h"
18 #include "system/sysapi/sysapi.h"
19 #include "system/file/console.h"
20 #include "system/process/process.h"
21 #include "system/command/command.h"
22 #include "system/shell/shell.h"
23 #include "driver/serial/pc16550/pc16550drv.h"
24 #include "driver/console/vt100/vt100drv.h"
25 #include "apl/hello/hello.h"
26 #include "apl/util/memdump/memdump.h"
27 #include "apl/util/memwrite/memwrite.h"
28 #include "apl/util/memtest/memtest.h"
29 #include "apl/util/keytest/keytest.h"
32 long g_SystemHeap[64 * 1024 / sizeof(long)];
33 C_PC16550DRV g_Pc16550Drv[1];
34 C_VT100DRV g_Vt100Drv[1];
37 #define REG_PLLCON ((volatile UB *)0xe01fc080)
38 #define REG_PLLCFG ((volatile UB *)0xe01fc084)
39 #define REG_PLLSTAT ((volatile UH *)0xe01fc088)
40 #define REG_PLLFEED ((volatile UB *)0xe01fc08c)
41 #define REG_PINSEL0 ((volatile UW *)0xe002c000)
42 #define REG_BCFG0 ((volatile UW *)0xffe00000)
45 void Sample_Task(VP_INT exinf)
50 /*************************/
52 /*************************/
56 *REG_PLLCFG = ((0x1 << 5) | (0x3 << 0)); /* M=4, P=2 (Fosc=14.7MHz, Fcco=235.2MHz, cclk=58.8MHz) */
60 while ( !(*REG_PLLSTAT & 0x0400) )
68 *REG_PINSEL0 = (*REG_PINSEL0 & 0xfffffff0) | 0x05;
69 // *REG_BCFG0 = ((0x1 << 28) | (0x03 << 11) | (0x03 << 5) | (0x03 << 0));
70 // *REG_BCFG0 = ((0x1 << 28) | (0x0f << 11) | (0x0f << 5) | (0x0f << 0));
73 /*************************/
75 /*************************/
78 System_Initialize(g_SystemHeap, sizeof(g_SystemHeap));
81 /*************************/
83 /*************************/
85 /* 16550デバドラ生成 (/dev/com0 に登録) */
86 Pc16550Drv_Create(&g_Pc16550Drv[0], (void *)0xe000c000, 2, 6, 14700000, 64);
87 File_AddDevice("com0", (C_DRVOBJ *)&g_Pc16550Drv[0]);
90 hTty = File_Open("/dev/com0", FILE_OPEN_READ | FILE_OPEN_WRITE);
92 /* シリアル上にコンソールを生成( /dev/con0 に登録) */
93 Vt100Drv_Create(&g_Vt100Drv[0], hTty);
94 File_AddDevice("con0", (C_DRVOBJ *)&g_Vt100Drv[0]);
97 hCon = File_Open("/dev/con0", FILE_OPEN_READ | FILE_OPEN_WRITE);
101 /*************************/
103 /*************************/
104 Command_AddCommand("hsh", Shell_Main);
105 Command_AddCommand("hello", Hello_Main);
106 Command_AddCommand("memdump", MemDump_Main);
107 Command_AddCommand("memwrite", MemWrite_Main);
108 Command_AddCommand("memtest", MemTest_Main);
109 Command_AddCommand("keytest", KeyTest_Main);
112 /*************************/
114 /*************************/
115 System_Boot(hTty, hCon, "hsh", 4096);