OSDN Git Service

update jelly sample (MIPS)
[hos/hos-v4a.git] / aplfw / sample / arm / utb_arm7at91 / boot.c
1 /**
2  * Hyper Operating System  Application Framework Library
3  *   μTeaboard/ARM7-AT91 用サンプルプログラム
4  *
5  * @file  boot_task.c
6  * @brief %jp{サンプルプログラム}%en{Sample program}
7  *
8  * Copyright (C) 1998-2007 by Project HOS
9  * http://sourceforge.jp/projects/hos/
10  */
11
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include "kernel.h"
17 #include "kernel_id.h"
18 #include "system/system/system.h"
19 #include "system/sysapi/sysapi.h"
20 #include "system/file/console.h"
21 #include "system/process/process.h"
22 #include "system/command/command.h"
23 /* #include "driver/ether/lan9118/lan9118drv.h" */
24 #include "driver/tcpip/ipether/ipether.h"
25 #include "driver/tcpip/tcpip/tcpip.h"
26 #include "driver/serial/at91/at91usartdrv.h"
27 #include "driver/console/vt100/vt100drv.h"
28 #include "driver/volume/fat/fatvol.h"
29 #include "application/syscmd/shell/shell.h"
30 #include "application/flashcmd/norflashcmd/norflashcmd.h"
31 #include "application/utility/memdump/memdump.h"
32 #include "application/utility/memwrite/memwrite.h"
33 #include "application/utility/memtest/memtest.h"
34 #include "application/utility/keytest/keytest.h"
35 #include "application/utility/timecmd/timecmd.h"
36 #include "application/netcmd/ethersnoop/ethersnoop.h"
37 #include "application/example/hello/hello.h"
38 #include "boot.h"
39 #include "ostimer.h"
40
41
42 long                    g_SystemHeap[32 * 1024 / sizeof(long)];
43
44
45 /* IP層生成情報 */
46 static const T_IPETHER_INF IpEtherInf =
47 {
48         {192, 168,   0, 100},           /* IPアドレス */
49         {255, 255, 255,   0},           /* サブネットマスク */
50         {192, 168,   0,   1},           /* デフォルトゲートウェイアドレス */
51 };
52
53
54 int Boot_Process(VPARAM Param);
55
56 /* ブートタスク */
57 void Boot_Task(VP_INT exinf)
58 {
59         T_SYSTEM_INITIALIZE_INF SysInf;
60
61         
62         /*************************/
63         /*    固有初期設定       */
64         /*************************/
65         
66         
67         
68         /*************************/
69         /*       初期化          */
70         /*************************/
71         
72         /* システム初期化 */
73         memset(&SysInf, 0, sizeof(SysInf));
74         SysInf.pSysMemBase     = g_SystemHeap;
75         SysInf.SysMemSize      = sizeof(g_SystemHeap);
76         SysInf.SysMemAlign     = 4;
77         SysInf.pIoMemBase      = NULL;
78         SysInf.SystemStackSize = 1024;
79         SysInf.pfncBoot        = Boot_Process;
80         SysInf.BootParam       = (VPARAM)0;
81         SysInf.BootStackSize   = 4096;
82         System_Initialize(&SysInf);
83 }
84
85
86 /* ブートプロセス */
87 int Boot_Process(VPARAM Param)
88 {
89         HANDLE  hTty;
90         HANDLE  hCon;
91         HANDLE  hDriver;
92         
93         
94         OsTimer_Initialize();
95         
96         
97         /*************************/
98         /*   デバイスドライバ    */
99         /*************************/
100         
101 #if 0
102         /* LAN9118デバドラ生成 (/dev/eth0 に登録) */
103         Lan9118Drv_Create(&g_Lan9118Drv[0], (void *)0x40000000, 24);
104         File_AddDevice("eth0", (C_DRVOBJ *)&g_Lan9118Drv[0]);
105         
106         /* Ether上にIP層構築 (/dev/ip0 に登録) */
107         IpEther_Create(&g_IpEther[0], "/dev/eth0", &IpEtherInf);
108         File_AddDevice("ip0", (C_DRVOBJ *)&g_IpEther[0]);
109
110         /* IP層の上にTCP/IP層構築 (/dev/tcpip0 に登録) */
111         TcpIp_Create(&g_TcpIp[0], "/dev/ip0");
112         File_AddDevice("tcpip0", (C_DRVOBJ *)&g_TcpIp[0]);
113 #endif  
114         
115         /* AT91 USARTデバドラ生成 (/dev/com0 に登録) */
116         hDriver = At91UsartDrv_Create((void *)0xfffc0000, 2, 32000000, 64);
117         File_AddDevice("com0", hDriver);
118
119         /* AT91 USARTデバドラ生成 (/dev/com1 に登録) */
120         hDriver = At91UsartDrv_Create((void *)0xfffc4000, 3, 32000000, 64);
121         File_AddDevice("com1", hDriver);
122         
123         /* AT91 USARTデバドラ生成 (/dev/com2 に登録) */
124         hDriver = At91UsartDrv_Create((void *)0xfffc8000, 4, 32000000, 64);
125         File_AddDevice("com2", hDriver);
126         
127         /* シリアルを開く */
128         hTty = File_Open("/dev/com0", FILE_OPEN_READ | FILE_OPEN_WRITE);
129         
130         /* シリアル上にコンソールを生成(/dev/con0 に登録) */
131         hDriver = Vt100Drv_Create(hTty);
132         File_AddDevice("con0", hDriver);
133         
134         /* コンソールを開く */
135         hCon = File_Open("/dev/con0", FILE_OPEN_READ | FILE_OPEN_WRITE);
136         
137
138         /*************************/
139         /*     標準入出力設定    */
140         /*************************/
141         
142         Process_SetTerminal(HANDLE_NULL, hTty);
143         Process_SetConIn(HANDLE_NULL, hCon);
144         Process_SetConOut(HANDLE_NULL, hCon);
145         Process_SetStdIn(HANDLE_NULL, hCon);
146         Process_SetStdOut(HANDLE_NULL, hCon);
147         Process_SetStdErr(HANDLE_NULL, hCon);
148         
149         
150         /*************************/
151         /*     コマンド登録      */
152         /*************************/
153         
154         Command_AddCommand("hsh",      Shell_Main);
155         Command_AddCommand("hello",    Hello_Main);
156         Command_AddCommand("memdump",  MemDump_Main);
157         Command_AddCommand("memwrite", MemWrite_Main);
158         Command_AddCommand("memtest",  MemTest_Main);
159         Command_AddCommand("keytest",  KeyTest_Main);
160         Command_AddCommand("time",     TimeCmd_Main);
161         Command_AddCommand("norflash", NorFlashCmd_Main);
162         Command_AddCommand("ethsnoop", EtherSnoop_Main);
163         
164         /* 起動メッセージ */
165         StdIo_PutString(
166                         "\n\n"
167                         "================================================================\n"
168                         " Hyper Operating System  Application Framework\n"
169                         "\n"
170                         "                          Copyright (C) 1998-2007 by Project HOS\n"
171                         "                          http://sourceforge.jp/projects/hos/\n"
172                         "================================================================\n"
173                         "\n");
174         
175         /*************************/
176         /*      シェル起動       */
177         /*************************/
178         
179         Command_Execute("hsh -i", NULL);
180         
181         return 0;
182 }
183
184
185
186 /* end of file */