Skip to content
Snippets Groups Projects
Commit af8d745e authored by Tom Feng's avatar Tom Feng
Browse files

backup

parent b51a6616
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,9 @@
#define RXFF_MASK 0x40 // Receive buffer full
#define TXFE_MASK 0x80 // Transmit buffer empty
#define UART_INTR_OFFSET 0x1c
#define MIS 0x1
#define RIS 0x2
#define TIS 0x4
#define UART_DMAR_OFFSET 0x28
// Specific to UART1
......
#include <bwio.h>
#include <event-itr.h>
#include <IRQ.h>
......@@ -66,15 +65,17 @@ int doAwaitEvent(KernelStruct* Colonel, int EventID) {
}
void UART1Event(int* Uart1Status, char* bTX, char* bRX ){
int* Uart1Flag = (int *)(UART1_BASE | UART_FLAG_OFFSET);
int flagval = *Uart1Flag;
int* Uart1IDClr = (int *)(UART1_BASE | UART_INTR_OFFSET);
int intID = *Uart1IDClr;
*bTX = (*Uart1Status & (1<<5 | 1<<3));
*bRX = (*Uart1Status & (1<< 4));
// turn off whoever is on
bwprintf(COM2,"UART1E: UART1Ctrl %d\n\r",((*Uart1Status)<<24)>>24);
if(flagval & TXFE_MASK) *Uart1Status &= ~(1<<5);
if(flagval & CTS_MASK) *Uart1Status &= ~(1<<3);
if(flagval & RXFF_MASK) *Uart1Status &= ~(1<<4);
if(intID & TIS) *Uart1Status &= ~(1<<5);
if(intID & MIS) *Uart1Status &= ~(1<<3);
if(intID & RIS) *Uart1Status &= ~(1<<4);
bwprintf(COM2,"UART1E: UART1Ctrl after modify %d\n\r",((*Uart1Status)<<24)>>24);
bwprintf(COM2,"UART1E: UART1IntIDClr %d\n\r",((*(int *)(UART1_BASE | 0x1c))<<28)>>28);
}
void ProcessEvent(KernelStruct* Colonel, int EventID) { //TODOTODO when use this
......@@ -91,20 +92,24 @@ void ProcessEvent(KernelStruct* Colonel, int EventID) { //TODOTODO when use this
// if uart1's cts and tie are disabled, wake uart1 out notifier
if((!(status & (1<<5 | 1<<3))) && bRealTX){
//if(!(status &(1<<5))){
bwprintf(COM2,"PE: push %d to scheduler",NotifTask->TaskID);
bwprintf(COM2,"PE: push %d to scheduler\n\r",NotifTask->TaskID);
NotifTask->TaskState = Ready;
pushToScheduler(Colonel,NotifTask);
}
WET[EventID].AwaitTask = NULL;
return;
}else NotifTask = NULL;
// if uart1's receive is disabled, wake uart1 in notifier
if((!(status & (1<<4))) && bRealRX){
NotifTask = (TD*)(WET[EventID].Data);
WET[EventID].Data = NULL;
}
}else NotifTask = NULL;
}
if(NotifTask!=NULL){
bwprintf(COM2,"PE: IRQ2 %d\n\r",(*(int *)(VIC2_BASE | INT_ENABLE)));
NotifTask->TaskState = Ready;
pushToScheduler(Colonel, NotifTask);
WET[EventID].AwaitTask = NULL;
}
bwprintf(COM2,"PE: IRQ2 %d\n\r",(*(int *)(VIC2_BASE | INT_ENABLE)));
NotifTask->TaskState = Ready;
pushToScheduler(Colonel, NotifTask);
WET[EventID].AwaitTask = NULL;
}
void HandleEvents(KernelStruct* Colonel, int IRQ2,int IRQ1){
......@@ -115,14 +120,9 @@ void HandleEvents(KernelStruct* Colonel, int IRQ2,int IRQ1){
// process all event in IRQ2
while(base > 0){
if(Mask & code2){/*
if(base+32 == UART2_INT){
int Flags = *(int *)(UART2_BASE | UART_FLAG_OFFSET);
int TrxMask = (int )(TXFE_MASK | CTS_MASK);
if(!(Flags & TrxMask)) {
base --;
code2 <<= 1;
continue;
}
if(base+32 == UART2_INT){ int Flags = *(int *)(UART2_BASE |
UART_FLAG_OFFSET); int TrxMask = (int )(TXFE_MASK | CTS_MASK);
if(!(Flags & TrxMask)) { base --; code2 <<= 1; continue; }
}*/
ProcessEvent(Colonel,base+32);
}
......
......@@ -32,19 +32,20 @@ void IdleTask1(){
//bPrinted = 0;
//}else
if(!bPrinted){
bwprintf(COM2,"IDT1: IntIDIntCLr %d\n\r",(*(int *)(UART1_BASE | UART_INTR_OFFSET)<<28) >> 28);
//bwprintf(COM2,"IDT1: IntIDIntCLr %d\n\r",(*(int *)(UART1_BASE | UART_INTR_OFFSET)<<28) >> 28);
bwprintf(COM2,"IDT1: IRQ2 :%d\n\r",(*(int *)(VIC2_BASE | INT_ENABLE)));
bPrinted = 1;
}else{
bPrinted = 0;
bwprintf(COM2,"IDT1: sft interrupt \n\r");
//}else{
//bPrinted = 0;
//bwprintf(COM2,"IDT1: sft interrupt \n\r");
//*(int *)(VIC2_BASE | SFT_INT) = 1<<20;
}
//}
//if(!bPrinted){
//bwprintf(COM1,"IDT1: runs\n\r");
//bPrinted = 1;
//}
//if(i & (1<<4)) break;
//bwprintf(COM2,"IdleTask1: runs\n\r");
}
}
}
......@@ -28,24 +28,43 @@ void InitNameServer() {
void PrintTask(){
char c = 'd';
char str[] = "AAABBBCCC";
str[0] = 1;
str[2] = str[5] = str[8] = 32;
str[1] = str[4] = str[7] = 33;
str[3] = 2;
str[6] = 3;
int len = stringLen(str);
int i = 0;
str[0] = 192;
str[1] = 1;
str[3] = str[6] = str[9] = 32;
str[2] = str[5] = str[8] = 33;
str[4] = 2;
str[7] = 3;
bwprintf(COM2,"PrintTask:\n\r");
char bChange = 0;
//putc(COM1,192);
//putc(COM1,133);
while(1){
//c = getc(COM1);
//bwprintf(COM1,"Print: got %d from COM1\n\r",c);
//bwprintf(COM2,"PrintTask: before print\n\r");
c = getc(COM1);
bwprintf(COM2,"PrintTask: got %d from COM1\n\r",c);
if(bChange){
str[2] = str[5] = str[8] = 33;
bChange = 0;
}else{
bChange = 1;
str[2] = str[5] = str[8] = 34;
}
c = bwgetc(COM2);
putc(COM1,c);
//putc(COM1,c);
//i++;
//putstr(COM1,str,len);
if(c == 'p'){
putstr(COM1,str,len);
}
}else putc(COM1,c);
}
Exit();
}
......@@ -57,7 +76,7 @@ void FirstUserTask() {
InitNameServer();
bwprintf(COM2,"FUT: IRQ2:%d\n\r",(*(int *)(VIC2_BASE | INT_ENABLE)));
bwprintf(COM2,"FUT: IntIDIntClr %d\n\r",((*(int*)(UART1_BASE | 0x1c))<<28)>>28);
/*
// Idle Task
Args.arg0 = (void*) 15;
......
......@@ -21,8 +21,8 @@ void ClockNotifier() {
}
else break;
}
if (Res == INVALID_EVENT) bwprintf(COM1, "Notifier: Invalid Event\n\r");
else if (Res == CORRUPTED_VOLATILE_DATA) bwprintf(COM1, "Notifier: Corrupte Volatile Data\n\r");
if (Res == INVALID_EVENT) bwprintf(COM2, "Notifier: Invalid Event\n\r");
else if (Res == CORRUPTED_VOLATILE_DATA) bwprintf(COM2, "Notifier: Corrupte Volatile Data\n\r");
}
void TermInNotifier(){
......@@ -35,25 +35,25 @@ void TermInNotifier(){
IRQ = (int ) VIC1_BASE;
EnableInterrupt((int)(UART2IN_INT));
FOREVER{
//bwprintf(COM1,"InNot: before await\n\r");
//bwprintf(COM2,"InNot: before await\n\r");
Res = AwaitEvent(UART2IN_INT);
//bwprintf(COM1,"InNot: AwaitResult %d\n\r",Res);
//bwprintf(COM2,"InNot: AwaitResult %d\n\r",Res);
if (Res > -1){
SendReq.Type = NIN;
SendReq.Len = 0;
SendReq.Byte = *(char *)(UART2_BASE);
SendReq.Chan = COM2;
//bwprintf(COM1,"InNot: Send %c to IServer %d\n\r",SendReq.Byte,IServerID);
//bwprintf(COM2,"InNot: Send %c to IServer %d\n\r",SendReq.Byte,IServerID);
Send(IServerID,(void*)&SendReq, sizeof(IOReq), (void *)&ReplyMsg, sizeof(int));
// enable interrupt
EnableIRQ(1<<IRQSource,IRQ);
//bwprintf(COM1,"InNot: Enabled IRQ %d",*(int *)(VIC1_BASE | 0x10));
//bwprintf(COM2,"InNot: Enabled IRQ %d",*(int *)(VIC1_BASE | 0x10));
}
else break;
}
/*
if(Res == INVALID_EVENT) bwprintf(COM1,"InNotifier: Invalid Event\n\r");
if(Res == CORRUPTED_VOLATILE_DATA) bwprintf(COM1,"InNotifier: Corrupte Volatile Data\n\r");
if(Res == INVALID_EVENT) bwprintf(COM2,"InNotifier: Invalid Event\n\r");
if(Res == CORRUPTED_VOLATILE_DATA) bwprintf(COM2,"InNotifier: Corrupte Volatile Data\n\r");
*/
}
......@@ -66,25 +66,25 @@ void TermOutNotifier(){
OServerID = WhoIs("OServer");
IRQSource = (int)(UART2OUT_INT);
IRQ = (int)VIC1_BASE;
//bwprintf(COM1,"OutNot: before enable uart2\n\r");
//bwprintf(COM2,"OutNot: before enable uart2\n\r");
//EnableInterrupt((int)(UART2OUT_INT));
//bwprintf(COM1,"OutNot: after enable uart2\n\r");
//bwprintf(COM2,"OutNot: after enable uart2\n\r");
FOREVER{
//bwprintf(COM1,"OutNot: before await\n\r");
//bwprintf(COM2,"OutNot: before await\n\r");
Res = AwaitEvent(UART2OUT_INT);
//bwprintf(COM1,"OutNot: Await Result %d\n\r",Res);
//bwprintf(COM2,"OutNot: Await Result %d\n\r",Res);
// uart status must be checked before waking up
if(Res > -1){
SendReq.Type = NOUT;
SendReq.Chan = COM2;
Send(OServerID,(void *)&SendReq,sizeof(IOReq),(void *)&ReplyByte, sizeof(char));
//bwprintf(COM1,"OutNot: Got reply %c \n\r",ReplyByte);
//bwprintf(COM2,"OutNot: Got reply %c \n\r",ReplyByte);
*(int *)(UART2_BASE) = ReplyByte;
// clear interrupt
//*(int *)(UART2_BASE | UART_INTR_OFFSET) |=
// enable interrupt
//EnableIRQ(1<<IRQSource,IRQ);
//bwprintf(COM1,"OutNot: Enabled IRQ %d",*(int *)(VIC1_BASE | 0x10));
//bwprintf(COM2,"OutNot: Enabled IRQ %d",*(int *)(VIC1_BASE | 0x10));
}
else break;
}
......
......@@ -5,7 +5,7 @@
int pushToScheduler (KernelStruct* Colonel, TD* Task) {
int returncode= PushToTDPQ(&(Colonel->ArrayPQ)[Task->TaskPriority],Task);
//bwprintf(COM1,"PUSH: pushed %d(prio: %d) to scheuler result%d\n\r",Task->TaskID,Task->TaskPriority,returncode);
bwprintf(COM1,"PUSH: pushed %d(prio: %d) to scheuler result%d\n\r",Task->TaskID,Task->TaskPriority,returncode);
return returncode;
}
......
......@@ -127,7 +127,7 @@ void Handle(KernelStruct* Colonel, int n) {
ClearIRQ(Mask,IRQ2);
bwprintf(COM2,"Handle: event %d, disable irq\n\r",EventID);
}
bwprintf(COM2,"Handle: IRQ2 :%d\n\r",(*(int *)(VIC2_BASE | INT_ENABLE)));
//bwprintf(COM2,"Handle: IRQ2 :%d\n\r",(*(int *)(VIC2_BASE | INT_ENABLE)));
//bwprintf(COM1,"Handle: Disabled IRQ2: %d\n\r",*(int *)(VIC2_BASE | 0x10));
}else{
Mask <<= EventID;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment