struct sysinfo_t
{
unsigned long mem;
unsigned long lower_mem;
char init[30];
}
struct mod_info
{
char *mod_start;
char *mod_end;
char *string;
unsigned long reserved;
}
struct mmap_section
{
/* unsigned long base_addr_low;
unsigned long base_addr_high;
unsigned long length_low;
unsigned long length_high; */
/* I'm pretty sure these are equivilant */
unsigned long long base_addr;
unsigned long long length;
unsigned long type;
}
struct drive_info
{
unsigned long size;
unsigned char drive_number;
unsigned char drive_mode;
unsigned short drive_cylinders;
unsigned char drive_heads;
unsigned char drive_sectors;
/* There is also a drive_ports field -- see multiboot manual */
}
struct multiboot_info
{
unsigned long flags;
unsigned long mem_lower;
unsigned long mem_upper;
unsigned long boot_device;
char *cmdline;
unsigned long mods_count;
struct mod_info *mods_addr;
unsigned long elf_shdr_num;
unsigned long elf_shdr_size;
unsigned long elf_shdr_addr;
unsigned long elf_shdr_shndx;
unsigned long mmap_length;
struct mmap_section *mmap_addr;
unsigned long drives_length;
struct drive_info *drives_addr;
unsigned long config_table;
char *boot_loader_name;
unsigned long apm_table;
unsigned long vbe_control_info;
unsigned long vbe_mode_info;
unsigned long vbe_mode;
unsigned long vbe_interface_seg;
unsigned long vbe_interface_off;
unsigned long vbe_interface_len;
}
void start(unsigned long magic, struct multiboot_info *mb_info)
{
struct sysinfo_t sysinfo;
boot_printf(0x0F, "Starting kryptOS 0.01...\n\n");
boot_printf(0x0C, "Boot loader: %c", mb_info->boot_loader_name);
parse_command_line(mb_info->cmdline, &sysinfo);
}
int boot_printf(unsigned char color, const char *format, ...)
{
}
void parse_command_line(char *cmdline, struct sysinfo_t *sysinfo)
{
char *result;
while (*cmdline != 0)
{
if (result = check_argument(cmdline, "init")) /* Returns pointer to part of cmdline */
{
sysinfo->init = check_argument_init(result);
skip_argument(&cmdline);
continue;
}
skip_argument(&cmdline);
}
}
void skip_argument(char **cmdline)
{
while (**cmdline != 0 && **cmdline != ',') /* First skip all characters to the next comma */
*cmdline++; /* or to the end of the string */
if (**cmdline != 0) /* If we didn't go to the end of the string */
{ /* Then skip all the space after the comma */
while (**cmdline != ' ')
*cmdline++;
}
}
char *check_argument(char *cmdline, char *test_argument)
{
while (*cmdline == *test_argument && *cmdline != 0 && *test_argument != 0)
{ cmdline++; test_argument++; }
if (*test_argument == 0)
{
while (*cmdline == ' ')
{ cmdline++; }
if (*cmdline == '=')
{
cmdline++;
while (*cmdline == ' ')
{ cmdline++; }
return cmdline;
} else {
return (char *)0;
}
} else {
return (char *)0;
}
}
char *check_argument_init(register char *value)
{
char init[30];
unsigned register int i;
for (i = 0; i < 30; i++)
{
init[i] = *value++;
if (init[i] == 0)
{
break;
}
if (init[i] == ',') {
i--;
while (init[i] == ' ')
{ i--; }
init[i+1] = 0;
break;
}
}
return init;
}