Add: userland hello world code
This commit is contained in:
		
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							| @@ -11,8 +11,8 @@ install: | |||||||
|  |  | ||||||
| bin: | bin: | ||||||
| 	$(MAKE) -C $(LIB) | 	$(MAKE) -C $(LIB) | ||||||
| 	gcc -c test.c -Ilibk -Llibk -lk -m32 | 	gcc -c ./app/$(APP).c -Ilibk -Llibk -lk -m32 | ||||||
| 	ld -m elf_i386 -Ttext=0x6000000 --entry=main test.o -L./libk/ -lk | 	ld -m elf_i386 -Ttext=0x6000000 --entry=main ./$(APP).o -L./libk/ -lk | ||||||
| 	objcopy --input binary --output elf32-i386 --binary-architecture i386 --rename-section .data=.rodata,CONTENTS,ALLOC,LOAD,READONLY,DATA a.out myfile.o | 	objcopy --input binary --output elf32-i386 --binary-architecture i386 --rename-section .data=.rodata,CONTENTS,ALLOC,LOAD,READONLY,DATA a.out myfile.o | ||||||
| 	cp myfile.o $(SOURCEDIR)/myfile.o | 	cp myfile.o $(SOURCEDIR)/myfile.o | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,3 +5,4 @@ GRUBDIR = iso | |||||||
| SOURCEDIR = src | SOURCEDIR = src | ||||||
| TARGET = kernel | TARGET = kernel | ||||||
| LIB=libk | LIB=libk | ||||||
|  | APP=hello_world | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								app/hello_world.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								app/hello_world.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | #include <syscall.h> | ||||||
|  |  | ||||||
|  | static char s[] = "Hello from userland!\n"; | ||||||
|  |  | ||||||
|  | int main(void) | ||||||
|  | { | ||||||
|  |     write(1, s, 21); | ||||||
|  |     while (1); | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user