Stop building binaries out of loader/

This is what userspace/ is for; consequentally, all userspace
applications now depend on the full toolchain and will build using the C
library.
This commit is contained in:
Kevin Lange 2012-01-28 16:19:57 -06:00
parent 023f506960
commit c65e458c50
7 changed files with 38 additions and 90 deletions

View File

@ -23,7 +23,6 @@ REALEMU = $(patsubst %.c,%.o,$(wildcard kernel/v8086/*.c))
SUBMODULES = ${MODULES} ${FILESYSTEMS} ${VIDEODRIVERS} ${DEVICES} ${VIRTUALMEM} ${MISCMODS} ${SYSTEM} ${DATASTRUCTS} ${CPUBITS} ${REALEMU}
BINARIES = hdd/bin/hello hdd/bin/echo hdd/bin/yes hdd/bin/sh
UTILITIES = util/bin/readelf util/bin/typewriter
EMU = qemu
GENEXT = genext2fs
@ -131,7 +130,7 @@ initrd/boot/kernel: toaruos-kernel
hdd:
@mkdir hdd
toaruos-disk.img: hdd hdd/bs.bmp ${BINARIES}
toaruos-disk.img: hdd hdd/bs.bmp
@${BEG} "hdd" "Generating a Hard Disk image..."
@-rm -f toaruos-disk.img
@${GENEXT} -d hdd -q -b 131072 -N 4096 toaruos-disk.img ${ERRORS}

View File

@ -1,13 +0,0 @@
#include <syscall.h>
int main(int argc, char ** argv) {
char * str = "Hello world!\n";
syscall_write(1 /* stdout */, str, 13);
return 0;
}
/*
* vim:tabstop=4
* vim:noexpandtab
* vim:shiftwidth=4
*/

View File

@ -1,30 +0,0 @@
#include <syscall.h>
int main(int argc, char ** argv) {
/* A Simple Shell */
syscall_print("My PID is ");
char x[] = {
'0' + syscall_getpid(),
0
};
syscall_print(x);
syscall_print("\n");
int i = syscall_getpid();
for (int j = 0; j < 5; ++j) {
syscall_fork();
if (syscall_getpid() != i) {
syscall_print("[Forked]\n");
char * bin = "/bin/echo";
char * args = "Executed echo.";
char * argv_[] = {
bin,
args,
0
};
syscall_execve(bin, argv_, 0);
} else {
syscall_print("(hello from parent)\n");
}
}
return 0;
}

View File

@ -1,19 +0,0 @@
#include <syscall.h>
int main(int argc, char ** argv) {
char * yes = "y";
if (argc > 1) {
yes = argv[1];
}
while (1) {
syscall_print(yes);
syscall_print("\n");
}
return 0;
}
/*
* vim:tabstop=4
* vim:noexpandtab
* vim:shiftwidth=4
*/

View File

@ -1,22 +1,13 @@
#include <syscall.h>
/* I really need a standard library */
int
strlen(
const char *str
) {
int i = 0;
while (str[i] != (char)0) {
++i;
}
return i;
}
/* vim: tabstop=4 shiftwidth=4 noexpandtab
*
* echo
*/
#include <stdio.h>
void usage() {
char * str ="echo [-n] [-e] [STRING]...\n"
" -n do not output a new line at the end\n"
" -e process escape sequences\n";
syscall_write(1, str, strlen(str));
printf("echo [-n] [-e] [STRING]...\n"
" -n do not output a new line at the end\n"
" -e process escape sequences\n");
}
int main(int argc, char ** argv) {
@ -59,20 +50,14 @@ int main(int argc, char ** argv) {
}
}
}
syscall_write(1, argv[i], strlen(argv[1]));
printf("%s",argv[i]);
if (i != argc - 1) {
syscall_write(1, " ", 1);
printf(" ");
}
}
if (use_newline) {
syscall_write(1, "\n", 1);
printf("\n");
}
return 0;
}
/*
* vim:tabstop=4
* vim:noexpandtab
* vim:shiftwidth=4
*/

10
userspace/hello.c Normal file
View File

@ -0,0 +1,10 @@
/* vim:tabstop=4 shiftwidth=4 noexpandtab
*
* Hello World!
*/
#include <stdio.h>
int main(int argc, char ** argv) {
printf("Hello World!\n");
return 0;
}

16
userspace/yes.c Normal file
View File

@ -0,0 +1,16 @@
/* vim: tabstop=4 shiftwidth=4 noexpandtab
*
* yes
*/
#include <stdio.h>
int main(int argc, char * argv[]) {
char * yes_string = "y";
if (argc > 1) {
yes_string = argv[1];
}
while (1) {
printf("%s\n", yes_string);
}
return 0;
}