OSDN Git Service

cae8809aba963189a3e22b4a09d3cb6280bf8fa1
[hos/hos-v4a.git] / aplfw / sample / sh / cq7144a / sample.c
1 /**
2  *  Sample program for Hyper Operating System V4 Advance
3  *
4  * @file  sample.c
5  * @brief %jp{サンプルプログラム}%en{Sample program}
6  *
7  * Copyright (C) 1998-2006 by Project HOS
8  * http://sourceforge.jp/projects/hos/
9  */
10
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include "kernel.h"
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/renesas/scidrv.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"
30 #include "regs_sh7144.h"
31
32
33 C_SCIDRV        g_SciDrv[4];
34 C_VT100DRV      g_Vt100Drv[1];
35
36
37
38 void Sample_Task(VP_INT exinf)
39 {
40         HANDLE                  hTty;
41         HANDLE                  hCon;
42         
43         
44         /*************************/
45         /*    固有初期設定       */
46         /*************************/
47         
48         *REG_STANDBY_MSTCR1 &= ~0x0002; /* %jp{SCI1のスタンバイモードを解除} */
49         *REG_PFC_PACRL2 |= 0x0100;              /* %jp{端子設定} */
50         
51         *REG_INTC_IPRF = ((*REG_INTC_IPRF & 0xfff0) | 0x0001);
52         
53         /*************************/
54         /*       初期化          *
55         /*************************/
56         
57         /* システム初期化 */
58         System_Initialize((void *)0x00440000, 0x40000);
59         
60         
61         /*************************/
62         /*   デバイスドライバ    */
63         /*************************/
64         
65         /* SCIデバドラ生成 */
66         SciDrv_Create(&g_SciDrv[0], (void *)REG_SCI0_SMR, 128, 24000000L, 64);  /* SCI0 */
67         SciDrv_Create(&g_SciDrv[1], (void *)REG_SCI1_SMR, 132, 24000000L, 64);  /* SCI1 */
68         SciDrv_Create(&g_SciDrv[2], (void *)REG_SCI2_SMR, 168, 24000000L, 64);  /* SCI2 */
69         SciDrv_Create(&g_SciDrv[3], (void *)REG_SCI3_SMR, 172, 24000000L, 64);  /* SCI3 */
70         
71         File_AddDevice("com0", (C_DRVOBJ *)&g_SciDrv[0]);       /* SCI0 を /dev/com0 に登録 */
72         File_AddDevice("com1", (C_DRVOBJ *)&g_SciDrv[1]);       /* SCI1 を /dev/com0 に登録 */
73         File_AddDevice("com2", (C_DRVOBJ *)&g_SciDrv[2]);       /* SCI2 を /dev/com0 に登録 */
74         File_AddDevice("com3", (C_DRVOBJ *)&g_SciDrv[3]);       /* SCI3 を /dev/com0 に登録 */
75         
76         /* シリアルを開く */
77         hTty = File_Open("/dev/com1", FILE_OPEN_READ | FILE_OPEN_WRITE);
78         
79         /* シリアル上にコンソールを生成( /dev/con0 に登録) */
80         Vt100Drv_Create(&g_Vt100Drv[0], hTty);
81         File_AddDevice("con1", (C_DRVOBJ *)&g_Vt100Drv[0]);
82         
83         /* コンソールを開く */
84         hCon = File_Open("/dev/con1", FILE_OPEN_READ | FILE_OPEN_WRITE);
85         
86         
87         /*************************/
88         /*     コマンド登録      */
89         /*************************/
90         Command_AddCommand("hsh",      Shell_Main);
91         Command_AddCommand("hello",    Hello_Main);
92         Command_AddCommand("memdump",  MemDump_Main);
93         Command_AddCommand("memwrite", MemWrite_Main);
94         Command_AddCommand("memtest",  MemTest_Main);
95         Command_AddCommand("keytest",  KeyTest_Main);
96         
97         
98         /*************************/
99         /*  システムプロセス起動 */
100         /*************************/
101         System_Boot(hTty, hCon, "hsh", 4096);
102 }
103
104
105
106 /* end of file */