Skip to content

Commit

Permalink
Add welcome page
Browse files Browse the repository at this point in the history
  • Loading branch information
konect-V committed Aug 12, 2024
1 parent 5691b43 commit a7d9c1c
Show file tree
Hide file tree
Showing 16 changed files with 876 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@
"stdlib.h": "c",
"update.h": "c",
"launch.h": "c",
"untar.h": "c"
"untar.h": "c",
"ft2build.h": "c"
},
"files.exclude": {
"bundled": true,
Expand Down
1 change: 1 addition & 0 deletions Bundled/freetype
Submodule freetype added at 3f83da
2 changes: 2 additions & 0 deletions bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ declare_options:
default: "amd64"
- name: "boot_name"
default: "limine"
- name: "ar"
default: "x86_64-kot-ar"
- name: "cc"
default: "x86_64-kot-gcc"
- name: "cxx"
Expand Down
27 changes: 27 additions & 0 deletions bootstrap/sys-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ packages:
- '-r'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: kot
source:
subdir: 'sources/core/apps'
Expand All @@ -45,6 +46,7 @@ packages:
- '-r'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: bash
source:
git: 'https://github.com/bminor/bash'
Expand Down Expand Up @@ -412,6 +414,31 @@ packages:
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: welcome
source:
subdir: 'sources/core/apps'
tools_required:
- host-gcc
pkgs_required:
- mlibc
- freetype
build:
- args:
- 'make'
- '-C'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@'
- 'build'
environ:
CC: "@OPTION:cc@"
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
- args:
- 'cp'
- '-r'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@/bin/.'
- '@SOURCE_ROOT@/target/boot_disk_kot_mount/.'

- name: bash
source:
git: 'https://github.com/bminor/bash'
Expand Down
123 changes: 98 additions & 25 deletions bootstrap/sys-libs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,34 +164,107 @@ packages:
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
build:
- args: ['make', '-j@PARALLELISM@']
- args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install']

- name: zlib
source:
subdir: 'bundled'
git: 'https://github.com/madler/zlib'
tag: 'v1.3.1'
version: '1.3.1'
tools_required:
- host-gcc
pkgs_required:
- mlibc
revision: 4
configure:
- args:
- 'cmake'
- '@THIS_SOURCE_DIR@'
- '-DCMAKE_INSTALL_PREFIX=/usr'
- '-DBUILD_SHARED_LIBS=Off'
environ:
CC: "@OPTION:cc@"
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
build:
- args: ['make', '-j@PARALLELISM@']
- args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install']

- name: libpng
source:
subdir: 'bundled'
git: 'https://github.com/winlibs/libpng'
tag: 'libpng-1.6.34'
version: '1.6.34'
tools_required:
- host-gcc
pkgs_required:
- mlibc
- zlib
revision: 4
configure:
- args:
- 'cmake'
- '@THIS_SOURCE_DIR@'
- '-DCMAKE_INSTALL_PREFIX=/usr'
- '-DBUILD_SHARED_LIBS=Off'
environ:
CC: "@OPTION:cc@"
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
build:
- args: ['make', '-j@PARALLELISM@']
- args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install']

# - name: libarchive
# source:
# subdir: 'bundled'
# git: 'https://github.com/libarchive/libarchive'
# tag: 'v3.7.4'
# version: '3.7.4'
# tools_required:
# - host-gcc
# pkgs_required:
# - mlibc
# revision: 4
# configure:
# - args:
# - 'cmake'
# - '@THIS_SOURCE_DIR@'
# - '-DCMAKE_INSTALL_PREFIX=/usr'
# - '-DBUILD_SHARED_LIBS=Off'
# environ:
# CC: "@OPTION:cc@"
# CXX: "@OPTION:cxx@"
# LD: "@OPTION:ld@"
# ASMC: "@OPTION:asmc@"
- name: freetype
source:
git: 'https://github.com/freetype/freetype'
subdir: 'Bundled'
tag: 'VER-2-11-1'
version: '2.11.1'
pkgs_required:
- mlibc
tools_required:
- host-gcc
configure:
- args:
- 'cmake'
- '@THIS_SOURCE_DIR@'
- '-DCMAKE_INSTALL_PREFIX=/usr'
- '-DBUILD_SHARED_LIBS=Off'
environ:
CC: "@OPTION:cc@"
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
build:
- args: ['make', '-j@PARALLELISM@']
- args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install']

# build:
# - args: ['make', '-j@PARALLELISM@']
# - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install']
- name: kot-graphics
source:
subdir: 'sources/core/libs'
tools_required:
- host-gcc
pkgs_required:
- mlibc
- freetype
build:
- args:
- 'make'
- 'DESTDIR=@THIS_COLLECT_DIR@'
- 'PREFIX=/usr'
- '-C'
- '@THIS_SOURCE_DIR@/target/@OPTION:arch_name@'
- 'build'
environ:
AR: "@OPTION:ar@"
CC: "@OPTION:cc@"
CXX: "@OPTION:cxx@"
LD: "@OPTION:ld@"
ASMC: "@OPTION:asmc@"
Binary file added sources/core/apps/welcome/res/welcome.ttf
Binary file not shown.
92 changes: 92 additions & 0 deletions sources/core/apps/welcome/source/core/core.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#include <fcntl.h>
#include <stdio.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>

#include <stdbool.h>

#include <linux/fb.h>
#include <sys/time.h>
#include <sys/ioctl.h>

#include <kot-graphics/font.h>
#include <kot-graphics/utils.h>

kfont_t font;

int fb_fd = -1;
kframebuffer_t fb;
struct fb_fix_screeninfo fix_screeninfo;
struct fb_var_screeninfo var_screeninfo;


void draw_frame(){
write(fb_fd, fb.buffer, fb.size);
}


int main(int argc, char* argv[]){
fb_fd = open("/dev/fb0", O_RDWR);

assert(fb_fd >= 0);


assert(ioctl(fb_fd, FBIOGET_FSCREENINFO, &fix_screeninfo) == 0);
assert(ioctl(fb_fd, FBIOGET_VSCREENINFO, &var_screeninfo) == 0);

if(
fix_screeninfo.visual == FB_VISUAL_TRUECOLOR &&
var_screeninfo.bits_per_pixel == 32 &&
var_screeninfo.red.length == 8 && var_screeninfo.red.msb_right == 0 &&
var_screeninfo.green.length == 8 && var_screeninfo.green.msb_right == 0 &&
var_screeninfo.blue.length == 8 && var_screeninfo.blue.msb_right == 0
){
fb.bpp = var_screeninfo.bits_per_pixel;
fb.btpp = fb.bpp / 8;
fb.size = var_screeninfo.xres_virtual * var_screeninfo.yres_virtual * fb.btpp;
fb.width = var_screeninfo.xres_virtual;
fb.pitch = fb.width * fb.btpp;
fb.height = var_screeninfo.yres_virtual;
fb.buffer = malloc(fb.size);
memset(fb.buffer, 0, fb.size);
}else{
perror("'/dev/fb0' : format not supported\n");
return EXIT_FAILURE;
}

FILE* font_file = fopen("/usr/bin/res/welcome/welcome.ttf", "rb");

if(font_file == NULL){
perror("error loading font\n");
return EXIT_FAILURE;
}

fseek(font_file, 0, SEEK_END);
size_t font_file_size = ftell(font_file);
fseek(font_file, 0, SEEK_SET);

void* font_data = malloc(font_file_size);
fread(font_data, font_file_size, 1, font_file);

font = load_font(font_data, font_file_size);

fclose(font_file);

load_pen(font, &fb, 0, 0, 64, 0, 0xffffff);
draw_font(font, "Welcome to Kot");

load_pen(font, &fb, 0, 0, 24, 0, 0xffffff);
write_paragraph(font, 0, get_line_height(font) * 2 + 20, 500, PARAGRAPH_JUSTIFY, "Kot is nothing more than an Operating System running on x86-64. And you already know that, but we're making to turn Kot more than just something.");

draw_frame();

while(true){
sleep(1);
}

return EXIT_SUCCESS;
}
2 changes: 2 additions & 0 deletions sources/core/apps/welcome/target/amd64/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/bin
**/lib
43 changes: 43 additions & 0 deletions sources/core/apps/welcome/target/amd64/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cyan = /bin/echo -e "\x1b[36m\#\# $1\x1b[0m"

# Project Root
override HOME = ../..

# Project Resources
SYSROOT = $(HOME)/../../../../sysroot
INCLUDE = $(SYSROOT)/usr/include
LIBRARIES = $(SYSROOT)/usr/lib
SOURCE = $(HOME)/source
TOOLS = $(HOME)/../../tools
BIN = bin/usr/bin
LIB = lib

# Tools Config
CFLAGS = -Werror

LDFLAGS = -Wall \
-lc

# Recursive Wild Card
rwildcard = $(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))

# Source Files
C_SRC = $(call rwildcard,$(SOURCE),*.c)

OBJS = $(patsubst $(SOURCE)/%.c,$(LIB)/%_c.o,$(C_SRC))

# Target
$(LIB)/%_c.o: $(SOURCE)/%.c
@ mkdir -m 777 -p $(@D)
@ $(call cyan,"$(subst ../,,$^)")
@ $(CC) $(CFLAGS) -c $^ -o $@

link:
@ mkdir -m 777 -p $(BIN)
@ $(CC) $(LDFLAGS) -o $(BIN)/welcome $(OBJS) $(LIBRARIES)/libkot-graphics.a $(LIBRARIES)/libfreetype.a

copy_res:
@ mkdir -m 777 -p $(BIN)/res/welcome
@ cp -r $(HOME)/res/. $(BIN)/res/welcome

build: $(OBJS) link copy_res
Loading

0 comments on commit a7d9c1c

Please sign in to comment.