12
« am: 28. November 2012, 11:16 »
Hallo,
habe da den Source von start.c: , damit nicht das komplette archiv gesaugt werden muss ...
#include "arch.h"
#include "video.h"
#include "k_defines.h"
#include "ints.h"
#include "descriptor.h"
#include "pic.h"
#include "./drivers/mindrvr.h"
void testint(void);
extern int printf(char*,...);
extern int testfat(void);
extern int ticks;
extern int InitializeMemoryManager(void);
extern short console_cursor_xpos;
extern short console_cursor_ypos;
extern int console_color_attribut;
#define VK_A 0x1e61
#define VK_B 0x3062
#define VK_C 0x2e63
#define VK_D 0x2064
#define VK_E 0x1265
#define VK_F 0x2166
#define VK_G 0x2267
#define VK_H 0x2368
#define VK_I 0x1769
#define VK_J 0x246a
#define VK_K 0x256b
#define VK_L 0x266c
#define VK_M 0x326d
#define VK_N 0x316e
#define VK_O 0x186f
#define VK_P 0x1970
#define VK_Q 0x1071
#define VK_R 0x1372
#define VK_S 0x1f73
#define VK_T 0x1474
#define VK_U 0x1675
#define VK_V 0x2f76
#define VK_W 0x1177
#define VK_X 0x2d78
#define VK_Y 0x2c7a
#define VK_Z 0x1579
#define VK_BACKSPACE 0xe08
#define VK_RETURN 0x1c0d
#define VK_ESC 0x11b
#define VK_F1 0x3b00
#define VK_F2 0x3c00
#define VK_F3 0x3d00
#define VK_F4 0x3e00
#define VK_F5 0x3f00
#define VK_F6 0x4000
#define VK_F7 0x4100
#define VK_F8 0x4200
#define VK_F9 0x4300
#define VK_F10 0x4400
#define MAXKEYCODES 29
struct {
unsigned short keycode;
unsigned int extended;
unsigned int shift;
char *consolecode;
} __attribute__((packed)) GERMAN_KEYBOARD_STRUCT[MAXKEYCODES] = {
VK_A, 0, 0, "a" ,
VK_B, 0, 0, "b" ,
VK_C, 0, 0, "c" ,
VK_D, 0, 0, "d" ,
VK_E, 0, 0, "e" ,
VK_F, 0, 0, "f" ,
VK_G, 0, 0, "g" ,
VK_H, 0, 0, "h" ,
VK_I, 0, 0, "i" ,
VK_J, 0, 0, "j" ,
VK_K, 0, 0, "k" ,
VK_L, 0, 0, "l" ,
VK_M, 0, 0, "m" ,
VK_N, 0, 0, "n" ,
VK_O, 0, 0, "o" ,
VK_P, 0, 0, "p" ,
VK_Q, 0, 0, "q" ,
VK_R, 0, 0, "r" ,
VK_S, 0, 0, "s" ,
VK_T, 0, 0, "t" ,
VK_U, 0, 0, "u" ,
VK_V, 0, 0, "v" ,
VK_W, 0, 0, "w" ,
VK_X, 0, 0, "x" ,
VK_Y, 0, 0, "y" ,
VK_Z, 0, 0, "z" ,
VK_BACKSPACE, 0,0, "\b" ,
VK_RETURN, 0,0, "\n" ,
0, 0, 0, "\0"
};
void nl(void)
{
console_cursor_xpos = 0;
console_cursor_ypos++;
}
struct CDROM_VolumeDescriptor
{
unsigned char type;
char ident[5];
unsigned char version;
char desc_type[2041];
} CD_VolumeDescriptor;
struct CDROM_BootRecord
{
unsigned char type;
char ident[5];
unsigned char version;
char sys_ident[32];
char boot_ident[32];
char boot_res[2048-64-7];
} CD_BootRecord;
struct CDROM_VolumeDescriptorSetTerminator
{
unsigned char type;
char ident[5];
unsigned char version;
char desc_type[2041];
} CD_VolumeSetTerminator;
struct CDROM_PrimaryVolumeDescriptor {
unsigned char type;
char ident[5];
unsigned char version;
unsigned char unused_field_1;
char sys_ident[32];
char vol_ident[32];
char unused_field_2[8];
int vol_space_size;
char unused_field_3[32];
int vol_set_size;
int vol_seq_number;
int log_block_size;
int path_table_size;
int location_L_path_table;
int location_L_path_table_optional;
int location_M_path_table;
int location_M_path_table_optional;
char root_directory_record[34];
char volume_set_ident[128];
char publisher_ident[128];
char data_preparer_ident[128];
char application_ident[128];
char copyright_ident[37];
char abstract_file_ident[37];
char bib_file_ident[37];
char volume_creation_date_time[17];
char volume_modification_date_time[17];
char volume_expiration_date_time[17];
char volume_effective_date_time[17];
int file_structure_version;
int reserved_byte;
char application_use[512];
char reserved[653];
} CD_PrimaryVolume;
struct CDROM_VolumeTerminator {
int type;
char ident[5];
} CD_VolumeTerminator;
struct disk_packet
{
byte size_pack;
byte reserved1;
byte no_of_blocks;
byte reserved2;
word offset;
word segment;
dword lba1;
dword lba2;
} disk_pack;
void LBASectorRead(void *buffer, unsigned long lba)
{
unsigned char bError = 0;
REGS regs;
disk_pack.size_pack = 16;
disk_pack.no_of_blocks = 1;
disk_pack.reserved1 = 0;
disk_pack.reserved2 = 0;
disk_pack.segment = (((unsigned int)buffer >> 16) << 12);
disk_pack.offset = ((unsigned int)buffer & 0xffff);
disk_pack.lba2 = lba >> 32;
disk_pack.lba1 = lba & 0xffffffff;
regs.b.ds = (((unsigned int)&disk_pack >> 16) << 12);
regs.b.si = ((unsigned int)&disk_pack &0xffff);
regs.b.dl = 0x9f;
regs.b.ah = 0x42;
int386(0x13,®s,®s);
//printf("Error: %d\n",regs.b.ah);
}
int testint_flag = 0;
extern void testsector(void);
void BootMain(char *cmd)
{
REGS regs;
int i,c,k, pos = 0;
char line[1024];
short sx = 0,sy=15;
//VideoClearScreen(0);
printf("kaBOX Version 0.1 (c) 2005 Jens Kallup"); nl();
printf("BETA-Version!"); nl(); nl();
if (InitializeMemoryManager() == 0) {
printf("Drücken Sie eine Taste zum Neustart des Computers."); nl();
ConsoleGetChar();
VideoClearScreen(0);
return;
}
//RunLoader();
nl();
//printf("1. --> %d\n", testint_flag);
//int386(0x21,®s,®s);
//printf("2. --> %d\n", testint_flag);
nl(); // printf("ret from int 21"); nl();
console_cursor_ypos = 15;
{
//static unsigned char buffer[2048] = { 0 };
//LBASectorRead(buffer,16);
LBASectorRead(&CD_VolumeDescriptor,16);
CD_VolumeDescriptor.ident[5] = '\0';
printf(CD_VolumeDescriptor.ident);
nl();
if (CD_VolumeDescriptor.version == 0)
printf("CDVD: Boot Record.");
nl();
LBASectorRead(&CD_BootRecord,17);
CD_BootRecord.ident[5] = '\0';
printf(CD_BootRecord.ident); nl();
printf(CD_BootRecord.sys_ident); nl();
printf(CD_BootRecord.boot_ident); nl();
LBASectorRead(&CD_VolumeSetTerminator,18);
CD_VolumeTerminator.ident[5] = '\0';
printf(CD_BootRecord.ident); nl();
printf("-----------"); nl();
LBASectorRead(&CD_PrimaryVolume,19);
CD_PrimaryVolume.ident[5] = '\0';
printf(CD_PrimaryVolume.ident); nl();
LBASectorRead(&CD_VolumeTerminator,20);
CD_VolumeTerminator.ident[5] = '\0';
printf(CD_VolumeTerminator.ident); nl();
}
nl();
//printf("System erfolgreich geladen, bereit fuer Eingabe(n):>");
nl(); nl();
for (;;)
{
anfang:
c = ConsoleGetChar();
if ((c == VK_W)) {
printf("ein w\n");
//int i = 0;
//int a = 2 / i;
printf("--> %d\n",c);
}
sx = console_cursor_xpos;
sy = console_cursor_ypos;
VideoGotoXY(50, 0); printf(" ");
VideoGotoXY(50, 0); printf("kcode: 0x%5x",c);
VideoGotoXY(sx,sy);
if (c == VK_BACKSPACE)
{
console_cursor_xpos--;
if (console_cursor_xpos <= -1) {
console_cursor_xpos = 79;
console_cursor_ypos--;
}
if (console_cursor_ypos <= 0) {
console_cursor_xpos = 0;
console_cursor_ypos = 0;
}
VideoPutChar('_',console_color_attribut,console_cursor_xpos, console_cursor_ypos);
VideoPutChar(' ',console_color_attribut,console_cursor_xpos+1, console_cursor_ypos);
VideoGotoXY(console_cursor_xpos,console_cursor_ypos);
goto anfang;
}
else if (c == VK_RETURN) {
VideoGotoXY(0,++console_cursor_ypos);
printf(":>_");
VideoGotoXY(--console_cursor_xpos,console_cursor_ypos);
goto anfang;
}
for (i = 0; i < sizeof(GERMAN_KEYBOARD_STRUCT); i++)
{
if (GERMAN_KEYBOARD_STRUCT[i].keycode == c) {
printf("%s",GERMAN_KEYBOARD_STRUCT[i].consolecode);
VideoPutChar('_',console_color_attribut,console_cursor_xpos, console_cursor_ypos);
}
}
}
}
/*
* Print only supports a-z and 0-9 and other keyboard characters
*/
void print(char *msg, unsigned int line)
{
char *vidmem = (char *)0xB8000;
unsigned int i = line*80*2, color = 0x07;
while(*msg != 0)
{
vidmem[i] = *msg;
i++;
vidmem[i] = color;
i++;
*msg++;
}
}
void testint(void)
{
print("TEST INT CALLED\n\n",10);
}
irgendwas stimmt da noch nicht mit den sectors.