[sys] And now for the user side too

This commit is contained in:
Kevin Lange 2011-04-11 16:51:31 -05:00
parent 3b12812608
commit 06c41369cc
5 changed files with 29 additions and 17 deletions

View File

@ -117,7 +117,7 @@ loader/crtbegin.o: loader/crtbegin.s
@${YASM} -f elf32 -o $@ $<
@${ECHO} "\r\033[32;1m yasm $<\033[0m"
initrd/bin/%: loader/%.o loader/crtbegin.o
initrd/bin/%: loader/%.o loader/crtbegin.o loader/syscall.o
@${ECHO} -n "\033[32m LD $<\033[0m"
@${LD} -T loader/link.ld -o $@ $<
@${ECHO} "\r\033[32;1m LD $<\033[0m"

View File

@ -1,16 +1,18 @@
int syscall_print(const char * p1) {
int a = 0xA5ADFACE;
__asm__ __volatile__("int $0x7F" : "=a" (a) : "0" (1), "b" ((int)p1));
return a;
}
#include <syscall.h>
int main(int argc, char ** argv) {
for (int i = 1; i < argc; ++i) {
syscall_print(argv[i]);
if (i != argc - 1) {
syscall_print(" ");
for (int i = 1; i < argc; ++i) {
syscall_print(argv[i]);
if (i != argc - 1) {
syscall_print(" ");
}
}
}
syscall_print("\n");
return 0;
syscall_print("\n");
return 0;
}
/*
* vim:tabstop=4
* vim:noexpandtab
* vim:shiftwidth=4
*/

View File

@ -5,6 +5,7 @@
OUTPUT_FORMAT(elf32-i386)
ENTRY(_start)
STARTUP(loader/crtbegin.o)
INPUT(loader/syscall.o)
phys = 0x02000000;
SECTIONS
{

5
loader/syscall.c Normal file
View File

@ -0,0 +1,5 @@
#include <syscall.h>
DEFN_SYSCALL1(exit, 0, int)
DEFN_SYSCALL1(print, 1, const char *)

View File

@ -1,8 +1,12 @@
#include <syscall.h>
DEFN_SYSCALL1(print, 1, const char *)
int main(int argc, char ** argv) {
syscall_print("Hello world!\n");
return 0;
syscall_print("Hello world!\n");
return 0;
}
/*
* vim:tabstop=4
* vim:noexpandtab
* vim:shiftwidth=4
*/