Import backup from 2004-01-07

This commit is contained in:
Josh Holtrop 2004-01-07 22:00:00 -05:00
parent af6087ecec
commit 0a546f1467
10 changed files with 1196 additions and 29 deletions

31
fat12.c
View File

@ -5,33 +5,43 @@
byte *fat12_readFile(char *fileName, DiskDevice *dd)
{
Fat12File *fp = fat12_getFileHandle(fileName, dd);
if (!fp)
return 0;
}
Fat12File *fat12_getFileHandle(char *fileName)
Fat12File *fat12_getFileHandle(char *fileName, DiskDevice *dd)
{
if (strlen(fileName) < 1)
return 0;
if (fileName[strlen(fileName)-1] == '/')
return 0;
}
//The trailing slash ('/') character should not be included in the directory string
Fat12Directory *fat12_getDirectoryHandle(char *directory, DiskDevice *dd)
{
dword numDirectories = 0;
int a = 0;
for (;;) //first count how many directories deep we are looking
{
if (fileName[a] == '/')
if (directory[a] == '/')
numDirectories++;
a++;
if (!fileName[a])
if (!directory[a])
break;
}
for (a = 0; ;a++) //next split apart the filename string into parts for each directory and file
{
if (fileName[a] == 0)
if (directory[a] == 0)
break;
if (fileName[a] == '/')
fileName[a] = 0;
if (directory[a] == '/')
directory[a] = 0;
}
char **levels = (char**)malloc((numDirectories+1)*sizeof(char *));
char *dir = fileName;
char *dir = directory;
for (a = 0; a <= numDirectories; a++)
{
levels[a] = dir;
@ -42,16 +52,15 @@ Fat12File *fat12_getFileHandle(char *fileName)
break;
}
dir++;
}
for (a = 0; a <= numDirectories; a++)
{
printf("directory: %s|\n", levels[a]);
}
//at this point we have an array of "strings" (character pointers) called levels
// its length is numDirectories+1, levels[numDirectores] points to the actual file name
free(levels);
}

41
fat12.h
View File

@ -11,9 +11,46 @@ typedef struct {
dword location;
} __attribute__((packed)) Fat12Directory;
typedef struct {
char fileName[8];
char ext[3];
byte attributes;
dword createTime;
word createDate;
word accessDate;
word unused0;
word modifiedDate;
word modifiedTime;
word firstCluster;
dword fileSize;
} __attribute__((packed)) Fat12DirectoryEntry;
typedef struct {
byte jump[3];
byte sysName[8];
word bytesPerSector;
byte sectorsPerCluster;
word reservedSectors;
byte FATcount;
word maxRootEntries;
word totalSectors1;
byte mediaDescriptor;
word sectorsPerFAT;
word sectorsPerTrack;
word headCount;
dword hiddenSectors;
dword totalSectors2;
byte driveNumber;
byte reserved1;
byte extBootSignature;
dword volumeSerial;
char volumeLabel[11];
char fileSystemID[8];
} __attribute__((packed)) Fat12BootSector;
byte *fat12_readFile(char *fileName, DiskDevice *dd);
Fat12File *fat12_getFileHandle(char *fileName);
Fat12Directory *fat12_getDirectoryHandle(char *directory);
Fat12File *fat12_getFileHandle(char *fileName, DiskDevice *dd);
Fat12Directory *fat12_getDirectoryHandle(char *directory, DiskDevice *dd);

BIN
kernel.bin Normal file

Binary file not shown.

View File

@ -36,7 +36,7 @@ extern int puts(char *str);
extern int putDec(int number);
extern int putDecu(dword number);
extern void strcpy(char *dest, char *src);
extern void memcpy(dword dest, dword src, dword n);
extern void memcpy(void *dest, void *src, dword n);
extern dword strlen(char *str);
#include "fat12.c"

182
lst/LDout.doc Normal file
View File

@ -0,0 +1,182 @@
Allocating common symbols
Common symbol size file
_mouse_y 0x10 kernel.o
_video_mode 0x100 kernel.o
_mm_megabytes 0x10 kernel.o
_console_memory 0xfa0 kernel.o
_page_bitmap 0x20000 kernel.o
_kbdBuffer 0x100 kernel.o
_video_psetp 0x10 kernel.o
_mouse_x 0x10 kernel.o
_mouse_inbuffer 0x10 kernel.o
Memory Configuration
Name Origin Length Attributes
*default* 0x00000000 0xffffffff
Linker script and memory map
.text 0xc0106000 0x4000
0xc0106000 code = .
0xc0106000 _code = .
0xc0106000 __code = .
*(.text)
.text 0xc0106000 0x358 ks.o
0xc0106000 start
*fill* 0xc0106358 0x8 00
.text 0xc0106360 0x2fa0 kernel.o
0xc0107c26 _kbdGetKey
0xc0108eb9 _video_psetp32
0xc0108602 _vmm_addHeapEntryBlock
0xc0108ed9 _video_drawConsole
0xc010898c _pic1_mask
0xc01087a9 _free
0xc0108b52 _video_renderChar
0xc010887b _strcat
0xc0107f06 _mm_palloc
0xc0107ebc _mm_pfree
0xc0108d86 _video_rectf
0xc0107208 _putc
0xc0107e7f _mm_pfreen
0xc0107352 _putHex
0xc01082d8 _vmm_unmapn
0xc0108f90 _video_drawConsoleChar
0xc0108ab0 _kernel_size
0xc0108297 _vmm_unmap1
0xc01073ec _mouse_init
0xc01086f3 _vmm_getFirstHoleHeapEntry
0xc01073c5 _fdc_sendDOR
0xc01085e6 _vmm_nextHeapEntry
0xc0108189 _vmm_map1
0xc01090d7 _k_init
0xc0106eb8 _vfs_getDiskDeviceByID
0xc01075e0 _SCAN2ASCII
0xc0108a70 _eoi
0xc0106bd4 _fat12_getDirectoryHandle
0xc0107cba _kbd_resetLEDs
0xc0108425 _vmm_coalesceHeapEntry
0xc01084ef _vmm_moreCore
0xc0106dac _vfs_readFile
0xc01089b0 _pic2_mask
0xc0108abf _video_init
0xc010886f _enable_ints
0xc010800e _vmm_init
0xc01089d7 _restart
0xc0107cdb _mm_init
0xc0106cd5 _vfs_init
0xc0108e25 _video_psetp16
0xc01076f3 _isr_keyboard
0xc0108bd2 _video_horiz
0xc0107faa _mm_freemem
0xc010882e _outportb
0xc0108e6b _video_psetp24
0xc0108ed4 _video_psetpnull
0xc010749a _isr_mouse
0xc0108a87 _eoi2
0xc0106b8e _fat12_getFileHandle
0xc0108843 _outportw
0xc0108d2e _video_rect
0xc0108305 _malloc
0xc0109281 _isr
0xc0106ca2 _rd_readSector
0xc0107660 _SCAN2ASCIISHIFT
0xc0106e81 _vfs_readSector
0xc0106360 _stdfont
0xc0108c78 _video_vert
0xc0108772 _vmm_heapEntriesLeft
0xc01088a0 _remap_pics
0xc01086c4 _vmm_getLastHeapEntry
0xc0107c77 _kbdWaitKey
0xc01087f3 _vmm_getHeapEntryByBase
0xc010810e _vmm_heb_init
0xc0108378 _vmm_getFreeChunk
0xc0106f02 _printf
0xc0108a38 _init_timer
0xc0108850 _inportb
0xc0108a31 _halt
0xc0106b60 _fat12_readFile
0xc0108875 _disable_ints
0xc0108dce _video_pset
0xc0108738 _vmm_getFirstUnusedHeapEntry
0xc010825e _vmm_mapn
.text 0xc0109300 0x32c asmfuncs.o
0xc0109387 _invlpg
0xc010931a _read_cr3
0xc010931e _strcmp
0xc0109453 _puts
0xc0109472 _putDecu
0xc0109359 _memcpy
0xc010938f _writeCursorPosition
0xc01093d2 _console_scroll
0xc0109414 _console_cls
0xc010953a _putDec
0xc0109344 _strcpy
0xc010936f _strlen
0xc01093b5 _getCursorPosition
0xc0109300 _write_cr0
0xc010930f _write_cr3
0xc010930b _read_cr0
0xc010a000 . = ALIGN (0x1000)
*fill* 0xc010962c 0x9d4 00
.data 0xc010a000 0x1000
0xc010a000 data = .
0xc010a000 _data = .
0xc010a000 __data = .
*(.data)
.data 0xc010a000 0x10 kernel.o
0xc010a000 _vid_ptr16
0xc010a00c _firstHeapEntry
0xc010a008 _vid_ptr32
0xc010a004 _vid_ptr24
0xc010b000 . = ALIGN (0x1000)
*fill* 0xc010a010 0xff0 00
.bss 0xc010b000 0x221f0
0xc010b000 bss = .
0xc010b000 _bss = .
0xc010b000 __bss = .
*(.bss)
.bss 0xc010b000 0x2c kernel.o
0xc010b010 _firstDiskDevice
0xc010b00c _rootDevice
0xc010b020 _kbdExt
0xc010b004 _mouse_bytesRead
0xc010b015 _kbdAscii
0xc010b000 _videoMode
0xc010b021 _kbdExt2
0xc010b022 _ackReason
0xc010b024 _mm_totalmem
0xc010b018 _kbdBufferStart
0xc010b016 _kbdScan
0xc010b01c _kbdBufferLen
0xc010b014 _kbdFlags
0xc010b028 _timer
0xc010b008 _cursorPosition
0xc010c000 . = ALIGN (0x1000)
*fill* 0xc010b02c 0xfd4 00
COMMON 0xc010c000 0x211f0 kernel.o
0x0 (size before relaxing)
0xc010c000 _mouse_y
0xc010c010 _video_mode
0xc010c110 _mm_megabytes
0xc010c120 _console_memory
0xc010d0c0 _page_bitmap
0xc012d0c0 _kbdBuffer
0xc012d1c0 _video_psetp
0xc012d1d0 _mouse_x
0xc012d1e0 _mouse_inbuffer
0xc012d1f0 end = .
0xc012d1f0 _end = .
0xc012d1f0 __end = .
LOAD ks.o
LOAD kernel.o
LOAD asmfuncs.o
OUTPUT(kernel.bin binary)
.comment 0xc012d1f0 0x14
.comment 0xc012d1f0 0x14 kernel.o

460
lst/asmfuncs.lst Normal file
View File

@ -0,0 +1,460 @@
1 ; asmfuncs.asm
2 ; Josh Holtrop
3 ; Created: 10/23/03
4 ; Modified: 12/25/03
5
6 [extern _putc]
7 [extern _console_memory]
8 [extern _cursorPosition]
9 [extern _video_drawConsole]
10 [extern _videoMode]
11
12 %macro jzfar 1
13 jnz %%skip
14 jmp %1
15 %%skip:
16
17 %endmacro
18
19 ;stores the parameter to the CR0 register
20 ;extern dword write_cr0(dword cr0);
21 [global _write_cr0]
22 _write_cr0:
23 00000000 55 push ebp
24 00000001 89E5 mov ebp, esp
25 00000003 8B4508 mov eax, [ebp+8]
26 00000006 0F22C0 mov cr0, eax
27 00000009 5D pop ebp
28 0000000A C3 ret
29
30 ;returns the value in the CR0 register
31 ;extern dword read_cr0();
32 [global _read_cr0]
33 _read_cr0:
34 0000000B 0F20C0 mov eax, cr0;
35 0000000E C3 ret
36
37 ;stores the parameter to the CR3 register
38 ;extern dword write_cr3(dword cr3);
39 [global _write_cr3]
40 _write_cr3:
41 0000000F 55 push ebp
42 00000010 89E5 mov ebp, esp
43 00000012 8B4508 mov eax, [ebp+8]
44 00000015 0F22D8 mov cr3, eax
45 00000018 5D pop ebp
46 00000019 C3 ret
47
48 ;returns the value in the CR3 register
49 ;extern dword read_cr3();
50 [global _read_cr3]
51 _read_cr3:
52 0000001A 0F20D8 mov eax, cr3;
53 0000001D C3 ret
54
55 ;compares one string to another
56 ;returns 0 if the strings are different
57 ;extern dword strcmp(char *str1, char *str2);
58 [global _strcmp]
59 _strcmp:
60 0000001E 55 push ebp
61 0000001F 89E5 mov ebp, esp
62 00000021 56 push esi
63 00000022 57 push edi
64
65 00000023 8B7508 mov esi, [ebp+8]
66 00000026 8B7D0C mov edi, [ebp+12]
67 strcmp_loop1:
68 00000029 AC lodsb
69 0000002A 8A27 mov ah, [edi]
70 0000002C 47 inc edi
71 0000002D 38C4 cmp ah, al
72 0000002F 750D jnz strcmp_ne
73 00000031 08C0 or al, al
74 00000033 7402 jz strcmp_e
75 00000035 EBF2 jmp strcmp_loop1
76 strcmp_e:
77 00000037 B801000000 mov eax, 1
78 0000003C EB02 jmp short strcmp_done
79 strcmp_ne:
80 0000003E 31C0 xor eax, eax
81 strcmp_done:
82
83 00000040 5F pop edi
84 00000041 5E pop esi
85 00000042 5D pop ebp
86 00000043 C3 ret
87
88 ;copies a string from the source to the destination parameter
89 ;extern void strcpy(char *dest, char *src);
90 [global _strcpy]
91 _strcpy:
92 00000044 55 push ebp
93 00000045 89E5 mov ebp, esp
94 00000047 56 push esi
95 00000048 57 push edi
96 00000049 8B7D08 mov edi, [ebp+8]
97 0000004C 8B750C mov esi, [ebp+12]
98 strcpyloop:
99 0000004F AC lodsb
100 00000050 AA stosb
101 00000051 08C0 or al, al
102 00000053 75FA jnz strcpyloop
103 00000055 5F pop edi
104 00000056 5E pop esi
105 00000057 5D pop ebp
106 00000058 C3 ret
107
108 ;copies memory of n bytes from src to destination
109 ;extern void memcpy(dword dest, dword src, dword n);
110 [global _memcpy]
111 _memcpy:
112 00000059 55 push ebp
113 0000005A 89E5 mov ebp, esp
114 0000005C 56 push esi
115 0000005D 57 push edi
116 0000005E 51 push ecx
117 0000005F 8B7D08 mov edi, [ebp+8]
118 00000062 8B750C mov esi, [ebp+12]
119 00000065 8B4D10 mov ecx, [ebp+16]
120
121 00000068 F3A4 rep movsb
122
123 0000006A 59 pop ecx
124 0000006B 5F pop edi
125 0000006C 5E pop esi
126 0000006D 5D pop ebp
127 0000006E C3 ret
128
129 ;returns the number of characters in a string
130 ;extern dword strlen(char *str);
131 [global _strlen]
132 _strlen:
133 0000006F 55 push ebp
134 00000070 89E5 mov ebp, esp
135 00000072 56 push esi
136 00000073 53 push ebx
137 00000074 8B7508 mov esi, [ebp+8]
138 00000077 31DB xor ebx, ebx
139 strlenloop:
140 00000079 AC lodsb
141 0000007A 08C0 or al, al
142 0000007C 7403 jz strlendone
143 0000007E 43 inc ebx
144 0000007F EBF8 jmp strlenloop
145 strlendone:
146 00000081 89D8 mov eax, ebx
147 00000083 5B pop ebx
148 00000084 5E pop esi
149 00000085 5D pop ebp
150 00000086 C3 ret
151
152 ;this function invalidates the page directory/table entry that
153 ; would be used to access the memory address given in the parameter
154 ;extern void invlpg(dword addr);
155 [global _invlpg]
156 _invlpg:
157 00000087 8B442404 mov eax, [esp+4]
158 0000008B 0F0138 invlpg [eax]
159 0000008E C3 ret
160
161
162 ;
163 ;void writeCursorPosition(word pos)
164 ;
165 [global _writeCursorPosition]
166 _writeCursorPosition:
167 0000008F 55 push ebp
168 00000090 89E5 mov ebp, esp
169
170 00000092 50 push eax
171 00000093 53 push ebx
172 00000094 52 push edx
173
174 00000095 8B4508 mov eax, [ebp+8] ;cursor position in ax
175
176 00000098 88C3 mov bl, al
177 0000009A 66BAD403 mov dx, 0x03D4
178 0000009E B00E mov al, 0x0E
179 000000A0 EE out dx, al
180
181 000000A1 6642 inc dx
182 000000A3 88E0 mov al, ah
183 000000A5 EE out dx, al
184
185 000000A6 664A dec dx
186 000000A8 B00F mov al, 0x0F
187 000000AA EE out dx, al
188
189 000000AB 6642 inc dx
190 000000AD 88D8 mov al, bl
191 000000AF EE out dx, al
192
193 000000B0 5A pop edx
194 000000B1 5B pop ebx
195 000000B2 58 pop eax
196 000000B3 5D pop ebp
197
198 000000B4 C3 ret
199
200
201 ;
202 ;word getCursorPosition()
203 ;
204 [global _getCursorPosition]
205 _getCursorPosition:
206 000000B5 53 push ebx
207 000000B6 52 push edx
208
209 000000B7 31C0 xor eax, eax
210 000000B9 66BAD403 mov dx, 0x03D4
211 000000BD B00E mov al, 0x0E
212 000000BF EE out dx, al
213
214 000000C0 6642 inc dx
215 000000C2 EC in al, dx
216 000000C3 88C3 mov bl, al
217
218 000000C5 664A dec dx
219 000000C7 B00F mov al, 0x0F
220 000000C9 EE out dx, al
221
222 000000CA 6642 inc dx
223 000000CC EC in al, dx
224 000000CD 88DC mov ah, bl
225
226 000000CF 5A pop edx
227 000000D0 5B pop ebx
228
229 000000D1 C3 ret
230
231
232 ;
233 ;void console_scroll()
234 ;
235 [global _console_scroll]
236 _console_scroll:
237 000000D2 60 pusha
238 000000D3 BE[A0000000] mov esi, _console_memory+160
239 000000D8 BF[00000000] mov edi, _console_memory
240 000000DD B9C0030000 mov ecx, 960 ;(2000-80)/2
241 000000E2 F3A5 rep movsd
242 000000E4 66B82007 mov ax, 0x0720
243 000000E8 B950000000 mov ecx, 80
244 000000ED F366AB rep stosw
245 000000F0 BE[00000000] mov esi, _console_memory
246 000000F5 BF00800BC0 mov edi, 0xC00B8000
247 000000FA B9E8030000 mov ecx, 1000
248 000000FF F3A5 rep movsd
249 00000101 A1[00000000] mov eax, [_videoMode]
250 00000106 3D00000000 cmp eax, 0
251 0000010B 7405 jz _console_scroll_end
252 0000010D E8(00000000) call _video_drawConsole
253 _console_scroll_end:
254 00000112 61 popa
255 00000113 C3 ret
256
257
258
259 ;
260 ;void console_cls()
261 ;
262 [global _console_cls]
263 _console_cls:
264 00000114 60 pusha
265 00000115 BF[00000000] mov edi, _console_memory
266 0000011A 66B82007 mov ax, 0x0720
267 0000011E B9D0070000 mov ecx, 2000
268 00000123 F366AB rep stosw
269 00000126 6800000000 push dword 0
270 0000012B E85FFFFFFF call _writeCursorPosition
271 00000130 81C404000000 add esp, 4
272 00000136 C705[00000000]0000- mov [_cursorPosition], dword 0
273 0000013E 0000
274 00000140 BE[00000000] mov esi, _console_memory
275 00000145 BF00800BC0 mov edi, 0xC00B8000
276 0000014A B9E8030000 mov ecx, 1000
277 0000014F F3A5 rep movsd
278 00000151 61 popa
279 00000152 C3 ret
280
281
282
283
284 ;
285 ;int puts(char *str)
286 ;
287 [global _puts]
288 _puts:
289 00000153 55 push ebp
290 00000154 89E5 mov ebp, esp
291 00000156 56 push esi
292 00000157 50 push eax
293 00000158 8B7508 mov esi, [ebp+8] ;esi = to string
294 puts_loop:
295 0000015B AC lodsb
296 0000015C 3C00 cmp al, 0
297 0000015E 740E jz puts_done
298 00000160 50 push eax
299 00000161 E8(00000000) call _putc
300 00000166 81C404000000 add esp, 4
301 0000016C EBED jmp puts_loop
302
303 puts_done:
304 0000016E 58 pop eax
305 0000016F 5E pop esi
306 00000170 5D pop ebp
307 00000171 C3 ret
308
309
310
311
312 [global _putDecu]
313 _putDecu:
314 00000172 55 push ebp
315 00000173 89E5 mov ebp, esp
316 00000175 81EC18000000 sub esp, 24
317 0000017B C745FC01000000 mov DWORD [ebp-4], 1
318 00000182 C645FB00 mov BYTE [ebp-5], 0
319 L2:
320 00000186 8B5508 mov edx, DWORD [ebp+8]
321 00000189 B8CDCCCCCC mov eax, -858993459
322 0000018E F7E2 mul edx
323 00000190 89D0 mov eax, edx
324 00000192 C1E803 shr eax, 3
325 00000195 3B45FC cmp eax, DWORD [ebp-4]
326 00000198 7305 jae L4
327 0000019A E912000000 jmp L3
328 L4:
329 0000019F 8B45FC mov eax, DWORD [ebp-4]
330 000001A2 89C2 mov edx, eax
331 000001A4 C1E202 sal edx, 2
332 000001A7 01C2 add edx, eax
333 000001A9 8D0412 lea eax, [edx+edx]
334 000001AC 8945FC mov DWORD [ebp-4], eax
335 000001AF EBD5 jmp L2
336 L3:
337 000001B1 90 nop
338 L5:
339 000001B2 817DFC01000000 cmp DWORD [ebp-4], 1
340 000001B9 7705 ja L7
341 000001BB E959000000 jmp L6
342 L7:
343 000001C0 8B5508 mov edx, DWORD [ebp+8]
344 000001C3 89D0 mov eax, edx
345 000001C5 BA00000000 mov edx, 0
346 000001CA F775FC div DWORD [ebp-4]
347 000001CD 8945F4 mov DWORD [ebp-12], eax
348 000001D0 8A45F4 mov al, BYTE [ebp-12]
349 000001D3 8845FB mov BYTE [ebp-5], al
350 000001D6 B800000000 mov eax, 0
351 000001DB 8A45FB mov al, BYTE [ebp-5]
352 000001DE 0FAF45FC imul eax, DWORD [ebp-4]
353 000001E2 294508 sub DWORD [ebp+8], eax
354 000001E5 8B55FC mov edx, DWORD [ebp-4]
355 000001E8 B8CDCCCCCC mov eax, -858993459
356 000001ED F7E2 mul edx
357 000001EF 89D0 mov eax, edx
358 000001F1 C1E803 shr eax, 3
359 000001F4 8945FC mov DWORD [ebp-4], eax
360 000001F7 8D45FB lea eax, [ebp-5]
361 000001FA 800030 add BYTE [eax], 48
362 000001FD 81EC0C000000 sub esp, 12
363 00000203 B800000000 mov eax, 0
364 00000208 8A45FB mov al, BYTE [ebp-5]
365 0000020B 50 push eax
366 0000020C E8(00000000) call _putc
367 00000211 81C410000000 add esp, 16
368 00000217 EB99 jmp L5
369 L6:
370 00000219 81EC0C000000 sub esp, 12
371 0000021F 8A4508 mov al, BYTE [ebp+8]
372 00000222 0530000000 add eax, 48
373 00000227 25FF000000 and eax, 255
374 0000022C 50 push eax
375 0000022D E8(00000000) call _putc
376 00000232 81C410000000 add esp, 16
377 00000238 C9 leave
378 00000239 C3 ret
379
380
381
382
383 [global _putDec]
384 _putDec:
385 0000023A 55 push ebp
386 0000023B 89E5 mov ebp, esp
387 0000023D 81EC18000000 sub esp, 24
388 00000243 817D0800000000 cmp DWORD [ebp+8], 0
389 0000024A 7919 jns L9
390 0000024C 81EC0C000000 sub esp, 12
391 00000252 682D000000 push 45
392 00000257 E8(00000000) call _putc
393 0000025C 81C410000000 add esp, 16
394 00000262 F75D08 neg DWORD [ebp+8]
395 L9:
396 00000265 C745FC01000000 mov DWORD [ebp-4], 1
397 0000026C C645FB00 mov BYTE [ebp-5], 0
398 L10:
399 00000270 8B4508 mov eax, DWORD [ebp+8]
400 00000273 3B45FC cmp eax, DWORD [ebp-4]
401 00000276 7305 jae L12
402 00000278 E912000000 jmp L11
403 L12:
404 0000027D 8B45FC mov eax, DWORD [ebp-4]
405 00000280 89C2 mov edx, eax
406 00000282 C1E202 sal edx, 2
407 00000285 01C2 add edx, eax
408 00000287 8D0412 lea eax, [edx+edx]
409 0000028A 8945FC mov DWORD [ebp-4], eax
410 0000028D EBE1 jmp L10
411 L11:
412 0000028F 8B55FC mov edx, DWORD [ebp-4]
413 00000292 B8CDCCCCCC mov eax, -858993459
414 00000297 F7E2 mul edx
415 00000299 89D0 mov eax, edx
416 0000029B C1E803 shr eax, 3
417 0000029E 8945FC mov DWORD [ebp-4], eax
418 L13:
419 000002A1 817DFC01000000 cmp DWORD [ebp-4], 1
420 000002A8 7705 ja L15
421 000002AA E959000000 jmp L14
422 L15:
423 000002AF 8B5508 mov edx, DWORD [ebp+8]
424 000002B2 89D0 mov eax, edx
425 000002B4 BA00000000 mov edx, 0
426 000002B9 F775FC div DWORD [ebp-4]
427 000002BC 8945F4 mov DWORD [ebp-12], eax
428 000002BF 8A45F4 mov al, BYTE [ebp-12]
429 000002C2 8845FB mov BYTE [ebp-5], al
430 000002C5 B800000000 mov eax, 0
431 000002CA 8A45FB mov al, BYTE [ebp-5]
432 000002CD 0FAF45FC imul eax, DWORD [ebp-4]
433 000002D1 294508 sub DWORD [ebp+8], eax
434 000002D4 8B55FC mov edx, DWORD [ebp-4]
435 000002D7 B8CDCCCCCC mov eax, -858993459
436 000002DC F7E2 mul edx
437 000002DE 89D0 mov eax, edx
438 000002E0 C1E803 shr eax, 3
439 000002E3 8945FC mov DWORD [ebp-4], eax
440 000002E6 8D45FB lea eax, [ebp-5]
441 000002E9 800030 add BYTE [eax], 48
442 000002EC 81EC0C000000 sub esp, 12
443 000002F2 B800000000 mov eax, 0
444 000002F7 8A45FB mov al, BYTE [ebp-5]
445 000002FA 50 push eax
446 000002FB E8(00000000) call _putc
447 00000300 81C410000000 add esp, 16
448 00000306 EB99 jmp L13
449 L14:
450 00000308 81EC0C000000 sub esp, 12
451 0000030E 8A4508 mov al, BYTE [ebp+8]
452 00000311 0530000000 add eax, 48
453 00000316 25FF000000 and eax, 255
454 0000031B 50 push eax
455 0000031C E8(00000000) call _putc
456 00000321 81C410000000 add esp, 16
457 00000327 C9 leave
458 00000328 C3 ret
459
460

465
lst/kernel.lst Normal file
View File

@ -0,0 +1,465 @@
1 ;kernel.asm
2 ;Author: Josh Holtrop
3 ;Modified: 10/30/03
4
5 %define GDT_P 0x100000; ;1mb physical - Global Descriptor Table space
6 %define GDT_V GDT_P+0xC0000000
7 %define IDT_P 0x102000 ;1mb+8kb - Interrupt Descriptor Table space
8 %define IDT_V IDT_P+0xC0000000
9 %define PDBR_P 0x104000 ;1mb+16kb - Page Directory Base Register (first PD)
10 %define PDBR_V PDBR_P+0xC0000000
11 %define LOPT_P 0x105000 ;1mb+20kb - LOw Page Table for mapping first 4mb
12 %define LOPT_V LOPT_P+0xC0000000
13 %define KERNEL_P 0x106000 ;1mb+24kb - the kernel's physical address
14 %define KERNEL_V KERNEL_P+0xC0000000 ;3gb+1mb+24kb, the virtual address of the kernel
15
16 [global start]
17 [extern _isr]
18 [extern _k_init]
19
20 bits 32
21
22 ;This is where the kernel begins execution
23 ;At this point, the temporary gdt is set up to "map" 0xC000_0000 to 0x0.
24 ;We must enable paging with the first 4mb mapped 1:1 virtual:physical
25 ; and with the 4mb starting at 0xC000_0000 mapped to the first 4mb physical.
26 ;Then we can start using our "real" gdt, then unmap the lower 4mb.
27 start:
28 00000000 FA cli ;if they weren't already off
29
30 00000001 31C0 xor eax, eax
31 00000003 BF004010C0 mov edi, PDBR_V
32 00000008 B900040000 mov ecx, 1024 ;clear the PDBR
33 0000000D F3AB rep stosd
34 0000000F C705004010C0035010- mov [PDBR_V], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
35 00000018 00
36 00000019 C705004C10C0035010- mov [PDBR_V+0xC00], dword LOPT_P|0x03 ;store the physical address of the LOw Page Table (read/write, present)
37 00000022 00
38
39 00000023 BF005010C0 mov edi, LOPT_V
40 00000028 B900040000 mov ecx, 1024
41 0000002D B803000000 mov eax, 0x03 ;starting physical address = 0x0 (read/write, present flags)
42 fill_lopt_loop: ;fill the page table
43 00000032 AB stosd
44 00000033 0500100000 add eax, 4096 ;increment next phsyical address by 4kb
45 00000038 E2F8 loop fill_lopt_loop
46
47 0000003A B800401000 mov eax, PDBR_P
48 0000003F 0F22D8 mov cr3, eax ;store the Page Directory Base Address
49 00000042 0F20C0 mov eax, cr0
50 00000045 0D00000080 or eax, 0x80000000 ;set page enable bit
51 0000004A 0F22C0 mov cr0, eax ;now paging is active!
52
53
54 0000004D BF000010C0 mov edi, GDT_V
55 00000052 BE[D4000000] mov esi, gdt
56 00000057 B948000000 mov ecx, gdt_end-gdt
57 copy_gdt:
58 0000005C AC lodsb
59 0000005D AA stosb
60 0000005E E2FC loop copy_gdt
61
62 00000060 BF002010C0 mov edi, IDT_V ;destination
63 00000065 BE[22010000] mov esi, isr_0 ;address of isr0
64 0000006A BA0B000000 mov edx, isr_1-isr_0 ;distance between isr labels
65 0000006F B932000000 mov ecx, 50 ;number of isrlabels
66 fill_idt:
67 00000074 89F3 mov ebx, esi
68 00000076 6689F0 mov ax, si
69 00000079 66AB stosw ;0 offset 15:0
70 0000007B 66B80800 mov ax, KERNEL_CODE
71 0000007F 66AB stosw ;2 selector 15:0
72 00000081 66B8008E mov ax, 0x8E00
73 00000085 66AB stosw ;4 [P][DPL][0][TYPE][0][0][0][0][0][0][0][0]
74 00000087 C1EE10 shr esi, 16
75 0000008A 6689F0 mov ax, si
76 0000008D 66AB stosw ;6 offset 31:16
77 0000008F 89DE mov esi, ebx
78 00000091 01D6 add esi, edx
79 00000093 E2DF loop fill_idt
80 00000095 66C705842110C000EE mov word [IDT_V+0x30*8+4], 0xEE00 ;interrupt 0x30 has user priviledges
81
82 0000009E 0F0115[CE000000] lgdt [gdtr] ;load gdt
83 000000A5 EA[AC000000]0800 jmp KERNEL_CODE:newgdtcontinue
84 newgdtcontinue:
85 000000AC 66B81000 mov ax, KERNEL_DATA
86 000000B0 8EC0 mov es, ax
87 000000B2 8ED8 mov ds, ax
88 000000B4 8EE8 mov gs, ax
89 000000B6 8EE0 mov fs, ax
90 000000B8 8ED0 mov ss, ax
91 000000BA BCFCFF1FC0 mov esp, 0xc01ffffc ;stack just under 3gb+2mb, moves downward
92 000000BF 0F011D[1C010000] lidt [idtr] ;load idt
93
94 000000C6 E8(00000000) call _k_init
95 haltit:
96 000000CB F4 hlt ;halt processor when k_init is done
97 000000CC EBFD jmp haltit ;shouldn't get here...
98
99 %include "gdt.inc"
100 <1> ;gdt.inc
101 <1> ;Author: Josh Holtrop
102 <1> ;for HOS
103 <1> ;Modified: 10/30/03
104 <1>
105 <1> gdtr:
106 000000CE 4700 <1> dw gdt_end-gdt-1
107 000000D0 00001000 <1> dd GDT_P
108 <1> gdt:
109 000000D4 00000000 <1> dd 0
110 000000D8 00000000 <1> dd 0
111 <1> KERNEL_CODE equ $-gdt
112 000000DC FFFF <1> dw 0xffff ;limit 15:0
113 000000DE 0000 <1> dw 0x0000 ;base 15:0
114 000000E0 00 <1> db 0x00 ;base 23:16
115 000000E1 9A <1> db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
116 000000E2 CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
117 000000E3 00 <1> db 0x00 ;base 31:24
118 <1> KERNEL_DATA equ $-gdt
119 000000E4 FFFF <1> dw 0xffff ;limit 15:0
120 000000E6 0000 <1> dw 0x0000 ;base 15:0
121 000000E8 00 <1> db 0x00 ;base 23:16
122 000000E9 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
123 000000EA CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
124 000000EB 00 <1> db 0x00 ;base 31:24
125 <1> VESA_CODE equ $-gdt
126 000000EC FFFF <1> dw 0xffff ;limit 15:0
127 000000EE 0000 <1> dw 0x0000 ;base 15:0
128 000000F0 00 <1> db 0x00 ;base 23:16
129 000000F1 9A <1> db 0x9A ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
130 000000F2 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
131 000000F3 00 <1> db 0x00 ;base 31:24
132 <1> VESA_DATA equ $-gdt
133 000000F4 FFFF <1> dw 0xffff ;limit 15:0
134 000000F6 0000 <1> dw 0x0000 ;base 15:0
135 000000F8 00 <1> db 0x00 ;base 23:16
136 000000F9 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
137 000000FA 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
138 000000FB 00 <1> db 0x00 ;base 31:24
139 <1> VIDEO_TEXT equ $-gdt
140 000000FC FF7F <1> dw 0x7FFF ;limit 15:0
141 000000FE 0080 <1> dw 0x8000 ;base 15:0
142 00000100 0B <1> db 0x0B ;base 23:16
143 00000101 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
144 00000102 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
145 00000103 00 <1> db 0x00 ;base 31:24
146 <1> VIDEO_GRAPHICS equ $-gdt
147 00000104 FFFF <1> dw 0xFFFF ;limit 15:0
148 00000106 0000 <1> dw 0x0000 ;base 15:0
149 00000108 0A <1> db 0x0A ;base 23:16
150 00000109 92 <1> db 0x92 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
151 0000010A 40 <1> db 0x40 ;flags ([G][D/B][0][0]) / limit 19:16
152 0000010B 00 <1> db 0x00 ;base 31:24
153 <1> USER_CODE equ $-gdt
154 0000010C FFFF <1> dw 0xffff ;limit 15:0
155 0000010E 0000 <1> dw 0x0000 ;base 15:0
156 00000110 00 <1> db 0x00 ;base 23:16
157 00000111 FA <1> db 0xFA ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
158 00000112 CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
159 00000113 00 <1> db 0x00 ;base 31:24
160 <1> USER_DATA equ $-gdt
161 00000114 FFFF <1> dw 0xffff ;limit 15:0
162 00000116 0000 <1> dw 0x0000 ;base 15:0
163 00000118 00 <1> db 0x00 ;base 23:16
164 00000119 F2 <1> db 0xF2 ;access ([P][DPL][1][Executable][Direction/Conforming][Writable/Readable][A])
165 0000011A CF <1> db 0xCF ;flags ([G][D/B][0][0]) / limit 19:16
166 0000011B 00 <1> db 0x00 ;base 31:24
167 <1> gdt_end:
168 <1>
169 <1>
170 <1>
171 %include "idt.inc"
172 <1> ;idt.inc
173 <1> ;Author: Josh Holtrop
174 <1> ;for HOS
175 <1> ;Modified: 10/30/03
176 <1>
177 <1> idtr:
178 0000011C 8F01 <1> dw 50*8-1 ;size of idt
179 0000011E 00201000 <1> dd IDT_P ;address of idt
180 <1>
181 <1>
182 <1> %macro isr_label 1
183 <1> isr_%1:
184 <1> push eax
185 <1> mov eax, %1
186 <1> jmp isr_main
187 <1> %endmacro
188 <1>
189 <1> isr_label 0
190 <2> isr_%1:
191 00000122 50 <2> push eax
192 00000123 B800000000 <2> mov eax, %1
193 00000128 E91B020000 <2> jmp isr_main
194 <1> isr_label 1
195 <2> isr_%1:
196 0000012D 50 <2> push eax
197 0000012E B801000000 <2> mov eax, %1
198 00000133 E910020000 <2> jmp isr_main
199 <1> isr_label 2
200 <2> isr_%1:
201 00000138 50 <2> push eax
202 00000139 B802000000 <2> mov eax, %1
203 0000013E E905020000 <2> jmp isr_main
204 <1> isr_label 3
205 <2> isr_%1:
206 00000143 50 <2> push eax
207 00000144 B803000000 <2> mov eax, %1
208 00000149 E9FA010000 <2> jmp isr_main
209 <1> isr_label 4
210 <2> isr_%1:
211 0000014E 50 <2> push eax
212 0000014F B804000000 <2> mov eax, %1
213 00000154 E9EF010000 <2> jmp isr_main
214 <1> isr_label 5
215 <2> isr_%1:
216 00000159 50 <2> push eax
217 0000015A B805000000 <2> mov eax, %1
218 0000015F E9E4010000 <2> jmp isr_main
219 <1> isr_label 6
220 <2> isr_%1:
221 00000164 50 <2> push eax
222 00000165 B806000000 <2> mov eax, %1
223 0000016A E9D9010000 <2> jmp isr_main
224 <1> isr_label 7
225 <2> isr_%1:
226 0000016F 50 <2> push eax
227 00000170 B807000000 <2> mov eax, %1
228 00000175 E9CE010000 <2> jmp isr_main
229 <1> isr_label 8
230 <2> isr_%1:
231 0000017A 50 <2> push eax
232 0000017B B808000000 <2> mov eax, %1
233 00000180 E9C3010000 <2> jmp isr_main
234 <1> isr_label 9
235 <2> isr_%1:
236 00000185 50 <2> push eax
237 00000186 B809000000 <2> mov eax, %1
238 0000018B E9B8010000 <2> jmp isr_main
239 <1> isr_label 10
240 <2> isr_%1:
241 00000190 50 <2> push eax
242 00000191 B80A000000 <2> mov eax, %1
243 00000196 E9AD010000 <2> jmp isr_main
244 <1> isr_label 11
245 <2> isr_%1:
246 0000019B 50 <2> push eax
247 0000019C B80B000000 <2> mov eax, %1
248 000001A1 E9A2010000 <2> jmp isr_main
249 <1> isr_label 12
250 <2> isr_%1:
251 000001A6 50 <2> push eax
252 000001A7 B80C000000 <2> mov eax, %1
253 000001AC E997010000 <2> jmp isr_main
254 <1> isr_label 13
255 <2> isr_%1:
256 000001B1 50 <2> push eax
257 000001B2 B80D000000 <2> mov eax, %1
258 000001B7 E98C010000 <2> jmp isr_main
259 <1> isr_label 14
260 <2> isr_%1:
261 000001BC 50 <2> push eax
262 000001BD B80E000000 <2> mov eax, %1
263 000001C2 E981010000 <2> jmp isr_main
264 <1> isr_label 15
265 <2> isr_%1:
266 000001C7 50 <2> push eax
267 000001C8 B80F000000 <2> mov eax, %1
268 000001CD E976010000 <2> jmp isr_main
269 <1> isr_label 16
270 <2> isr_%1:
271 000001D2 50 <2> push eax
272 000001D3 B810000000 <2> mov eax, %1
273 000001D8 E96B010000 <2> jmp isr_main
274 <1> isr_label 17
275 <2> isr_%1:
276 000001DD 50 <2> push eax
277 000001DE B811000000 <2> mov eax, %1
278 000001E3 E960010000 <2> jmp isr_main
279 <1> isr_label 18
280 <2> isr_%1:
281 000001E8 50 <2> push eax
282 000001E9 B812000000 <2> mov eax, %1
283 000001EE E955010000 <2> jmp isr_main
284 <1> isr_label 19
285 <2> isr_%1:
286 000001F3 50 <2> push eax
287 000001F4 B813000000 <2> mov eax, %1
288 000001F9 E94A010000 <2> jmp isr_main
289 <1> isr_label 20
290 <2> isr_%1:
291 000001FE 50 <2> push eax
292 000001FF B814000000 <2> mov eax, %1
293 00000204 E93F010000 <2> jmp isr_main
294 <1> isr_label 21
295 <2> isr_%1:
296 00000209 50 <2> push eax
297 0000020A B815000000 <2> mov eax, %1
298 0000020F E934010000 <2> jmp isr_main
299 <1> isr_label 22
300 <2> isr_%1:
301 00000214 50 <2> push eax
302 00000215 B816000000 <2> mov eax, %1
303 0000021A E929010000 <2> jmp isr_main
304 <1> isr_label 23
305 <2> isr_%1:
306 0000021F 50 <2> push eax
307 00000220 B817000000 <2> mov eax, %1
308 00000225 E91E010000 <2> jmp isr_main
309 <1> isr_label 24
310 <2> isr_%1:
311 0000022A 50 <2> push eax
312 0000022B B818000000 <2> mov eax, %1
313 00000230 E913010000 <2> jmp isr_main
314 <1> isr_label 25
315 <2> isr_%1:
316 00000235 50 <2> push eax
317 00000236 B819000000 <2> mov eax, %1
318 0000023B E908010000 <2> jmp isr_main
319 <1> isr_label 26
320 <2> isr_%1:
321 00000240 50 <2> push eax
322 00000241 B81A000000 <2> mov eax, %1
323 00000246 E9FD000000 <2> jmp isr_main
324 <1> isr_label 27
325 <2> isr_%1:
326 0000024B 50 <2> push eax
327 0000024C B81B000000 <2> mov eax, %1
328 00000251 E9F2000000 <2> jmp isr_main
329 <1> isr_label 28
330 <2> isr_%1:
331 00000256 50 <2> push eax
332 00000257 B81C000000 <2> mov eax, %1
333 0000025C E9E7000000 <2> jmp isr_main
334 <1> isr_label 29
335 <2> isr_%1:
336 00000261 50 <2> push eax
337 00000262 B81D000000 <2> mov eax, %1
338 00000267 E9DC000000 <2> jmp isr_main
339 <1> isr_label 30
340 <2> isr_%1:
341 0000026C 50 <2> push eax
342 0000026D B81E000000 <2> mov eax, %1
343 00000272 E9D1000000 <2> jmp isr_main
344 <1> isr_label 31
345 <2> isr_%1:
346 00000277 50 <2> push eax
347 00000278 B81F000000 <2> mov eax, %1
348 0000027D E9C6000000 <2> jmp isr_main
349 <1> isr_label 32
350 <2> isr_%1:
351 00000282 50 <2> push eax
352 00000283 B820000000 <2> mov eax, %1
353 00000288 E9BB000000 <2> jmp isr_main
354 <1> isr_label 33
355 <2> isr_%1:
356 0000028D 50 <2> push eax
357 0000028E B821000000 <2> mov eax, %1
358 00000293 E9B0000000 <2> jmp isr_main
359 <1> isr_label 34
360 <2> isr_%1:
361 00000298 50 <2> push eax
362 00000299 B822000000 <2> mov eax, %1
363 0000029E E9A5000000 <2> jmp isr_main
364 <1> isr_label 35
365 <2> isr_%1:
366 000002A3 50 <2> push eax
367 000002A4 B823000000 <2> mov eax, %1
368 000002A9 E99A000000 <2> jmp isr_main
369 <1> isr_label 36
370 <2> isr_%1:
371 000002AE 50 <2> push eax
372 000002AF B824000000 <2> mov eax, %1
373 000002B4 E98F000000 <2> jmp isr_main
374 <1> isr_label 37
375 <2> isr_%1:
376 000002B9 50 <2> push eax
377 000002BA B825000000 <2> mov eax, %1
378 000002BF E984000000 <2> jmp isr_main
379 <1> isr_label 38
380 <2> isr_%1:
381 000002C4 50 <2> push eax
382 000002C5 B826000000 <2> mov eax, %1
383 000002CA E979000000 <2> jmp isr_main
384 <1> isr_label 39
385 <2> isr_%1:
386 000002CF 50 <2> push eax
387 000002D0 B827000000 <2> mov eax, %1
388 000002D5 E96E000000 <2> jmp isr_main
389 <1> isr_label 40
390 <2> isr_%1:
391 000002DA 50 <2> push eax
392 000002DB B828000000 <2> mov eax, %1
393 000002E0 E963000000 <2> jmp isr_main
394 <1> isr_label 41
395 <2> isr_%1:
396 000002E5 50 <2> push eax
397 000002E6 B829000000 <2> mov eax, %1
398 000002EB E958000000 <2> jmp isr_main
399 <1> isr_label 42
400 <2> isr_%1:
401 000002F0 50 <2> push eax
402 000002F1 B82A000000 <2> mov eax, %1
403 000002F6 E94D000000 <2> jmp isr_main
404 <1> isr_label 43
405 <2> isr_%1:
406 000002FB 50 <2> push eax
407 000002FC B82B000000 <2> mov eax, %1
408 00000301 E942000000 <2> jmp isr_main
409 <1> isr_label 44
410 <2> isr_%1:
411 00000306 50 <2> push eax
412 00000307 B82C000000 <2> mov eax, %1
413 0000030C E937000000 <2> jmp isr_main
414 <1> isr_label 45
415 <2> isr_%1:
416 00000311 50 <2> push eax
417 00000312 B82D000000 <2> mov eax, %1
418 00000317 E92C000000 <2> jmp isr_main
419 <1> isr_label 46
420 <2> isr_%1:
421 0000031C 50 <2> push eax
422 0000031D B82E000000 <2> mov eax, %1
423 00000322 E921000000 <2> jmp isr_main
424 <1> isr_label 47
425 <2> isr_%1:
426 00000327 50 <2> push eax
427 00000328 B82F000000 <2> mov eax, %1
428 0000032D E916000000 <2> jmp isr_main
429 <1> isr_label 48
430 <2> isr_%1:
431 00000332 50 <2> push eax
432 00000333 B830000000 <2> mov eax, %1
433 00000338 E90B000000 <2> jmp isr_main
434 <1> isr_label 49
435 <2> isr_%1:
436 0000033D 50 <2> push eax
437 0000033E B831000000 <2> mov eax, %1
438 00000343 E900000000 <2> jmp isr_main
439 <1>
440 <1> isr_main:
441 00000348 60 <1> pusha
442 00000349 1E <1> push ds
443 0000034A 06 <1> push es
444 <1>
445 0000034B 50 <1> push eax
446 <1>
447 0000034C E8(00000000) <1> call _isr
448 <1>
449 00000351 58 <1> pop eax
450 <1>
451 00000352 07 <1> pop es
452 00000353 1F <1> pop ds
453 00000354 61 <1> popa
454 00000355 58 <1> pop eax
455 <1>
456 00000356 CF <1> iret
457 <1>
458 <1>
459 <1>
460 <1>
461 <1>
462 <1>
463 <1>
464
465

2
rd.c
View File

@ -6,7 +6,7 @@
byte *rd_readSector(DiskDevice *rd, dword sector, byte *dest)
{
memcpy((dword)dest, rd->location + (sector * 512), 512);
memcpy(dest, (void *)(rd->location + (sector * 512)), 512);
return dest;
}

View File

@ -148,29 +148,43 @@ got_rd:
mov [ds:BOOT_HASRD], al
pop ds ;ds=0
cmp al, 0 ;dont load rd
jz no_rd
jnz yes_rd
jmp no_rd
yes_rd:
mov cx, 80
mov edi, 0xb8000+160*4
filler_loop:
filler_loop: ;draw a red bar
mov word [ds:edi], 0x0400+177
inc edi
inc edi
loop filler_loop
mov cx, 80 ;80 cylinders to read
xor si, si
xor si, si ;start at cylinder 0
mov edi, BOOT_RD_ADD ;ram disk address
read_cylinder:
push cx
mov bx, 0x0100
mov bx, 0x0100 ;read sectors from head 0
mov es, bx
xor bx, bx
mov ax, 0x0224
mov cx, si
mov ch, cl
mov cl, 1
xor dx, dx
mov dl, [gs:BOOT_DRIVE]
xor bx, bx ;es:bx = data buffer for read
mov ax, 0x0212 ;ah = int 0x13 function 2, al = number of sectors to read
mov cx, si ;what cyl. we are on is now in cx
mov ch, cl ;ch = cyl. number
mov cl, 1 ;cl = sector number 1-63
xor dx, dx ;dh = head number
mov dl, [gs:BOOT_DRIVE] ;dl = drive number
int 0x13
mov bx, 0x0100 ;now read sectors from head 1
mov es, bx
mov bx, 9216 ;es:bx = data buffer for read
mov ax, 0x0212 ;ah = int 0x13 function 2, al = number of sectors to read
mov cx, si ;what cyl. we are on is now in cx
mov ch, cl ;ch = cyl. number
mov cl, 1 ;cl = sector number 1-63
mov dh, 1 ;dh = head number
mov dl, [gs:BOOT_DRIVE] ;dl = drive number
int 0x13
mov ebx, 0xb8000
@ -837,7 +851,7 @@ puthex2_goon2:
ret
;------------------------------------------------------
txt_welcome: db " Welcome to HOS v", VERSION, "! ", 0
txt_welcome: db " Welcome to HOS v", VERSION, "! ", 0
txt_rd1: db "1. Do not load an initial ram disk", 0
txt_rd2: db "2. Load initial ram disk from floppy", 0
txt_input: db "Enter your selection: ", 0

2
vfs.c
View File

@ -43,7 +43,7 @@ byte *vfs_readFile(char *fileName)
if (!((fileName[3] == ':') && (fileName[4] == '/'))) //if we aren't using the root directory, then there must be a 3 character device explicitly specified
return 0; // followed by a colon and then a slash
char device[4];
memcpy((dword)device, (dword)fileName, 3); //copy the 3 digit device id to device
memcpy(device, fileName, 3); //copy the 3 digit device id to device
device[3] = 0; //null-terminating character for device string
dd = vfs_getDiskDeviceByID(device);
if (!dd) //the specified device was not found