Created lib file structure

This commit is contained in:
lucic71 2020-06-22 14:21:12 +03:00
parent 8e1a5c3af8
commit 18e81420e5
3 changed files with 110 additions and 0 deletions

41
lib/Makefile Normal file
View File

@ -0,0 +1,41 @@
# Stand-alone directories present in lib/.
SO_DIR := so/
INC_DIR := include/
# Directories containing actual code for libraries.
LIB_DIR = $(wildcard */)
LIB_DIR := $(filter-out $(SO_DIR), $(LIB_DIR))
LIB_DIR := $(filter-out $(INC_DIR), $(LIB_DIR))
# Library objects.
LIB_OBJ = $(foreach TMP, $(LIB_DIR), $(wildcard $(TMP)/lobj/*))
# Name of the resulted shared object.
SO := libklib.a
# Archiver
AR = ar
ARFLAGS = rcs
all: rbuild
$(AR) $(ARFLAGS) $(SO_DIR)/$(SO) $(LIB_OBJ)
# Build all libraries recursively.
rbuild:
for dir in $(LIB_DIR); do \
$(MAKE) -C $$dir; \
done
# Clean all libraries recursively.
clean:
for dir in $(LIB_DIR); do \
$(MAKE) -C $$dir clean; \
done
@$(RM) -rv $(SO_DIR)/$(SO)

6
lib/include/memio.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef IO_H_
#define IO_H_
void mio_out(unsigned short port, unsigned char data);
#endif

63
lib/include/vga.h Normal file
View File

@ -0,0 +1,63 @@
#ifndef VGA_H_
#define VGA_H_
/*
* Definition of an enum type that contains codes for each VGA color.
*
*/
enum vga_color {
VGA_COLOR_BLACK,
VGA_COLOR_BLUE,
VGA_COLOR_GREEN,
VGA_COLOR_CYAN,
VGA_COLOR_RED,
VGA_COLOR_MAGENTA,
VGA_COLOR_BROWN,
VGA_COLOR_LIGHT_GREY,
VGA_COLOR_DARK_GREY,
VGA_COLOR_LIGHT_BLUE,
VGA_COLOR_LIGHT_GREEN,
VGA_COLOR_LIGHT_CYAN,
VGA_COLOR_LIGHT_RED,
VGA_COLOR_LIGHT_MAGENTA,
VGA_COLOR_LIGHT_BROWN,
VGA_COLOR_WHITE,
};
/*
* Use the classic 80x25 mode for screen size.
*
*/
static const unsigned VGA_WIDTH = 80;
static const unsigned VGA_HEIGHT = 25;
/*
* vga_entry_color:
* Creates a VGA color encoding by combining foreground and background colors.
*
* @param fg - Foreground color
* @param bg - Background color
* @return - Combined encoding
*
*/
unsigned char vga_entry_color(enum vga_color fg, enum vga_color bg);
/*
* vga_entry:
* Creates a VGA entry from the character @c and the color associated with
* it, @color.
*
* @param c - Character
* @param color - Color of the character
* @return - VGA entry
*
*/
unsigned short vga_entry(unsigned char c, unsigned char color);
#endif