2011-03-26 21:30:08 +03:00
|
|
|
/*
|
|
|
|
* Kernel Argument Parser
|
2011-04-15 05:36:51 +04:00
|
|
|
*
|
|
|
|
* Parses arguments passed by, ie, a Multiboot bootloader.
|
|
|
|
*
|
|
|
|
* Part of the ToAruOS Kernel.
|
|
|
|
* (C) 2011 Kevin Lange
|
2011-03-26 21:30:08 +03:00
|
|
|
*/
|
|
|
|
#include <system.h>
|
|
|
|
|
2011-04-15 05:36:51 +04:00
|
|
|
/**
|
|
|
|
* Parse the given arguments to the kernel.
|
|
|
|
*
|
|
|
|
* @param arg A string containing all arguments, separated by spaces.
|
|
|
|
*/
|
2011-03-26 21:30:08 +03:00
|
|
|
void
|
2011-04-15 05:36:51 +04:00
|
|
|
parse_args(
|
|
|
|
char * arg /* Arguments */
|
|
|
|
) {
|
|
|
|
/* Sanity check... */
|
2011-03-29 05:34:53 +04:00
|
|
|
if (!arg) { return; }
|
2011-04-15 05:36:51 +04:00
|
|
|
char * pch; /* Tokenizer pointer */
|
|
|
|
char * save; /* We use the reentrant form of strtok */
|
|
|
|
char * argv[1024]; /* Command tokens (space-separated elements) */
|
|
|
|
int tokenid = 0; /* argc, basically */
|
|
|
|
|
|
|
|
/* Tokenize the arguments, splitting at spaces */
|
2011-03-26 21:30:08 +03:00
|
|
|
pch = strtok_r(arg," ",&save);
|
2011-04-15 05:36:51 +04:00
|
|
|
if (!pch) { return; }
|
2011-03-26 21:30:08 +03:00
|
|
|
while (pch != NULL) {
|
|
|
|
argv[tokenid] = (char *)pch;
|
|
|
|
++tokenid;
|
|
|
|
pch = strtok_r(NULL," ",&save);
|
|
|
|
}
|
|
|
|
argv[tokenid] = NULL;
|
2011-04-15 05:36:51 +04:00
|
|
|
/* Tokens are now stored in argv. */
|
|
|
|
|
|
|
|
|
2011-03-26 21:30:08 +03:00
|
|
|
for (int i = 0; i < tokenid; ++i) {
|
2011-04-15 05:36:51 +04:00
|
|
|
/* Parse each provided argument */
|
|
|
|
|
2011-03-26 21:30:08 +03:00
|
|
|
if (!strcmp(argv[i],"vid=qemu")) {
|
2011-04-15 05:36:51 +04:00
|
|
|
/* Bochs / Qemu Video Device */
|
2011-03-26 21:30:08 +03:00
|
|
|
graphics_install_bochs();
|
2011-04-06 04:12:08 +04:00
|
|
|
ansi_init(&bochs_write, 128, 64);
|
2011-03-26 21:30:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-15 05:36:51 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* vim:tabstop=4
|
|
|
|
* vim:noexpandtab
|
|
|
|
*/
|