OSDN Git Service

(none)
[hos/hos-v4a.git] / aplfw / sample / arm / ez_arm7 / 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/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"
30
31
32 long         g_SystemHeap[64 * 1024 / sizeof(long)];
33 C_PC16550DRV g_Pc16550Drv[1];
34 C_VT100DRV   g_Vt100Drv[1];
35
36
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)
43
44
45 void Sample_Task(VP_INT exinf)
46 {
47         HANDLE                  hTty;
48         HANDLE                  hCon;
49         
50         /*************************/
51         /*    固有初期設定       */
52         /*************************/
53         
54         /* PLL設定 */
55 #if 1
56         *REG_PLLCFG   = ((0x1 << 5) | (0x3 << 0));      /* M=4, P=2 (Fosc=14.7MHz, Fcco=235.2MHz, cclk=58.8MHz) */
57         *REG_PLLCON  |= 0x01;
58         *REG_PLLFEED  = 0xaa;
59         *REG_PLLFEED  = 0x55;
60         while ( !(*REG_PLLSTAT & 0x0400) )
61                 ;
62         *REG_PLLCON  |= 0x02;
63         *REG_PLLFEED  = 0xaa;
64         *REG_PLLFEED  = 0x55;
65 #endif
66         
67         /* Pin設定 */
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));
71         
72         
73         /*************************/
74         /*       初期化          */
75         /*************************/
76         
77         /* システム初期化 */
78         System_Initialize(g_SystemHeap, sizeof(g_SystemHeap));
79         
80         
81         /*************************/
82         /*   デバイスドライバ    */
83         /*************************/
84         
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]);
88
89         /* シリアルを開く */
90         hTty = File_Open("/dev/com0", FILE_OPEN_READ | FILE_OPEN_WRITE);
91         
92         /* シリアル上にコンソールを生成( /dev/con0 に登録) */
93         Vt100Drv_Create(&g_Vt100Drv[0], hTty);
94         File_AddDevice("con0", (C_DRVOBJ *)&g_Vt100Drv[0]);
95         
96         /* コンソールを開く */
97         hCon = File_Open("/dev/con0", FILE_OPEN_READ | FILE_OPEN_WRITE);
98         
99         
100         
101         /*************************/
102         /*     コマンド登録      */
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);
110         
111         
112         /*************************/
113         /*  システムプロセス起動 */
114         /*************************/
115         System_Boot(hTty, hCon, "hsh", 4096);
116 }
117
118
119
120 /* end of file */