Skip to content

Commit 04fa6b5

Browse files
committed
* Now kernel can execute applications in the
slave drive which has .com extention . A sample file is in the root folder of the repository * Bumped kernel version to V3.2.1
1 parent fedf69a commit 04fa6b5

File tree

8 files changed

+150
-17
lines changed

8 files changed

+150
-17
lines changed

Drivers/Keyboard.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ void CustomShell::clearBuffer()
5555

5656
void CustomShell::OnKeyDown(uint8_t key)
5757
{
58-
printf("lol\n");
5958
}
6059

6160
KeyboardDriver::KeyboardDriver(InterruptManager* manager)

Filesystem/FATFS.cpp

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
void printf(char*);
44
void printfchar(char);
55
void printHex(uint8_t Key);
6+
void Entry();
67

78
char *PATH;
89
char *lst_dir;
910
char *lst_dir2;
11+
bool IsDir;
12+
bool IsProgDir;
1013
int PATHIndex = 0;
1114

15+
void Entry()
16+
{
17+
printf("EXECUTION FAILED");
18+
}
19+
1220
void ReadBiosBlock(AdvancedTechnologyAttachment *hd, uint32_t partitionOffset)
1321
{
1422
BiosParameterBlock32 bpb;
@@ -43,7 +51,20 @@ void ReadBiosBlock(AdvancedTechnologyAttachment *hd, uint32_t partitionOffset)
4351

4452
if ((dirent[i].attributes & 0x10) == 0x10) // directory
4553
{
46-
continue;
54+
IsDir = true;
55+
if(dirent[i].name[0] == 'P' && dirent[i].name[1] == 'R' && dirent[i].name[2] == 'O' && dirent[i].name[3] == 'G' && dirent[i].name[4] == 'S')
56+
{
57+
IsProgDir = true;
58+
printf("\n");
59+
printf("prog dir found\n");
60+
printf("\n");
61+
continue;
62+
}
63+
else
64+
{
65+
IsProgDir = false;
66+
continue;
67+
}
4768
}
4869

4970
uint32_t firstFileCluster = ((uint32_t)dirent[i].firstClusterHi) << 16 | ((uint32_t)dirent[i].firstClusterLow);
@@ -57,13 +78,33 @@ void ReadBiosBlock(AdvancedTechnologyAttachment *hd, uint32_t partitionOffset)
5778
{
5879
uint32_t fileSector = dataStart + bpb.sectorsPerCluster * (nextFileCluster - 2);
5980
int sectorOffset = 0;
60-
6181
for (; SIZE > 0; SIZE -= 512)
6282
{
63-
hd->Read28(fileSector + sectorOffset, buffer, 512);
64-
65-
buffer[SIZE > 512 ? 512 : SIZE] = '\0';
66-
printf((char *)buffer);
83+
if (dirent[i].ext[0] == 'C' && dirent[i].ext[1] == 'O' && dirent[i].ext[2] == 'M')
84+
{
85+
hd->Read28(fileSector + sectorOffset, (uint8_t *)Entry, 512);
86+
printf("executing ");
87+
printf((char *)dirent[i].name);
88+
printf(".");
89+
printf((char *)dirent[i].ext);
90+
printf("\n");
91+
Entry();
92+
}
93+
else if (dirent[i].name[0] == 'I' && dirent[i].name[1] == 'N' && dirent[i].name[2] == 'I' && dirent[i].name[3] == 'T')
94+
{
95+
hd->Read28(fileSector + sectorOffset, INITS, 512);
96+
INITS[SIZE > 512 ? 512 : SIZE] = '\0';
97+
printf("INIT: ");
98+
printf((char*)INITS);
99+
}
100+
else
101+
{
102+
hd->Read28(fileSector + sectorOffset, buffer, 512);
103+
buffer[SIZE > 512 ? 512 : SIZE] = '\0';
104+
printf((char *)dirent[i].name);
105+
printf(" :\n");
106+
printf((char *)buffer);
107+
}
67108

68109
if (++sectorOffset > bpb.sectorsPerCluster)
69110
break;

Filesystem/FATFS.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "../Drivers/HDD-ATA.h"
55
#include "../Include/types.h"
6+
#include "../Memory/MemoryManagement.h"
7+
#include "../Include/Public_VAR.h"
68

79
struct BiosParameterBlock32
810
{

Include/Public_VAR.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
inline char *OS_NAME = "SectorOS";
1717

1818
inline char *KERNEL_NAME = "SectorOS";
19-
inline char *KERNEL_VERSION = "V3.0.1-rc1";
20-
inline char *KERNEL_BUILD = "Build: 2022-02-26";
19+
inline char *KERNEL_VERSION = "V3.2.1";
20+
inline char *KERNEL_BUILD = "Build: 2022-03-13";
2121
inline char *KERNEL_ARCH = "x86";
2222

2323
inline char *SHELL_NAME = "SOSH";
@@ -32,6 +32,7 @@ inline int SPIndex = 0; // Shell Prompt Index
3232
inline bool IsShellDisabled = false; // To disable the shell
3333
inline bool isShift = false; // To know if the shift key is pressed
3434
inline bool GlobalBool1 = false; // Global bool 1
35+
inline uint8_t INITS[513]; // Init file contents
3536
// END Kernel variables
3637

3738
// START Common Functions

Network/tcp.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ TransmissionControlProtocolHandler::~TransmissionControlProtocolHandler()
1212

1313
bool TransmissionControlProtocolHandler::HandleTransmissionControlProtocolMessage(TransmissionControlProtocolSocket *socket, uint8_t *data, uint16_t size)
1414
{
15+
char *foo = " ";
16+
for (int i = 0; i < size; i++)
17+
{
18+
foo[0] = data[i];
19+
printf(foo);
20+
}
21+
22+
if (size > 9 && data[0] == 'G' && data[1] == 'E' && data[2] == 'T' && data[3] == ' ' && data[4] == '/' && data[5] == ' ' && data[6] == 'H' && data[7] == 'T' && data[8] == 'T' && data[9] == 'P')
23+
{
24+
printf("SYSMSG: Sending response\n");
25+
socket->Send((uint8_t *)"HTTP/1.1 200 OK\r\nServer: SectorOS\r\nContent-Type: text/html\r\n\r\n<html><head><title>SectorOS</title></head><body><b>This is a test webpage which is hosted on SectorOS</b> https://github.com/Arun007coder/SectorOS</body></html>\r\n", 224);
26+
socket->Disconnect();
27+
}
1528
return true;
1629
}
1730

@@ -22,12 +35,23 @@ TransmissionControlProtocolSocket::TransmissionControlProtocolSocket(Transmissio
2235
state = CLOSED;
2336
}
2437

38+
void TransmissionControlProtocolHandler::TEST()
39+
{
40+
printf("TEST FAILED\n");
41+
}
42+
43+
void TransmissionControlProtocolHandler::TEST2()
44+
{
45+
printf("TEST2 FAILED\n");
46+
}
47+
2548
TransmissionControlProtocolSocket::~TransmissionControlProtocolSocket()
2649
{
2750
}
2851

2952
bool TransmissionControlProtocolSocket::HandleTransmissionControlProtocolMessage(uint8_t *data, uint16_t size)
3053
{
54+
handler->TEST2();
3155
if (handler != 0)
3256
return handler->HandleTransmissionControlProtocolMessage(this, data, size);
3357
return false;
@@ -168,12 +192,11 @@ bool TransmissionControlProtocolProvider::OnInternetProtocolReceived(uint32_t sr
168192
if (msg->flags == ACK)
169193
break;
170194

171-
// no break, because of piggybacking
172-
173195
default:
174196

175197
if (bigEndian32(msg->sequenceNumber) == socket->acknowledgementNumber)
176198
{
199+
socket->handler->TEST2();
177200
reset = !(socket->HandleTransmissionControlProtocolMessage(internetprotocolPayload + msg->headerSize32 * 4, size - msg->headerSize32 * 4));
178201
if (!reset)
179202
{
@@ -321,5 +344,6 @@ TransmissionControlProtocolSocket *TransmissionControlProtocolProvider::Listen(u
321344
void TransmissionControlProtocolProvider::Bind(TransmissionControlProtocolSocket *socket, TransmissionControlProtocolHandler *handler)
322345
{
323346
socket->handler = handler;
347+
socket->handler->TEST();
324348
printf("BINDED");
325349
}

Network/tcp.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ class TransmissionControlProtocolHandler
7575
public:
7676
TransmissionControlProtocolHandler();
7777
~TransmissionControlProtocolHandler();
78-
virtual bool HandleTransmissionControlProtocolMessage(TransmissionControlProtocolSocket* socket, uint8_t* data, uint16_t size);
78+
virtual void TEST();
79+
virtual void TEST2();
80+
virtual bool HandleTransmissionControlProtocolMessage(TransmissionControlProtocolSocket *socket, uint8_t *data, uint16_t size);
7981
};
8082

8183

@@ -97,7 +99,7 @@ friend class TransmissionControlProtocolProvider;
9799
public:
98100
TransmissionControlProtocolSocket(TransmissionControlProtocolProvider* backend);
99101
~TransmissionControlProtocolSocket();
100-
virtual bool HandleTransmissionControlProtocolMessage(uint8_t* data, uint16_t size);
102+
virtual bool HandleTransmissionControlProtocolMessage(uint8_t *data, uint16_t size);
101103
virtual void Send(uint8_t* data, uint16_t size);
102104
virtual void Disconnect();
103105
};

hello.asm

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[BITS 32]
2+
3+
;; To compile this file. execute the following command: nasm -f bin -o test.com hello.asm
4+
mov eax, 2
5+
mov ebx, 'H'
6+
int 0x80
7+
mov eax, 2
8+
mov ebx, 'E'
9+
int 0x80
10+
mov eax, 2
11+
mov ebx, 'L'
12+
int 0x80
13+
mov eax, 2
14+
mov ebx, 'L'
15+
int 0x80
16+
mov eax, 2
17+
mov ebx, 'O'
18+
int 0x80
19+
mov eax, 2
20+
mov ebx, ' '
21+
int 0x80
22+
mov eax, 2
23+
mov ebx, 'W'
24+
int 0x80
25+
mov eax, 2
26+
mov ebx, 'O'
27+
int 0x80
28+
mov eax, 2
29+
mov ebx, 'R'
30+
int 0x80
31+
mov eax, 2
32+
mov ebx, 'L'
33+
int 0x80
34+
mov eax, 2
35+
mov ebx, 'D'
36+
int 0x80
37+
mov eax, 2
38+
mov ebx, '!'
39+
int 0x80

kernel/kernel.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,16 @@ class PrintfUDPHandler : public UserDatagramProtocolHandler
11631163
class PrintfTCPHandler : public TransmissionControlProtocolHandler
11641164
{
11651165
public:
1166+
void TEST()
1167+
{
1168+
printf("TEST WORKED\n");
1169+
}
1170+
1171+
void TEST2()
1172+
{
1173+
printf("TEST2 WORKED\n");
1174+
}
1175+
11661176
bool HandleTransmissionControlProtocolMessage(TransmissionControlProtocolSocket *socket, uint8_t *data, uint16_t size)
11671177
{
11681178
printf("SYSMSG: GOT TCP MSG\n");
@@ -1175,10 +1185,10 @@ class PrintfTCPHandler : public TransmissionControlProtocolHandler
11751185

11761186
if (size > 9 && data[0] == 'G' && data[1] == 'E' && data[2] == 'T' && data[3] == ' ' && data[4] == '/' && data[5] == ' ' && data[6] == 'H' && data[7] == 'T' && data[8] == 'T' && data[9] == 'P')
11771187
{
1178-
socket->Send((uint8_t *)"HTTP/1.1 200 OK\r\nServer: MyOS\r\nContent-Type: text/html\r\n\r\n<html><head><title>SectorOS</title></head><body><b>This is a test webpage which is hosted on SectorOS</b> https://github.com/Arun007coder/SectorOS</body></html>\r\n", 184);
1188+
printf("SYSMSG: Sending response\n");
1189+
socket->Send((uint8_t *)"HTTP/1.1 200 OK\r\nServer: SectorOS\r\nContent-Type: text/html\r\n\r\n<html><head><title>SectorOS</title></head><body><b>This is a test webpage which is hosted on SectorOS</b> https://github.com/Arun007coder/SectorOS</body></html>\r\n", 224);
11791190
socket->Disconnect();
11801191
}
1181-
11821192
return true;
11831193
}
11841194
};
@@ -1196,18 +1206,22 @@ void StartWEBServer(uint16_t port)
11961206

11971207
printf("Starting webserver\n");
11981208
PrintfTCPHandler tcphandler;
1199-
tcp.Bind(tcpsocket, &tcphandler);
12001209
printf("WebServer started\n");
12011210
printf("Listening on port ");
12021211
printf(INTTOCHARPOINT(port));
12031212
printf("\n");
1213+
tcp.Bind(tcpsocket, &tcphandler);
1214+
while (1)
1215+
;
1216+
/*
12041217
ifkeypress ifkeypress;
12051218
KeyboardDriver *keyboard = (KeyboardDriver*)DriverManager::ActiveDriverManager->GetDriver(UDID_KEYBOARD); //(KeyboardDriver *)DriverManager::ActiveDriverManager->GetDriver(UDID_KEYBOARD);
12061219
keyboard->ChangeEventHandler(&ifkeypress);
12071220
printf("Press ESC to exit\n");
12081221
while (!GlobalBool1)
12091222
;
12101223
printf("WebServer Stopped\n");
1224+
*/
12111225
}
12121226
}
12131227

@@ -1351,7 +1365,6 @@ extern "C" void kernelMain(const void *multiboot_structure, uint32_t multiboot_m
13511365
printf("\n");
13521366

13531367
arp.BroadcastMACAddress(gip_be);
1354-
icmp.RequestEchoReply(gip_be);
13551368
}
13561369

13571370
sp.logToSerialPort("\nHardware initialising stage 3 finished");
@@ -1367,13 +1380,25 @@ extern "C" void kernelMain(const void *multiboot_structure, uint32_t multiboot_m
13671380
PrintDate();
13681381
printf(" Type: Shell\nhttps://github.com/Arun007coder/SectorOS \n");
13691382

1383+
/*
13701384
printf("Initializing ");
13711385
printf(SHELL_NAME);
13721386
printf(" ");
13731387
printf(SHELL_VER);
13741388
printf("\n\n");
1389+
*/
13751390

13761391
printf("Welcome to SectorOS Shell\nRun help to get the list of commands which is implemented \n \n");
1392+
printf(" @@@@@@@@@@@@@@\n");
1393+
printf("@ \n");
1394+
printf("@ \n");
1395+
printf("@ \n");
1396+
printf(" @@@@@@@@@@@@@ \n");
1397+
printf(" @\n");
1398+
printf(" @\n");
1399+
printf(" @\n");
1400+
printf("@@@@@@@@@@@@@@ \n");
1401+
13771402
sp.logToSerialPort("\nKernel initialization surcessful.\nGiving execution access to the kernel.\nAwaiting user input...");
13781403

13791404
SPIndex = set.UserNameLength + set.HostnameLength + 5 + 11;

0 commit comments

Comments
 (0)