Skip to content

Commit 74fabe4

Browse files
committed
* Fixed the Fat filesystem driver
Before the fix it cannot identify partitions and files * Fixed the ata driver The read function was broken * Bumped the kernel version Bumped the kernel version the 2.2.2 * Updated issue template There were many "Markdown violations" in that template
1 parent 84e309e commit 74fabe4

File tree

10 files changed

+151
-298
lines changed

10 files changed

+151
-298
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A clear and concise description of what the bug is.
1212

1313
**To Reproduce**
1414
Steps to reproduce the behavior:
15+
1516
1. Go to '...'
1617
2. Click on '....'
1718
3. Scroll down to '....'
@@ -24,15 +25,17 @@ A clear and concise description of what you expected to happen.
2425
If applicable, add screenshots to help explain your problem.
2526

2627
**Desktop (please complete the following information):**
27-
- Kernel version [e.g. 22]
28-
- cpu [e.g. intel pentium 2]
29-
- ram [e.g. 4GB]
28+
29+
- Kernel version [e.g. 22]
30+
- cpu [e.g. intel pentium 2]
31+
- ram [e.g. 4GB]
3032

3133
**Virtual Machine:**
32-
- Kernel version [e.g. 2.1.4]
33-
- Hypervisor [e.g. virtualbox]
34-
- Hypervisor version [e.g. 6.1]
35-
- Hypervisor ram [e.g. 4GB]
34+
35+
- Kernel version [e.g. 2.1.4]
36+
- Hypervisor [e.g. virtualbox]
37+
- Hypervisor version [e.g. 6.1]
38+
- Hypervisor ram [e.g. 4GB]
3639

3740
**Additional context**
3841
Add any other context about the problem here.

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.vscode/configurationCache.log
33
out/
44
.vscode
5-
serial.log
5+
serial.log
6+
.UNCODE

Drivers/HDD-ATA.cpp

+69-70
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
void printf(char* );
44
void printHex(uint8_t );
55

6-
AdvancedTechnologyAttachment::AdvancedTechnologyAttachment(bool master, uint16_t portBase)
7-
: dataPort(portBase),
8-
errorPort(portBase + 0x1),
9-
sectorCountPort(portBase + 0x2),
10-
lbaLowPort(portBase + 0x3),
11-
lbaMidPort(portBase + 0x4),
12-
lbaHiPort(portBase + 0x5),
13-
devicePort(portBase + 0x6),
14-
commandPort(portBase + 0x7),
15-
controlPort(portBase + 0x206)
6+
AdvancedTechnologyAttachment::AdvancedTechnologyAttachment(uint16_t portBase, bool master)
7+
: dataPort(portBase),
8+
errorPort(portBase + 1),
9+
sectorCountPort(portBase + 2),
10+
lbaLowPort(portBase + 3),
11+
lbaMidPort(portBase + 4),
12+
lbaHiPort(portBase + 5),
13+
devicePort(portBase + 6),
14+
commandPort(portBase + 7),
15+
controlPort(portBase + 0x206)
1616
{
17+
bytesPerSector = 512;
1718
this->master = master;
1819
}
1920

@@ -28,137 +29,135 @@ void AdvancedTechnologyAttachment::Identify()
2829

2930
devicePort.WriteToPort(0xA0);
3031
uint8_t status = commandPort.ReadFromPort();
31-
if(status == 0xFF)
32+
if (status == 0xFF)
3233
return;
3334

34-
3535
devicePort.WriteToPort(master ? 0xA0 : 0xB0);
3636
sectorCountPort.WriteToPort(0);
3737
lbaLowPort.WriteToPort(0);
3838
lbaMidPort.WriteToPort(0);
3939
lbaHiPort.WriteToPort(0);
40-
commandPort.WriteToPort(0xEC); // identify command
41-
40+
commandPort.WriteToPort(0xEC);
4241

4342
status = commandPort.ReadFromPort();
44-
if(status == 0x00)
45-
return;
43+
if (status == 0x00)
44+
return; // no device
4645

47-
while(((status & 0x80) == 0x80)
48-
&& ((status & 0x01) != 0x01))
46+
while (((status & 0x80) == 0x80) && ((status & 0x01) != 0x01))
4947
status = commandPort.ReadFromPort();
5048

51-
if(status & 0x01)
49+
if (status & 0x01)
5250
{
5351
printf("ERROR");
5452
return;
5553
}
5654

57-
for(int i = 0; i < 35; i++)
55+
for (uint16_t i = 0; i < 256; i++)
5856
{
59-
6057
uint16_t data = dataPort.ReadFromPort();
61-
char *text = "\0\0";
62-
text[0] = (data >> 8) & 0xFF;
63-
text[1] = data & 0xFF;
64-
printf(text);
58+
char *foo = " \0";
59+
foo[1] = (data >> 8) & 0x00FF;
60+
foo[0] = data & 0x00FF;
61+
printf(foo);
6562
}
66-
printf("\n");
6763
}
6864

69-
void AdvancedTechnologyAttachment::Read28(uint32_t sectorNum, uint8_t* data, int count)
65+
void AdvancedTechnologyAttachment::Read28(uint32_t sector, uint8_t *data, int count)
7066
{
71-
if(sectorNum > 0x0FFFFFFF)
67+
if (sector & 0xF0000000)
68+
return;
69+
if (count > bytesPerSector)
7270
return;
7371

74-
devicePort.WriteToPort( (master ? 0xE0 : 0xF0) | ((sectorNum & 0x0F000000) >> 24) );
72+
devicePort.WriteToPort((master ? 0xE0 : 0xF0) | ((sector & 0x0F000000) >> 24));
7573
errorPort.WriteToPort(0);
7674
sectorCountPort.WriteToPort(1);
77-
lbaLowPort.WriteToPort( sectorNum & 0x000000FF );
78-
lbaMidPort.WriteToPort( (sectorNum & 0x0000FF00) >> 8);
79-
lbaLowPort.WriteToPort( (sectorNum & 0x00FF0000) >> 16 );
75+
76+
lbaLowPort.WriteToPort(sector & 0x000000FF);
77+
lbaMidPort.WriteToPort((sector & 0x0000FF00) >> 8);
78+
lbaHiPort.WriteToPort((sector & 0x00FF0000) >> 16);
8079
commandPort.WriteToPort(0x20);
8180

8281
uint8_t status = commandPort.ReadFromPort();
83-
while(((status & 0x80) == 0x80)
84-
&& ((status & 0x01) != 0x01))
82+
while (((status & 0x80) == 0x80) && ((status & 0x01) != 0x01))
8583
status = commandPort.ReadFromPort();
8684

87-
if(status & 0x01)
85+
if (status & 0x01)
8886
{
8987
printf("ERROR");
9088
return;
9189
}
9290

91+
printf("Reading from ATA: ");
9392

94-
printf("Reading ATA Drive: ");
95-
96-
for(uint16_t i = 0; i < count; i += 2)
93+
for (uint16_t i = 0; i < count; i += 2)
9794
{
9895
uint16_t wdata = dataPort.ReadFromPort();
9996

97+
/*
98+
char* foo = " \0";
99+
foo[1] = (wdata >> 8) & 0x00FF;
100+
foo[0] = wdata & 0x00FF;
101+
printf(foo);
102+
*/
103+
100104
data[i] = wdata & 0x00FF;
101-
if(i+1 < count)
102-
data[i+1] = (wdata >> 8) & 0x00FF;
103-
}
105+
if (i + 1 < count)
106+
data[i + 1] = (wdata >> 8) & 0x00FF;
107+
}
104108

105-
for(int i = count + (count%2); i < 512; i += 2)
109+
for (uint16_t i = count + (count % 2); i < bytesPerSector; i += 2)
106110
dataPort.ReadFromPort();
107111
}
108112

109-
void AdvancedTechnologyAttachment::Write28(uint32_t sectorNum, uint8_t* data, uint32_t count)
113+
void AdvancedTechnologyAttachment::Write28(uint32_t sector, uint8_t *data, int count)
110114
{
111-
if(sectorNum > 0x0FFFFFFF)
115+
if (sector & 0xF0000000)
112116
return;
113-
if(count > 512)
117+
if (count > bytesPerSector)
114118
return;
115119

116-
117-
devicePort.WriteToPort( (master ? 0xE0 : 0xF0) | ((sectorNum & 0x0F000000) >> 24) );
120+
devicePort.WriteToPort((master ? 0xE0 : 0xF0) | ((sector & 0x0F000000) >> 24));
118121
errorPort.WriteToPort(0);
119122
sectorCountPort.WriteToPort(1);
120-
lbaLowPort.WriteToPort( sectorNum & 0x000000FF );
121-
lbaMidPort.WriteToPort( (sectorNum & 0x0000FF00) >> 8);
122-
lbaLowPort.WriteToPort( (sectorNum & 0x00FF0000) >> 16 );
123-
commandPort.WriteToPort(0x30);
124123

124+
lbaLowPort.WriteToPort(sector & 0x000000FF);
125+
lbaMidPort.WriteToPort((sector & 0x0000FF00) >> 8);
126+
lbaHiPort.WriteToPort((sector & 0x00FF0000) >> 16);
127+
commandPort.WriteToPort(0x30);
125128

126-
printf("Writing to ATA Drive: ");
129+
printf("Writing to ATA: ");
127130

128-
for(int i = 0; i < count; i += 2)
131+
for (uint16_t i = 0; i < count; i += 2)
129132
{
130133
uint16_t wdata = data[i];
131-
if(i+1 < count)
132-
wdata |= ((uint16_t)data[i+1]) << 8;
133-
dataPort.WriteToPort(wdata);
134+
if (i + 1 < count)
135+
wdata |= ((uint16_t)data[i + 1]) << 8;
134136

135-
char *text = " \0";
136-
text[0] = (wdata >> 8) & 0xFF;
137-
text[1] = wdata & 0xFF;
138-
printf(text);
137+
char *foo = " \0";
138+
foo[1] = (wdata >> 8) & 0x00FF;
139+
foo[0] = wdata & 0x00FF;
140+
printf(foo);
141+
142+
dataPort.WriteToPort(wdata);
139143
}
140144

141-
for(int i = count + (count%2); i < 512; i += 2)
145+
for (uint16_t i = count + (count % 2); i < bytesPerSector; i += 2)
142146
dataPort.WriteToPort(0x0000);
143-
144147
}
145148

146149
void AdvancedTechnologyAttachment::Flush()
147150
{
148-
devicePort.WriteToPort( master ? 0xE0 : 0xF0 );
151+
devicePort.WriteToPort(master ? 0xE0 : 0xF0);
149152
commandPort.WriteToPort(0xE7);
150153

151154
uint8_t status = commandPort.ReadFromPort();
152-
if(status == 0x00)
153-
return;
154-
155-
while(((status & 0x80) == 0x80)
156-
&& ((status & 0x01) != 0x01))
155+
while (((status & 0x80) == 0x80) && ((status & 0x01) != 0x01))
157156
status = commandPort.ReadFromPort();
158157

159-
if(status & 0x01)
158+
if (status & 0x01)
160159
{
161160
printf("ERROR");
162161
return;
163162
}
164-
}
163+
}

Drivers/HDD-ATA.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ class AdvancedTechnologyAttachment
1818
port8BIT devicePort;
1919
port8BIT commandPort;
2020
port8BIT controlPort;
21+
22+
uint16_t bytesPerSector;
23+
2124
public:
22-
AdvancedTechnologyAttachment(bool master, uint16_t portBase);
25+
AdvancedTechnologyAttachment(uint16_t portBase, bool master);
2326
~AdvancedTechnologyAttachment();
2427
void Identify();
2528
void Read28(uint32_t sectorNum, uint8_t* data, int count = 512);
26-
void Write28(uint32_t sectorNum, uint8_t* data, uint32_t count);
29+
void Write28(uint32_t sectorNum, uint8_t* data, int count);
2730
void Flush();
2831
};
2932

Drivers/Keyboard.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,6 @@ void KeyboardDriver::CommandInterpreter() // SOSH v1.0.3 [SectorOS SHell]. 11 Co
520520
}
521521
else
522522
{
523-
for (int i = 0x00; i < key_buffer_index; i++)
524-
{
525-
printHex(i);
526-
printf(" : ");
527-
printf(key_buffer[i]);
528-
printf("\n");
529-
}
530523
printf("Unknown Command. Type help in console to get all the commands");
531524
}
532525
if(!isTxtMode){

0 commit comments

Comments
 (0)