/* usrKernel.c - wind kernel initialization */
/* Copyright 1992-1999 Wind River Systems, Inc. */
/*
modification history
--------------------
01f,20jan99,jpd added INITIAL_MEM_ALLOCATION.
01e,18sep95,ism imported conditional include of wvLib.h from bootConfig.c
01d,28mar95,kkk moved kernel defines to configAll.h
01c,07dec93,smb configuration change for windview
01b,10nov92,jcf configuration change for MicroWorks.
01a,18sep92,jcf written.
*/
/*
DESCRIPTION
This file is used to configure and initialize the Wind kernel. This file is
included by usrConfig.c.
NOMANUAL
*/
#ifdef INCLUDE_WDB
#define FREE_MEM_START_ADRS (FREE_RAM_ADRS + WDB_POOL_SIZE)
#else /* ! INCLUDE_WDB */
#define FREE_MEM_START_ADRS FREE_RAM_ADRS
#endif
#ifdef INCLUDE_INITIAL_MEM_ALLOCATION
#define MEM_POOL_START (char *) /
(ROUND_UP(FREE_MEM_START_ADRS, (INITIAL_MEM_ALIGNMENT)) + /
(INITIAL_MEM_SIZE))
#else /* INCLUDE_INITIAL_MEM_ALLOCATION */
#define MEM_POOL_START (char *) FREE_MEM_START_ADRS
#endif /* INCLUDE_INITIAL_MEM_ALLOCATION */
/* global variables */
#ifdef INCLUDE_CONSTANT_RDY_Q
BMAP_LIST readyQBMap; /* bit mapped ready queue list array */
#endif /* INCLUDE_CONSTANT_RDY_Q */
/*******************************************************************************
*
* usrKernelInit - configure kernel data structures
*
* NOMANUAL
*/
#define COM1_PORT 0x3F8
void com_send_data(unsigned char sdata);
int com1_send_data_ready(void);
void com1_send_data(unsigned char data);
void com1_init(void)
{
int data;
sysOutByte(COM1_PORT+3,0x80); //DLAB="1", set baud
sysOutByte(COM1_PORT,0x0c); // 波特率 0x30:2400 0x18:4800 0x0c:9600
sysOutByte(COM1_PORT+2,0x87);
sysOutByte(COM1_PORT+2,0x81);
sysOutByte(COM1_PORT+1,0x00);
sysOutByte(COM1_PORT+3,0x03); //data length: 8 , stop bits: 1
sysOutByte(COM1_PORT+4,0x0b);
//outportb(COM1_PORT+1,0x01); // receive interrupt enable
sysInByte(COM1_PORT);
}
void com_send_string(unsigned char *str)
{
int i;
i="0";
while(str[i] != '/0')
{
com_send_data(str[i]);
i++;
}
}
void com_send_data(unsigned char sdata)
{
while(1)
{
if(com1_send_data_ready()) // send data to com1 ready: 1, else 0
{
com1_send_data(sdata); // send data to com1( 查询方式?)
break;
}
}
}
int com1_send_data_ready(void) // send data to com1 ready: 1, else 0
{
if(((unsigned char )sysInByte(COM1_PORT+5) & 0x20)!= 0)
return 1;
else return 0;
}
void com1_send_data(unsigned char data) // send data to com1( 查询方式?)
{
//printf(" %x ",data);
sysOutByte(COM1_PORT,data);
}
void usrKernelInit (void)
{
char *ROOT_buffersy;//shenyan
classLibInit (); /* initialize class (must be first) */
taskLibInit (); /* initialize task object */
/* configure the kernel queues */
#ifdef INCLUDE_CONSTANT_RDY_Q
qInit (&readyQHead, Q_PRI_BMAP, (int)&readyQBMap, 256); /* fixed ready q */
#else
qInit (&readyQHead, Q_PRI_LIST); /* simple priority ready q */
#endif /* !INCLUDE_CONSTANT_RDY_Q */
//sysOutByte (0x3F8, 6);
qInit (&activeQHead, Q_FIFO); /* FIFO queue for active q */
qInit (&tickQHead, Q_PRI_LIST); /* simple priority semaphore q*/
workQInit (); /* queue for deferred work */
/* start the kernel specifying usrRoot as the root task */
com1_init();
sprintf(ROOT_buffersy,"ROOT_STACK_SIZE=%d/n",ROOT_STACK_SIZE);
com_send_string(ROOT_buffersy);
sprintf(ROOT_buffersy,"ISR_STACK_SIZE=%d/n",ISR_STACK_SIZE);
com_send_string(ROOT_buffersy);
sprintf(ROOT_buffersy,"INT_LOCK_LEVEL=%d/n",INT_LOCK_LEVEL);
com_send_string(ROOT_buffersy);
sprintf(ROOT_buffersy,"MEM_POOL_START=%d/n",MEM_POOL_START);
com_send_string(ROOT_buffersy);
kernelInit ((FUNCPTR) usrRoot, ROOT_STACK_SIZE, MEM_POOL_START,
sysMemTop (), ISR_STACK_SIZE, INT_LOCK_LEVEL);
}