Skip to content

Commit cd717cd

Browse files
committed
adding terminal command and make asm work
1 parent dccfbb7 commit cd717cd

24 files changed

+761
-702
lines changed

SanderOSUSB.0

56 Bytes
Binary file not shown.

boot/pxe/pxeentry.bin

56 Bytes
Binary file not shown.

cdrom.iso

0 Bytes
Binary file not shown.

include/symbols.h

+275-274
Large diffs are not rendered by default.

kernel.bin

56 Bytes
Binary file not shown.

kernel/dev/terminal.c

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "../kernel.h"
22

33
#define MAX_COMMAND_SIZE 10
4-
#define MAX_COMMAND_STACK 5
4+
#define MAX_COMMAND_STACK 10
55
#define MAX_COMMAND_COMMAND_SIZE 50
66

77
struct terminal_cmd{
@@ -14,8 +14,19 @@ struct terminal_cmd term_commands[MAX_COMMAND_STACK];
1414
char* read_line(int maxsize){
1515
char* buffer = (char*) malloc(maxsize);
1616
int i = 0;
17+
int* curhi = curget();
1718
for(i = 0 ; i < maxsize ; i++){
18-
buffer[i] = (char)getch();
19+
char deze = (char)getch();
20+
if(deze=='\b'){
21+
buffer[i] = 0;
22+
buffer[i-1] = 0;
23+
i -= 2;
24+
curset(curhi[0]+i+1,curhi[1]);
25+
putc(' ');
26+
curset(curhi[0]+i+1,curhi[1]);
27+
continue;
28+
}
29+
buffer[i] = deze;
1930
putc(buffer[i]);
2031
if(buffer[i]=='\n'){
2132
break;
@@ -84,6 +95,8 @@ void tty_dir(char* argv){
8495
printf("DIR %s : %s \n",cmd,dir(cmd));
8596
}
8697

98+
volatile char* last_tty_command;
99+
87100
void tty_exec(char* argv){
88101
char* cmd;
89102
char* tuv = getcwd();
@@ -99,13 +112,16 @@ void tty_exec(char* argv){
99112
int exparam = 0;
100113
for(int i = 0 ; i < strlen(cmd) ; i++){
101114
if(cmd[i]==' '){
102-
exparam = i+1;
115+
exparam = i;
116+
break;
103117
}
104118
}
105119
if(exparam==0){
106120
exparam = strlen(cmd);
107121
}
108122
cmd[exparam] = 0;
123+
last_tty_command = (char*)cmd+exparam+1;
124+
109125
unsigned char* buffer = (unsigned char*)0x2000;
110126
if(fexists((unsigned char *)cmd) && fread(cmd,buffer)){
111127
if(iself(buffer)){
@@ -179,7 +195,7 @@ int handle_tty_command(char* prompt){
179195
}
180196

181197
void tty_loop(){
182-
setpwd("@");
198+
setpwd("A@PRGS");
183199
while(1){
184200
printf("[%s]-> ",getcwd());
185201
char* prompt = read_line(MAX_COMMAND_COMMAND_SIZE);

kernel/dev/video.c

+7
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,13 @@ int init_graph_vga(unsigned int width, unsigned int height,int chain4)
18411841
return 1;
18421842
}
18431843

1844+
int* curget(){
1845+
int *elf = (int*)malloc(sizeof(int)*2);
1846+
elf[0] = curx;
1847+
elf[1] = cury;
1848+
return elf;
1849+
}
1850+
18441851
void curset(int x,int y){
18451852
curx = x;
18461853
cury = y;

kernel/hal/i386/interrupts.c

+31-8
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,25 @@ typedef struct {
128128

129129
#define MAX_FILE_SYMBOLS 10
130130
FileSymbol filesymboltable[MAX_FILE_SYMBOLS];
131+
extern volatile char* last_tty_command;
131132

132133
void special_handler(Register *r){
133134
outportb(0xA0,0x20);
134135
outportb(0x20,0x20);// printf("OKE: eax=%x \n",r->eax);__asm__ __volatile__("cli\nhlt"); for(;;);
135136
debugf("INT0x80: EIP=%x \n",r->eip);
136137

137138
if(r->eax==0x01){ // EXIT
138-
printf("INT0x80: PROGRAM FINISHED\n");
139-
if(isGraphicsMode()){
140-
if(r->ebx){
141-
r->eip = (unsigned long)exit_program_and_wait_for_keypress;
142-
}else{
143-
r->eip = (unsigned long)browser;
144-
}
139+
printf("INT0x80: PROGRAM FINISHED\n");
140+
debugf("INT0x80: PROGRAM FINISHED\n");
141+
if(isGraphicsMode()){
142+
if(r->ebx){
143+
r->eip = (unsigned long)exit_program_and_wait_for_keypress;
145144
}else{
146-
r->eip = (unsigned long)tty_loop;
145+
r->eip = (unsigned long)browser;
147146
}
147+
}else{
148+
r->eip = (unsigned long)tty_loop;
149+
}
148150
}
149151
else if(r->eax==0x03){ // F-READ
150152
debugf("INT0x80: READ\n");
@@ -423,6 +425,27 @@ void special_handler(Register *r){
423425
create_tcp_session(getOurIpAsLong(),((unsigned long*)addr)[0],port & 0xFFFF,port & 0xFFFF,func);
424426
r->eax = 0;
425427
}
428+
else if(r->eax==0xCB){ // PRGS::ARG
429+
debugf("INT0x80: GETPARAMS\n");
430+
int argcount = 0; // we always start with 1, this is the object itself
431+
unsigned long *args = (unsigned long *)malloc(sizeof(unsigned long)*10);
432+
args[argcount++] = (unsigned long)"example"; // example -m 10 test test
433+
if(strlen((char*)last_tty_command)){
434+
args[argcount++] = (unsigned long) (last_tty_command);
435+
int z = strlen((char*)last_tty_command);
436+
for(int i = 0 ; i < z ; i++){
437+
if(last_tty_command[i]==' '){
438+
last_tty_command[i] = 0;
439+
args[argcount++] = (unsigned long) (last_tty_command+i+1);
440+
}
441+
}
442+
}
443+
for(int i = 0 ; i < argcount ; i++){
444+
debugf("INT0x80: serving on arg %x the value %s \n",i,(char*)args[i]);
445+
}
446+
r->eax = (unsigned long)args; // arguments
447+
r->ebx = argcount; // argumentcount
448+
}
426449
else{
427450
printf("INT0x80: UNKNOWN SYSCALL %x \n",r->eax);
428451
debugf("INT0x80: UNKNOWN SYSCALL %x \n",r->eax);

kernel/kernel.h

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ void drawcharraw(unsigned char c, int offsetX, int offsetY, int fgcolor, int bgc
150150
**/
151151
unsigned char getch();
152152
void curset(int x,int y);
153+
int* curget();
153154
void setForeGroundBackGround(unsigned char fg,unsigned char bg);
154155

155156
char* vsprintf(char* format,va_list arg);

kernel/myos.bin

56 Bytes
Binary file not shown.

lib/libsos.a

88 Bytes
Binary file not shown.

programs/assembler.bin

8 Bytes
Binary file not shown.

programs/basic.bin

0 Bytes
Binary file not shown.

programs/basic/basic

0 Bytes
Binary file not shown.

programs/basic/basic.o

0 Bytes
Binary file not shown.

programs/fasm/source/SoS/fasm

8 Bytes
Binary file not shown.

programs/fasm/source/SoS/startup.asm

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@
99
section '.text' executable
1010
1111
_start:
12-
push _char_c
13-
push 5
12+
; push _char_c
13+
; push 5
14+
; get params
15+
mov eax,0xCB
16+
int 0x80
17+
push eax
18+
push ebx
19+
; call main
1420
call main
21+
; quit
22+
mov eax,0x01
23+
int 0x80
1524
ret
1625

1726
filenamebuffer: db 'A@PRGS/TEGT.ASM', 0

programs/irc.bin

0 Bytes
Binary file not shown.

programs/irc/irc

0 Bytes
Binary file not shown.

programs/irc/irc.o

0 Bytes
Binary file not shown.

programs/sedit.bin

0 Bytes
Binary file not shown.

programs/sedit/sedit

0 Bytes
Binary file not shown.

programs/sedit/sedit.o

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)