summaryrefslogtreecommitdiff
path: root/kernel/shell.c
blob: 6a4a0aa117d430c46c214eedccc1704e20341cbe (plain)
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
#include "interrupts.h"
#include "lib/logger/log.h"	// logger facilities
#include "lib/bool/bool.h"
#include "lib/int/stdint.h"

#define FOOLOS_MODULE_NAME "shell"

#define COMMAND_LENGTH 255

static char command[COMMAND_LENGTH];
static int pos=0;

// in timer:
uint16_t timer16;

void shell_init()
{
    pos=0;
    command[0]=0;
    scr_put_string("Command> ");
}

void shell_put(char x)
{
    log(FOOLOS_MODULE_NAME,FOOLOS_LOG_DEBUG,"char:%c",x);

    if(pos<COMMAND_LENGTH-2);

    command[pos]=x;
    pos++;

    command[pos]=0;
    
}

void shell_backspace()
{
    if(pos>0);
    pos--;
    command[pos]=0;

}


// TODO: EXECUTE LATER not inside INTERRUPT !!!
void shell_execute()
{
    //scr_nextline();
    //scr_put_string("  processing command: ");
    //scr_put_string_nl(command);

    if(1==strcmp(command,"TIME",0))
    {
	log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d seconds passed since system start.",timer16);
    }
    else if(1==strcmp(command,"EIGHT",0))
    {
	int_generate88();
    }
    else if(1==strcmp(command,"MEM",0))
    {
	mmap_show_free();	
    }
    else if(1==strcmp(command,"ALLOC",0))
    {
	uint32_t *malloc= pmmngr_alloc_block();
	log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"allocated 4KB block at: %08x.",malloc);
    }
    else if(1==strcmp(command,"READ",0))
    {
	uint8_t *read= flpydsk_read_sector (10);
    }
    else
    {
	log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"command unknown");
    }
    
    pos=0;
    scr_nextline();
    scr_put_string("Command> ");

}