Added:
- TTY driver - VGA driver - kernel's main function - Makefiles *NOTE*: iceOS not works at this stage.
This commit is contained in:
10
kernel/libc/Makefile
Normal file
10
kernel/libc/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
OBJS = stdio.o string.o
|
||||
|
||||
CC = i686-elf-gcc # cross-compiler
|
||||
CFLAGS = -m32 -fno-stack-protector -ffreestanding -Wall -Wextra -Werror -g -c
|
||||
|
||||
|
||||
all:${OBJS}
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include "drivers/shell.h"
|
||||
|
||||
#include "../drivers/tty.h"
|
||||
|
||||
int printf(const char *format, ...) {
|
||||
char buf[20],c,*s;
|
||||
@@ -20,32 +19,36 @@ int printf(const char *format, ...) {
|
||||
case 'i':
|
||||
val = va_arg(ap, int);
|
||||
itoa(val, buf, 10);
|
||||
printk(buf);
|
||||
kprint(buf);
|
||||
break;
|
||||
case 'x':
|
||||
uval = va_arg(ap, uint32_t);
|
||||
uitoa(uval, buf, 16);
|
||||
printk(buf);
|
||||
kprint(buf);
|
||||
break;
|
||||
case 'd':
|
||||
uval = va_arg(ap, uint32_t);
|
||||
uitoa(uval, buf, 10);
|
||||
printk(buf);
|
||||
kprint(buf);
|
||||
break;
|
||||
case 'c':
|
||||
s = va_arg(ap, char*);
|
||||
printk_c(&c, 1);
|
||||
kprint_c(&c, 1, WHITE, BLACK);
|
||||
break;
|
||||
case 's':
|
||||
s = va_arg(ap, char*);
|
||||
printk(s);
|
||||
kprint(s);
|
||||
break;
|
||||
default:
|
||||
printk_c((char*)format+1, 1);
|
||||
kprint_c((char*)format+1, 1, WHITE, BLACK);
|
||||
}
|
||||
} else
|
||||
printk_c((char*)format+1, 1);
|
||||
kprint_c((char*)format+1, 1, WHITE, BLACK);
|
||||
}
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void puts(int8_t *buf) {
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
@@ -1,10 +1,19 @@
|
||||
/**************************************
|
||||
* iceOS Kernel *
|
||||
* Developed by Marco 'icebit' Cetica *
|
||||
* (c) 2019 *
|
||||
* Released under GPLv3 *
|
||||
* https://github.com/ice-bit/iceOS *
|
||||
***************************************/
|
||||
|
||||
#ifndef _STDIO_H_
|
||||
#define _STDIO_H
|
||||
#define _STDIO_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int printf(const char *format, ...);
|
||||
void puts(uint8_t *buf);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user