diff --git a/asmfuncs.asm b/asmfuncs.asm index e5a26b8..02f4bc1 100644 --- a/asmfuncs.asm +++ b/asmfuncs.asm @@ -2,13 +2,10 @@ ; Josh Holtrop ; 10/23/03 -[global _write_cr0] -[global _read_cr0] -[global _write_cr3] -[global _read_cr3] ;stores the parameter to the CR0 register ;extern dword write_cr0(dword cr0); +[global _write_cr0] _write_cr0: push ebp mov ebp, esp @@ -19,12 +16,14 @@ _write_cr0: ;returns the value in the CR0 register ;extern dword read_cr0(); +[global _read_cr0] _read_cr0: mov eax, cr0; ret ;stores the parameter to the CR3 register ;extern dword write_cr3(dword cr3); +[global _write_cr3] _write_cr3: push ebp mov ebp, esp @@ -35,11 +34,90 @@ _write_cr3: ;returns the value in the CR3 register ;extern dword read_cr3(); +[global _read_cr3] _read_cr3: mov eax, cr3; ret +;copies 32bpp video buffer memory to LFB +;extern dword video_copyBuffer32(dword src, dword dest, dword pixelcount); +[global _video_copyBuffer32] +_video_copyBuffer32: + push ebp + mov ebp, esp + push esi + push edi + push ecx + mov esi, [ebp+8] + mov edi, [ebp+12] + mov ecx, [ebp+16] + rep movsd + pop ecx + pop edi + pop esi + pop ebp + ret + + +;copies 24bpp video buffer memory to LFB +;extern dword video_copyBuffer24(dword src, dword dest, dword pixelcount); +[global _video_copyBuffer24] +_video_copyBuffer24: + push ebp + mov ebp, esp + push esi + push edi + push ecx + mov esi, [ebp+8] + mov edi, [ebp+12] + mov ecx, [ebp+16] +_video_copyBuffer24_loop: + movsd + dec edi + loop _video_copyBuffer24_loop + pop ecx + pop edi + pop esi + pop ebp + ret + + +;copies 16bpp video buffer memory to LFB +;extern dword video_copyBuffer16(dword src, dword dest, dword pixelcount); +[global _video_copyBuffer16] +_video_copyBuffer16: + push ebp + mov ebp, esp + push esi + push edi + push ecx + push ebx + mov esi, [ebp+8] + mov edi, [ebp+12] + mov ecx, [ebp+16] +_video_copyBuffer16_loop: + lodsd ;eax = 32bpp color + shr eax, 3 + mov ebx, eax + and ebx, 0x1F + shr eax, 2 + and eax, 0xFFFFFFE0 + or ebx, eax + and ebx, 0x7FF + shr eax, 3 + and eax, 0xF800 + or ebx, eax + mov eax, ebx + stosw ;store ax + loop _video_copyBuffer16_loop + pop ebx + pop ecx + pop edi + pop esi + pop ebp + ret + diff --git a/kernel.c b/kernel.c index 5e29b29..3b8a36b 100644 --- a/kernel.c +++ b/kernel.c @@ -1,8 +1,8 @@ //kernel.c //08/13/03 Josh Holtrop //Holtrop's Operating System -//Version: 0.1.2 -//Modified: 10/30/03 +//Version: 0.12 +//Modified: 11/12/03 #include "k_defines.h" //#DEFINE's for kernel @@ -55,7 +55,7 @@ void k_init() enable_ints(); kbd_resetLEDs(); //after enabling interrupts!! - printf("HOS 0.1.2 - Kernel Size: %d kb\n", kernel_size()/1024); + printf("HOS 0.12 - Kernel Size: %d kb\n", kernel_size()/1024); printf("Memory available to OS: %d MB (Bytes: %d)\n", mm_totalmem/0x100000, mm_totalmem); printf("Freem memory: %d bytes\n", mm_freemem()); diff --git a/lib/compa.bat b/lib/compa.bat index 66e2e9b..9a83959 100755 --- a/lib/compa.bat +++ b/lib/compa.bat @@ -1 +1,2 @@ nasmw -f aout -l io.lst io.asm -o io_a.o +nasmw -f aout -l misc.lst misc.asm -o misc.o diff --git a/lib/misc.asm b/lib/misc.asm new file mode 100644 index 0000000..187f931 --- /dev/null +++ b/lib/misc.asm @@ -0,0 +1,25 @@ + + + +;void memcpy(dword src, dword dest, dword length) +[global _memcpy] +_memcpy: + push ebp + mov ebp, esp + push esi + push edi + push ecx + mov esi, [ebp+8] + mov edi, [ebp+12] + mov ecx, [ebp+14] + + rep movsb + + pop ecx + pop edi + pop esi + pop ebp + ret + + + diff --git a/lib/misc.h b/lib/misc.h new file mode 100644 index 0000000..d624e67 --- /dev/null +++ b/lib/misc.h @@ -0,0 +1,8 @@ + +#ifndef __HMISC_H__ +#define __HMISC_H__ __HMISC_H__ + +void memcpy(dword src, dword dest, dword length); + +#endif + diff --git a/stage1.asm b/stage1.asm index 2df5de7..6f526fc 100644 --- a/stage1.asm +++ b/stage1.asm @@ -28,7 +28,7 @@ brDrive DB 0 ; 0024h - Physical drive no. DB 0 ; 0025h - Reserved (FAT32) DB 29H ; 0026h - Extended boot record sig (FAT32) brSerialNum DD 404418EAH ; 0027h - Volume serial number -brLabel DB 'HOS 0.1.1 ' ; 002Bh - Volume label +brLabel DB 'Holtrops OS' ; 002Bh - Volume label brFSID DB 'FAT12 ' ; 0036h - File System ID ;------------------------------------------------------------------------ diff --git a/video.c b/video.c index 6206274..1c4a180 100644 --- a/video.c +++ b/video.c @@ -31,7 +31,7 @@ void video_init(ModeInfoBlock *mib) int VXR = video_mode.XResolution; int VYR = video_mode.YResolution; - + video_rectf(VXR*3/11, 0, VXR*4/11, VYR-1, 0x00000088); //test rectangles, draws "HOS" video_rectf(VXR*7/11, 0, VXR*8/11, VYR-1, 0x00000088); video_rectf(VXR/11, 0, VXR*2/11, VYR*2/5, 0x00000088); @@ -141,7 +141,19 @@ inline void video_pset(int x, int y, dword color) //Copies double-buffer to VESA Linear Frame Buffer void video_copyBuffer() { - int pixel; + switch (video_mode.BitsPerPixel) + { + case 32: + video_copyBuffer32((dword)vid_Buffer, video_mode.PhysBasePtr, video_mode.XResolution*video_mode.YResolution); + break; + case 24: + video_copyBuffer24((dword)vid_Buffer, video_mode.PhysBasePtr, video_mode.XResolution*video_mode.YResolution); + break; + case 16: + video_copyBuffer16((dword)vid_Buffer, video_mode.PhysBasePtr, video_mode.XResolution*video_mode.YResolution); + break; + } + /*int pixel; dword color; for (pixel = 0; pixel < video_mode.XResolution*video_mode.YResolution; pixel++) { @@ -162,7 +174,7 @@ void video_copyBuffer() color = vid_Buffer[pixel]; ((dword *)video_mode.PhysBasePtr)[pixel] = color; } - } + } */ } diff --git a/video.h b/video.h index 403279e..abfa4e2 100644 --- a/video.h +++ b/video.h @@ -11,6 +11,9 @@ inline void video_pset(int x, int y, dword color); void video_psetp(int pixel, dword color); void video_copyBuffer(); +extern dword video_copyBuffer16(dword src, dword dest, dword pixelcount); +extern dword video_copyBuffer24(dword src, dword dest, dword pixelcount); +extern dword video_copyBuffer32(dword src, dword dest, dword pixelcount); typedef struct{ word ModeAttributes;