Added system fetcher and strcpy(string.h)
This commit is contained in:
parent
21f017f13c
commit
f13837f6f8
@ -58,6 +58,5 @@ void kernel_main() {
|
|||||||
PRTOK
|
PRTOK
|
||||||
printf(" - Heap works!");
|
printf(" - Heap works!");
|
||||||
|
|
||||||
iceos_ascii_logo();
|
|
||||||
init_prompt(); // Initialize frame buffer
|
init_prompt(); // Initialize frame buffer
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,13 @@ size_t strlen(const uint8_t *buf) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t *strcpy(uint8_t *dst, const uint8_t *src) {
|
||||||
|
uint8_t *dst_p = dst;
|
||||||
|
while((*dst++ = *src++));
|
||||||
|
|
||||||
|
return dst_p;
|
||||||
|
}
|
||||||
|
|
||||||
/* Worst memset implementation
|
/* Worst memset implementation
|
||||||
* i could find on the net.
|
* i could find on the net.
|
||||||
* however it works so... */
|
* however it works so... */
|
||||||
@ -122,4 +129,4 @@ void strlower(uint8_t *str) {
|
|||||||
if(str[i] == 'A' && str[i] < 'Z')
|
if(str[i] == 'A' && str[i] < 'Z')
|
||||||
str[i] |= 0x60;
|
str[i] |= 0x60;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ int32_t strcmp(const uint8_t *s1, const uint8_t *s2);
|
|||||||
uint8_t *itoa(int32_t val, uint8_t *buf, uint32_t radix);
|
uint8_t *itoa(int32_t val, uint8_t *buf, uint32_t radix);
|
||||||
uint8_t *uitoa(uint32_t val, uint8_t *buf, uint32_t radix);
|
uint8_t *uitoa(uint32_t val, uint8_t *buf, uint32_t radix);
|
||||||
size_t strlen(const uint8_t *buf);
|
size_t strlen(const uint8_t *buf);
|
||||||
|
uint8_t *strcpy(uint8_t *dst, const uint8_t *src);
|
||||||
void *memset(void *s, uint32_t c, size_t n);
|
void *memset(void *s, uint32_t c, size_t n);
|
||||||
void *memmove(void *dst, const void *src, size_t len);
|
void *memmove(void *dst, const void *src, size_t len);
|
||||||
void strupper(uint8_t *str);
|
void strupper(uint8_t *str);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
OBJS = shell.o
|
OBJS = shell.o fetch.o
|
||||||
|
|
||||||
CC = i686-elf-gcc # cross-compiler
|
CC = i686-elf-gcc # cross-compiler
|
||||||
CFLAGS = -m32 -fno-stack-protector -ffreestanding -Wall -Wextra -Werror -g -c
|
CFLAGS = -DDEFAULT_USER=root -DDEFAULT_HOSTNAME=vulcan -m32 -fno-stack-protector -ffreestanding -Wall -Wextra -Werror -g -c
|
||||||
|
|
||||||
|
|
||||||
all:${OBJS}
|
all:${OBJS}
|
||||||
|
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) $(CFLAGS) $< -o $@
|
$(CC) $(CFLAGS) $< -o $@
|
||||||
|
34
kernel/userspace/fetch.c
Normal file
34
kernel/userspace/fetch.c
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "fetch.h"
|
||||||
|
#include "../libc/stdio.h"
|
||||||
|
#include "../libc/string.h"
|
||||||
|
#include "../libc/time.h"
|
||||||
|
#include "../drivers/tty.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void system_fetcher() {
|
||||||
|
/*uint8_t *logo = (uint8_t*)" \n \
|
||||||
|
__ __ ___ ___ \n \
|
||||||
|
\\ \\ / / / _ \\/ __| \n \
|
||||||
|
\\ V / | (_) \\__ \\ \n \
|
||||||
|
\\_/ \\___/|___/";*/
|
||||||
|
|
||||||
|
uint8_t user[64], hostname[64];
|
||||||
|
#define STRINGIZE(x) #x
|
||||||
|
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
|
||||||
|
#ifdef DEFAULT_USER
|
||||||
|
strcpy(user, (uint8_t*)STRINGIZE_VALUE_OF(DEFAULT_USER));
|
||||||
|
#else
|
||||||
|
#error "-DDEFAULT_USER flag not set"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEFAULT_HOSTNAME
|
||||||
|
strcpy(hostname, (uint8_t*)STRINGIZE_VALUE_OF(DEFAULT_HOSTNAME));
|
||||||
|
#else
|
||||||
|
#error "-DDEFAULT_HOSTNAME flag not set"
|
||||||
|
#endif
|
||||||
|
printf_color("\n__ __ ___ ___ ", LIGHT_RED, BLACK);
|
||||||
|
printf_color((char*)user, LIGHT_CYAN, BLACK);
|
||||||
|
printf_color("@", LIGHT_RED, BLACK);
|
||||||
|
printf_color((char*)hostname, LIGHT_CYAN, BLACK);
|
||||||
|
}
|
15
kernel/userspace/fetch.h
Normal file
15
kernel/userspace/fetch.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**************************************
|
||||||
|
* VulcanOS Kernel *
|
||||||
|
* Developed by Marco 'icebit' Cetica *
|
||||||
|
* (c) 2019-2021 *
|
||||||
|
* Released under GPLv3 *
|
||||||
|
* https://github.com/ice-bit/iceOS *
|
||||||
|
***************************************/
|
||||||
|
#ifndef FETCH_H
|
||||||
|
#define FETCH_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void system_fetcher();
|
||||||
|
|
||||||
|
#endif
|
@ -1,4 +1,5 @@
|
|||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
#include "fetch.h"
|
||||||
#include "../libc/string.h"
|
#include "../libc/string.h"
|
||||||
#include "../libc/stdio.h"
|
#include "../libc/stdio.h"
|
||||||
#include "../drivers/tty.h"
|
#include "../drivers/tty.h"
|
||||||
@ -110,20 +111,10 @@ void processCommand(uint8_t *cmd) {
|
|||||||
register_dump();
|
register_dump();
|
||||||
else if(strcmp(cmd, (uint8_t*)"timer") == 0)
|
else if(strcmp(cmd, (uint8_t*)"timer") == 0)
|
||||||
timer_dump();
|
timer_dump();
|
||||||
else if(strcmp(cmd, (uint8_t*)"banner") == 0)
|
else if(strcmp(cmd, (uint8_t*)"fetch") == 0)
|
||||||
iceos_ascii_logo();
|
system_fetcher();
|
||||||
else if(strcmp(cmd, (uint8_t*)"reboot") == 0)
|
else if(strcmp(cmd, (uint8_t*)"reboot") == 0)
|
||||||
reboot();
|
reboot();
|
||||||
else
|
else
|
||||||
puts("\nCommand not found!");
|
puts("\nCommand not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void iceos_ascii_logo() {
|
|
||||||
printf_color("\n\n"
|
|
||||||
"###################################################\n#",
|
|
||||||
LIGHT_BLUE, BLACK);
|
|
||||||
printf_color(" iceOS - developed by Marco Cetica (c) 2019-2020 ",
|
|
||||||
LIGHT_MAGENTA, BLACK);
|
|
||||||
printf_color("#\n###################################################\n",
|
|
||||||
LIGHT_BLUE, BLACK);
|
|
||||||
}
|
|
||||||
|
@ -15,6 +15,5 @@
|
|||||||
|
|
||||||
void helper();
|
void helper();
|
||||||
void processCommand(uint8_t *cmd);
|
void processCommand(uint8_t *cmd);
|
||||||
void iceos_ascii_logo();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user