-
Notifications
You must be signed in to change notification settings - Fork 2
/
arm.c
135 lines (93 loc) · 1.92 KB
/
arm.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "gpio.h"
#include "atags.h"
#include "fb.h"
#include "ext.h"
#include "systimer.h"
#include "stdio.h"
#include "keyboard.h"
#include <usbd/usbd.h>
#include <device/hid/keyboard.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
extern fb_t fb;
struct fs_t *fs;
int place = 0;
void ls(const char *s){
list_files();
}
struct command {
char name[12];
void (*command)(char *);
};
struct command *command_s[81];
void getc(char *args){
//char c;
//printf("%c", c);
}
void assign_command(char *name, void (*command)(char *)){
strcpy(command_s[place]->name, name);
command_s[place++]->command = command;
}
struct command *get_command(const char *command_name){
for(int i =0; i < 81; i++){
if(command_s[i] == 0){
break;
}
if(!strcmp(command_s[i]->name, command_name)){
return command_s[i];
}
}
return (struct command*)0;
}
int handle_command(){
return 1;
}
void empty_command(char *comm, int size){
for(int i = 0; i < size; i++){
comm[i] = 0;
}
}
void handle_input(){
char c;
char comm[81];
printf(">>");
do{
KeyboardUpdate();
c = KeyboardGetChar();
} while(c != '\n');
char *token = strtok(comm, " ");
struct command *comman = get_command(token);
comman->command((char *)&comm[(sizeof(token)-1)]);
empty_command(comm, 81);
printf("\n");
}
int main(uint32_t r0, uint32_t r1, uint32_t atags){
ext2_init(&fs);
setPinOn(16);
fb_init();
mp = RPI_PropertyGet(TAG_ALLOCATE_BUFFER);
clear();
int count;
Result res;
UsbInitialise();
do {
UsbCheckForChange();
} while (!(count = KeyboardCount()));
/*res = KeyboardGetAddress(0);
if(res){
struct KeyboardLeds leds = KeyboardGetLedSupport(res);
leds.NumberLock = 1;
leds.CapsLock = 1;
KeyboardSetLeds(res, leds);
}*/
list_files();
while(1){
printf(">>Hello");
handle_input();
}
return 1;
}
void exit(int code){
while(1);
}