Import backup from 2003-09-01
This commit is contained in:
parent
594502f824
commit
dae5569216
@ -13,7 +13,7 @@ inline void outportw(unsigned int port, unsigned int value) // Output a word to
|
||||
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
|
||||
};
|
||||
|
||||
inline UCHAR inportb(unsigned short port)
|
||||
inline byte inportb(unsigned short port)
|
||||
{
|
||||
unsigned char ret_val;
|
||||
|
||||
@ -35,7 +35,7 @@ void disable_ints()
|
||||
|
||||
void remap_pics(int pic1, int pic2)
|
||||
{
|
||||
UCHAR a1, a2;
|
||||
byte a1, a2;
|
||||
|
||||
a1 = inportb(PIC1_DATA);
|
||||
a2 = inportb(PIC2_DATA);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
inline void outportb(unsigned int port, unsigned char value);
|
||||
inline void outportw(unsigned int port, unsigned int value);
|
||||
inline UCHAR inportb(unsigned short port);
|
||||
inline byte inportb(unsigned short port);
|
||||
void enable_ints();
|
||||
void disable_ints();
|
||||
inline void restart();
|
||||
|
55
io.asm
55
io.asm
@ -1,6 +1,10 @@
|
||||
|
||||
;void writeCursorPosition(dword pos);
|
||||
;dword getCursorPosition();
|
||||
%macro jzfar 1
|
||||
jnz %%skip
|
||||
jmp %1
|
||||
%%skip:
|
||||
|
||||
%endmacro
|
||||
|
||||
[global _writeCursorPosition]
|
||||
[global _getCursorPosition]
|
||||
@ -13,7 +17,7 @@
|
||||
|
||||
|
||||
;
|
||||
;void writeCursorPosition(int position)
|
||||
;void writeCursorPosition(word pos)
|
||||
;
|
||||
_writeCursorPosition:
|
||||
push ebp
|
||||
@ -79,7 +83,7 @@ _getCursorPosition:
|
||||
|
||||
|
||||
;
|
||||
;void putc(int chr)
|
||||
;int putc(int chr)
|
||||
;
|
||||
_putc:
|
||||
push ebp
|
||||
@ -177,9 +181,9 @@ printf_loop:
|
||||
mov al, [ebx]
|
||||
inc ebx
|
||||
cmp al, 0
|
||||
jz printf_done
|
||||
jzfar printf_done
|
||||
cmp al, '%'
|
||||
jz printf_percent
|
||||
jzfar printf_percent
|
||||
cmp ecx, 1
|
||||
jz printf_special
|
||||
|
||||
@ -196,6 +200,8 @@ printf_special:
|
||||
jz printf_hex
|
||||
cmp al, '%'
|
||||
jz printf_ppercent
|
||||
cmp al, 's'
|
||||
jz printf_string
|
||||
jmp printf_special_done
|
||||
|
||||
printf_decimal:
|
||||
@ -218,6 +224,13 @@ printf_ppercent:
|
||||
add esp, 4
|
||||
jmp printf_special_done
|
||||
|
||||
printf_string:
|
||||
mov eax, [esi]
|
||||
push eax
|
||||
call _puts
|
||||
add esp, 4
|
||||
jmp printf_special_done
|
||||
|
||||
printf_special_done
|
||||
add esi, 4 ;point to next extra argument
|
||||
jmp printf_loop
|
||||
@ -272,7 +285,7 @@ console_cls_loop:
|
||||
ret
|
||||
|
||||
;
|
||||
;void putHex(dword number)
|
||||
;int putHex(dword number)
|
||||
;
|
||||
_putHex:
|
||||
push ebp
|
||||
@ -318,15 +331,39 @@ putHex_loop_end:
|
||||
|
||||
|
||||
;
|
||||
;void putDec(dword number)
|
||||
;int putDec(dword number)
|
||||
;
|
||||
_putDec:
|
||||
|
||||
ret
|
||||
|
||||
|
||||
;
|
||||
;int puts(char *str)
|
||||
;
|
||||
_puts:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
push esi
|
||||
push eax
|
||||
mov esi, [ebp+8] ;esi = ptr to string
|
||||
puts_loop:
|
||||
lodsb
|
||||
cmp al, 0
|
||||
jz puts_done
|
||||
push eax
|
||||
call _putc
|
||||
add esp, 4
|
||||
jmp puts_loop
|
||||
|
||||
puts_done:
|
||||
pop eax
|
||||
pop esi
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
11
io.h
11
io.h
@ -3,10 +3,15 @@
|
||||
#ifndef __HIO_H__
|
||||
#define __HIO_H__ __HIO_H__
|
||||
|
||||
void writeCursorPosition(dword pos);
|
||||
dword getCursorPosition();
|
||||
void putc(byte chr);
|
||||
void writeCursorPosition(word pos);
|
||||
word getCursorPosition();
|
||||
int putc(byte chr);
|
||||
int printf(char *fmt, ...);
|
||||
int puts(char *str);
|
||||
int putDec(dword number);
|
||||
int putHex(dword number);
|
||||
void console_cls();
|
||||
void console_scroll();
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -28,9 +28,7 @@
|
||||
#define YELLOW_TXT 0x0E
|
||||
#define BRWHITE_TXT 0x0F
|
||||
|
||||
#define UCHAR unsigned char
|
||||
#define USHORT unsigned short
|
||||
#define UINT unsigned int
|
||||
#define FREERAM_START 0x268000
|
||||
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
|
8
kernel.c
8
kernel.c
@ -29,14 +29,6 @@ void k_init()
|
||||
outportb(0x40, 0x2e); //msb
|
||||
enable_ints();
|
||||
video_init((ModeInfoBlock *) 0x90306);
|
||||
int a;
|
||||
for (a=0;a<768;a+=10)
|
||||
{
|
||||
video_horiz(a, 2, 1021, 0);
|
||||
video_vert(a, 2, 765, 0x0000FFFF);
|
||||
}
|
||||
video_rect(10, 10, 100, 100, 0x00FFFFFF);
|
||||
video_rectf(11, 11, 99, 99, 0x00FFFF00);
|
||||
console_cls();
|
||||
mm_init();
|
||||
}
|
||||
|
29
mm.c
29
mm.c
@ -1,5 +1,11 @@
|
||||
// mm.c
|
||||
// 09/01/03 Josh Holtrop
|
||||
|
||||
// 0x368000 is first available byte (this is right after the kernel @ 1mb and the initrd @ 2mb, 1440kb.
|
||||
|
||||
|
||||
pageblock *first_pageblock = (pageblock *) 0;
|
||||
dword totalmem = 0;
|
||||
|
||||
void mm_init()
|
||||
{
|
||||
@ -7,7 +13,28 @@ void mm_init()
|
||||
memmap_entry *maps = (memmap_entry *) 0x92000;
|
||||
dword a;
|
||||
for (a=0;a<(*memmap_entries);a++)
|
||||
printf("Entry %x:\tBase: %x\n\t\tLimit: %x\n\t\tAttributes: %x\n", a, maps[a].base.lowdword, maps[a].limit.lowdword, maps[a].attributes);
|
||||
{
|
||||
if (maps[a].attributes == 1) // (1) mem free to OS
|
||||
{
|
||||
if ((maps[a].base.lowdword + maps[a].limit.lowdword) > (FREERAM_START+4096)) //goes past where we start freeram
|
||||
{
|
||||
if (first_pageblock == 0) //no pageblock page set up yet
|
||||
{
|
||||
if (maps[a].base.lowdword < (FREERAM_START+4096))
|
||||
{
|
||||
first_pageblock = (pageblock *) FREERAM_START;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
totalmem += maps[a].limit.lowdword;
|
||||
}
|
||||
}
|
||||
printf("Total memory available to OS: %x", totalmem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
8
mm.h
8
mm.h
@ -11,6 +11,14 @@ typedef struct {
|
||||
} __attribute__((packed)) memmap_entry;
|
||||
|
||||
|
||||
typedef struct {
|
||||
dword base;
|
||||
dword length; //in pages
|
||||
dword flags;
|
||||
dword link;
|
||||
} __attribute__ ((packed)) pageblock; //16 byte pageblock entry - 512 entries = 1 page
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -215,7 +215,7 @@ getmemmap_loop:
|
||||
;mov ebx, 0x00000000
|
||||
mov edx, 0x534D4150 ;'SMAP'
|
||||
int 0x15
|
||||
jc getmemmap_done
|
||||
jc getmemmap_carry
|
||||
cmp eax, 0x534D4150 ;eax should be 'SMAP' on return...
|
||||
jnz getmemmap_error
|
||||
cmp ebx, 0
|
||||
@ -245,6 +245,8 @@ getmemmap_error:
|
||||
hlt
|
||||
jmp $
|
||||
|
||||
getmemmap_carry:
|
||||
dec edx
|
||||
getmemmap_done:
|
||||
pop edx
|
||||
pop di
|
||||
|
2
video.c
2
video.c
@ -22,7 +22,7 @@ void video_init(ModeInfoBlock *mib)
|
||||
vid_ptr32 = (dword *) video_mode.PhysBasePtr;
|
||||
}
|
||||
|
||||
UINT tot = ((video_mode.XResolution) * (video_mode.YResolution));
|
||||
dword tot = ((video_mode.XResolution) * (video_mode.YResolution));
|
||||
int a;
|
||||
for (a = 0; a < tot; a++)
|
||||
{
|
||||
|
64
video.h
64
video.h
@ -14,42 +14,42 @@ void video_psetp(int pixel, dword color);
|
||||
#define checkBoundsy(x) (x<0 ? x=0 : (x>=video_mode.YResolution ? x=video_mode.YResolution-1 : 0))
|
||||
|
||||
typedef struct{
|
||||
USHORT ModeAttributes;
|
||||
UCHAR WinAAttributes;
|
||||
UCHAR WinBAttributes;
|
||||
USHORT WinGranularity;
|
||||
USHORT WinSize;
|
||||
USHORT WinASegment;
|
||||
USHORT WinBSegment;
|
||||
UINT WinFuncPtr;
|
||||
USHORT BytesPerScanLine;
|
||||
word ModeAttributes;
|
||||
byte WinAAttributes;
|
||||
byte WinBAttributes;
|
||||
word WinGranularity;
|
||||
word WinSize;
|
||||
word WinASegment;
|
||||
word WinBSegment;
|
||||
dword WinFuncPtr;
|
||||
word BytesPerScanLine;
|
||||
|
||||
USHORT XResolution;
|
||||
USHORT YResolution;
|
||||
UCHAR XCharSize;
|
||||
UCHAR YCharSize;
|
||||
UCHAR NumberOfPlanes;
|
||||
UCHAR BitsPerPixel;
|
||||
UCHAR NumberOfBanks;
|
||||
UCHAR MemoryModel;
|
||||
UCHAR BankSize;
|
||||
UCHAR NumberOfImagePages;
|
||||
UCHAR Reserved1;
|
||||
word XResolution;
|
||||
word YResolution;
|
||||
byte XCharSize;
|
||||
byte YCharSize;
|
||||
byte NumberOfPlanes;
|
||||
byte BitsPerPixel;
|
||||
byte NumberOfBanks;
|
||||
byte MemoryModel;
|
||||
byte BankSize;
|
||||
byte NumberOfImagePages;
|
||||
byte Reserved1;
|
||||
|
||||
UCHAR RedMaskSize;
|
||||
UCHAR RedFieldPosition;
|
||||
UCHAR GreenMaskSize;
|
||||
UCHAR GreenFieldPosition;
|
||||
UCHAR BlueMaskSize;
|
||||
UCHAR BlueFieldPosition;
|
||||
UCHAR RsvdMaskSize;
|
||||
UCHAR RsvdFieldPosition;
|
||||
UCHAR DirectColorModeInfo;
|
||||
byte RedMaskSize;
|
||||
byte RedFieldPosition;
|
||||
byte GreenMaskSize;
|
||||
byte GreenFieldPosition;
|
||||
byte BlueMaskSize;
|
||||
byte BlueFieldPosition;
|
||||
byte RsvdMaskSize;
|
||||
byte RsvdFieldPosition;
|
||||
byte DirectColorModeInfo;
|
||||
|
||||
dword PhysBasePtr;
|
||||
UINT OffScreenMemOffset;
|
||||
USHORT OffScreenMemSize;
|
||||
UCHAR Reserved[206];
|
||||
dword OffScreenMemOffset;
|
||||
word OffScreenMemSize;
|
||||
byte Reserved[206];
|
||||
} ModeInfoBlock;
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user