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

before switch back to k1

parent 4090909f
No related branches found
No related tags found
No related merge requests found
......@@ -82,3 +82,10 @@
#define UART_HDLCSTS_OFFSET 0x21c
#define VIC1_BASE 0x800B0000
#define VIC2_BASE 0x800C0000
#define IRQ_STATUS 0x0
#define INT_ENABLE 0x10
#define SFT_INT 0x18
#define SFT_INT_CLR 0x1C
#define PRT_OFFSET 0x20
......@@ -34,7 +34,7 @@ bwio.o: bwio.s
$(AS) $(ASFLAGS) -o bwio.o bwio.s
main.elf: main.o
$(LD) $(LDFLAGS) -o $@ main.o -ltimer -lbwio -lgcc
$(LD) $(LDFLAGS) -o $@ main.o -lcs -lbwio -lgcc
bwio.a: bwio.o
$(AR) $(ARFLAGS) $@ bwio.o
......
#include <bwio.h>
#include <context-switch.h>
#include <types.h>
#include <timer.h>
#include <ts7200.h>
int GenSWI(){
bwprintf(COM2,"got into GenSWI\n\r");
return 0;
//asm volatile("swi 2\n\t");
}
int GenHWI(){
int a = *(int *)(VIC1_BASE);
bwprintf(COM2,"before generate hwi, %d\n\r",a);
*(int *)(VIC1_BASE + PRT_OFFSET) = (1<<4);
*(int *)(VIC1_BASE + INT_ENABLE) = (1<<4);
*(int *)(VIC1_BASE + SFT_INT) = (1<<4);
bwprintf(COM2,"after write to sft interrupt slot %d\n\r",a);
asm volatile("swi 0\n\t");
}
void EnableInter(){
int a = *(int *)(VIC1_BASE);
*(int *)(VIC1_BASE + INT_ENABLE) = a;
}
void hwi(){
asm volatile("stmfd sp!, {r0,r1}\n\t"
"mrs r0, spsr\n\t"
"stmfd sp!, {r0,lr}\n\t"
"swi 100\n\t"
"ldmfd sp!, {r0,lr}\n\t"
"msr spsr, r0\n\t"
"ldmfd sp!, {r0,r1}\n\t"
"bl EnableInter\n\t"
"subs pc, lr, #4\n\t");
}
void SetSHWI(){
asm volatile(
"mov r0, #0x38\n\t"
"ldr r1, =hwi\n\t"
"add r1, r1, #0x218000\n\t"
"str r1, [r0]\n\t"
"mov r0, #0x28\n\t"
"ldr r1, =kerent\n\t"
"add r1, r1, #0x218000\n\t"
"str r1, [r0]\n\t"
);
}
int main(){
Clock C;
ClockInit(&C);
SetSHWI();
bwprintf(COM2,"handler set up\n\r");
TD task;
task.TaskID = 0;
task.TaskState = Ready;
task.TaskPriority = Prio0;
task.sp = (int *)(0x1e00000);
task.RetVal = 22;
task.ParentID = 0;
void* func = (void *)&GenHWI;
task.lr = (int *)(func + 0x218000);
task.spsr = 0x600000d0;
int b;
int count = 0;
while(1){
kerxit(&task);
register int a asm("r0");
b = a;
if(b == 0) break;
if(b == 100){
count++;
bwprintf(COM2,"Count: %d\n\r");
if(Count >= 100) break;
}
return 0;
}
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