⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cinit.c

📁 一个简单的小型操作系统
💻 C
字号:

/*****************************************************************************
 *
 * Module       : cinit.c
 * Description  : initialize the command line and task1 
 * OS           : SLOS 0.09
 * Platform     : e7t
 * History      :
 *
 * 10th November 2001 Andrew N. Sloss
 * - created
 *
 * 11th December 2001 Andrew N. Sloss
 * - updated the cinit with comments and new structure
 *
 *****************************************************************************/

/*****************************************************************************
 * IMPORTS
 *****************************************************************************/

#include "all.h"
#include "../e7t/events/event_init.h"

/*****************************************************************************
 * MACROS
 *****************************************************************************/

/* trace - note this should go into a separate file ... */

#define DEVICESINIT    1
#define SERVICESINIT   2
#define TICKINIT       3
#define CINITINIT      4
#define TICKSTART      5
#define ENTERTASK      6

#define LOW_LEVEL_INITIALIZATION   1
#define BOOT_SLOS                  2

/*****************************************************************************
 * DATATYPES
 *****************************************************************************/

/* none... */

/*****************************************************************************
 * STATICS
 *****************************************************************************/

unsigned int STATE;
	
/*****************************************************************************
 * ROUTINUES
 *****************************************************************************/

/* -- cinit_init --------------------------------------------------------------
 *
 * Description : platform initialization C code is placed here
 *
 * Parameters  : none...
 * Return      : none...
 * Notes       : none...
 *		  
 */

void cinit_init(void)
{

STATE = LOW_LEVEL_INITIALIZATION;

 /* -------------------------------------------------------------------
  * Initialize all the device drivers
  * 
  * This routine has to be called before any of the device driver can 
  * be used. It complies with version 0.01 of the Wright Device Driver 
  * Framework (v0.01).
  *
  * ------------------------------------------------------------------- 
  */

lltrace(eventIODeviceInit(),DEVICESINIT);

 /* -------------------------------------------------------------------
  * 
  * Initialize all the unique services /pod/events/e7t/init.h
  * In SLOS Services are devices that cause interrupts.
  *
  * ------------------------------------------------------------------- 
  */

lltrace(eventServicesInit(),SERVICESINIT);

 /* -------------------------------------------------------------------
  * 
  * Initialize the timer to interrupt every 2 milliseconds
  * 
  * ------------------------------------------------------------------- 
  */
 
lltrace(eventTickInit(2),TICKINIT);
}

/* -- C_Entry -----------------------------------------------------------------
 *
 * Description: C entry point
 * 
 * Parameters  : none...
 * Return      : return 1 if successful
 * Notes       : none...
 *
 */

int C_Entry(void)
{
	
 /* --------------------------------------------------------------------
  * 
  * Initalize all the internal data structures for device drivers and
  * services. 
  *
  * Terminology:
  *
  *  - services are called by interrupt... 
  *  - device drivers are called by applications
  *
  * -------------------------------------------------------------------
  */

lltrace(cinit_init(),CINITINIT);
	
 /* -------------------------------------------------------------------
  *
  * Start the periodic timer. This will not effect the system until 
  * IRQ or FIQ interrupts are enabled.
  * 
  * -------------------------------------------------------------------
  */

lltrace(eventTickStart(),TICKSTART);

 /* ------------------------------------------------------------------- 
  *
  * Turn On interrupts (I_bit=0) and change mode to User Mode.
  *
  * -------------------------------------------------------------------
  */

STATE=BOOT_SLOS;

  asm volatile ("MSR  CPSR_c,#0x50");

 /* -------------------------------------------------------------------
  *
  * Enter into Application/Task1 
  * 
  * -------------------------------------------------------------------
  */

lltrace(C_EntryTask1(),ENTERTASK); 

 /* -------------------------------------------------------------------
  *
  * THIS CODE SHOULD NEVER BE REACHED 
  *
  * -------------------------------------------------------------------
  */
 
return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -