diff options
| author | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-25 06:56:01 +0100 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2023-02-25 08:45:09 +0100 |
| commit | 239900af293f192931391dc5579afab39a43e6c6 (patch) | |
| tree | 72d7f87ee6adf5aa84b78436197e03e61fba8d97 | |
| parent | aaa23fffd02fb49cdbc56a480dbb5a8fa95bff38 (diff) | |
clang-format
64 files changed, 1497 insertions, 1448 deletions
diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f45cb7d --- /dev/null +++ b/.clang-format @@ -0,0 +1,129 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# clang-format configuration file. Intended for clang-format >= 11. +# +# For more information, see: +# +# Documentation/process/clang-format.rst +# https://clang.llvm.org/docs/ClangFormat.html +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html +# +--- +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: false +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: false +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false + +# Taken from: +# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' kernel/include/ \ +# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ +# | LC_ALL=C sort -u +ForEachMacros: + - 'list_for_each' + - 'list_for_each_entry' + - 'list_for_each_entry_del' + - 'list_for_each_entry_prev' + +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentGotoLabels: false +IndentPPDirectives: None +IndentWidth: 8 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 8 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true + +# Taken from git's rules +PenaltyBreakAssignment: 10 +PenaltyBreakBeforeFirstCallParameter: 30 +PenaltyBreakComment: 10 +PenaltyBreakFirstLessLess: 0 +PenaltyBreakString: 10 +PenaltyExcessCharacter: 100 +PenaltyReturnTypeOnItsOwnLine: 60 + +PointerAlignment: Right +ReflowComments: false +SortIncludes: false +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatementsExceptForEachMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp03 +TabWidth: 8 +UseTab: Always +... diff --git a/kernel/include/atomic.h b/kernel/include/atomic.h index 6f59937..4b2ddb3 100644 --- a/kernel/include/atomic.h +++ b/kernel/include/atomic.h @@ -4,12 +4,11 @@ #include <types.h> struct mutex_t { - __volatile__ uint64_t* addr; + __volatile__ uint64_t *addr; }; typedef struct mutex_t mutex_t; - -void init_mutex(mutex_t* mutex); +void init_mutex(mutex_t *mutex); bool test_and_set(mutex_t mutex, bool value); void lock(mutex_t mutex); void unlock(mutex_t mutex); diff --git a/kernel/include/containter_of.h b/kernel/include/containter_of.h index 766847a..9cadd91 100644 --- a/kernel/include/containter_of.h +++ b/kernel/include/containter_of.h @@ -5,7 +5,7 @@ #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) -#define typeof_member(T, m) typeof(((T*)0)->m) +#define typeof_member(T, m) typeof(((T *)0)->m) /** * container_of - cast a member of a structure out to the containing structure @@ -14,12 +14,14 @@ * @member: the name of the member within the struct. * */ -#define container_of(ptr, type, member) ({ \ - void *__mptr = (void *)(ptr); \ - static_assert(__same_type(*(ptr), ((type *)0)->member) || \ - __same_type(*(ptr), void), \ - "pointer type mismatch in container_of()"); \ - ((type *)(__mptr - offsetof(type, member))); }) +#define container_of(ptr, type, member) \ + ({ \ + void *__mptr = (void *)(ptr); \ + static_assert(__same_type(*(ptr), ((type *)0)->member) || \ + __same_type(*(ptr), void), \ + "pointer type mismatch in container_of()"); \ + ((type *)(__mptr - offsetof(type, member))); \ + }) /** * container_of_safe - cast a member of a structure out to the containing structure @@ -29,12 +31,15 @@ * * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged. */ -#define container_of_safe(ptr, type, member) ({ \ - void *__mptr = (void *)(ptr); \ - static_assert(__same_type(*(ptr), ((type *)0)->member) || \ - __same_type(*(ptr), void), \ - "pointer type mismatch in container_of_safe()"); \ - IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \ - ((type *)(__mptr - offsetof(type, member))); }) +#define container_of_safe(ptr, type, member) \ + ({ \ + void *__mptr = (void *)(ptr); \ + static_assert(__same_type(*(ptr), ((type *)0)->member) || \ + __same_type(*(ptr), void), \ + "pointer type mismatch in container_of_safe()"); \ + IS_ERR_OR_NULL(__mptr) ? \ + ERR_CAST(__mptr) : \ + ((type *)(__mptr - offsetof(type, member))); \ + }) #endif diff --git a/kernel/include/disc.h b/kernel/include/disc.h index 7b4fd0b..e13d2fd 100644 --- a/kernel/include/disc.h +++ b/kernel/include/disc.h @@ -3,8 +3,6 @@ #include <types.h> -#include <libk/stdio.h> - #define SECTOR_SIZE 512 struct disc_sector_t { @@ -12,10 +10,10 @@ struct disc_sector_t { }; typedef struct disc_sector_t disc_sector_t; -extern disc_sector_t* disc; +extern disc_sector_t *disc; void disc_init(void); -void read_sector(size_t sector_num, disc_sector_t* disc_sector); -void write_sector(size_t sector_num, disc_sector_t* disc_sector); +void read_sector(size_t sector_num, disc_sector_t *disc_sector); +void write_sector(size_t sector_num, disc_sector_t *disc_sector); #endif diff --git a/kernel/include/ext2.h b/kernel/include/ext2.h index d6022a2..53c6b33 100644 --- a/kernel/include/ext2.h +++ b/kernel/include/ext2.h @@ -2,11 +2,10 @@ #define EXT2_H #include <types.h> - #include <libk/list.h> struct ext2_superblock_t { -// base fields + // base fields uint32_t inodes_count; uint32_t blocks_count; uint32_t superuser_blocks; @@ -32,7 +31,7 @@ struct ext2_superblock_t { uint32_t version_major; uint16_t superuser_id; uint16_t supergroup_id; -// extended fields + // extended fields uint32_t first_inode; uint16_t inode_size; uint16_t superblock_group; @@ -90,13 +89,13 @@ struct ext2_inode_t { typedef struct ext2_inode_t ext2_inode_t; // inode type -#define TYPE_FIFO 0x1000 -#define TYPE_CHAR_DEV 0x2000 -#define TYPE_DIR 0x4000 -#define TYPE_BLOCK DEV 0x6000 -#define TYPE_FILE 0x8000 -#define TYPE_SYMLINK 0xA000 -#define TYPE_SOCKET 0xC000 +#define TYPE_FIFO 0x1000 +#define TYPE_CHAR_DEV 0x2000 +#define TYPE_DIR 0x4000 +#define TYPE_BLOCK DEV 0x6000 +#define TYPE_FILE 0x8000 +#define TYPE_SYMLINK 0xA000 +#define TYPE_SOCKET 0xC000 // inode permission #define PERM_OE 0x001 @@ -117,12 +116,12 @@ struct ext2_dentry_t { uint16_t size; uint8_t name_length_lower; uint8_t type; - char* name; + char *name; }; typedef struct ext2_dentry_t ext2_dentry_t; struct path_t { - char* name; + char *name; list_t list; }; typedef struct path_t path_t; @@ -133,7 +132,7 @@ struct dentry_list_t { }; typedef struct dentry_list_t dentry_list_t; -extern ext2_superblock_t* ext2_superblock; +extern ext2_superblock_t *ext2_superblock; // size of structs #define BG_DESC_SIZE 32 @@ -141,16 +140,16 @@ extern ext2_superblock_t* ext2_superblock; #define INODE_SIZE (ext2_superblock->inode_size) #define INODES_PER_BLOCK (BLOCK_SIZE / INODE_SIZE) - void ext2_init(void); -void read_block(uint32_t block_num, void* block_ptr); -void read_superblock(ext2_superblock_t* ext2_superblock); -void read_bg_desc(uint32_t bg_desc, ext2_bg_desc_t* ext2_bg_desc); -void read_inode(uint32_t starting_block_num, uint32_t inode_index, ext2_inode_t* ext2_inode); -dentry_list_t* directory_to_entries(uint32_t inode); -char* files_to_buffer(uint32_t inode); -path_t* path_to_list(const char* path); -uint32_t path_to_inode(const char* path); +void read_block(uint32_t block_num, void *block_ptr); +void read_superblock(ext2_superblock_t *ext2_superblock); +void read_bg_desc(uint32_t bg_desc, ext2_bg_desc_t *ext2_bg_desc); +void read_inode(uint32_t starting_block_num, uint32_t inode_index, + ext2_inode_t *ext2_inode); +dentry_list_t *directory_to_entries(uint32_t inode); +char *files_to_buffer(uint32_t inode); +path_t *path_to_list(const char *path); +uint32_t path_to_inode(const char *path); void ls(uint32_t inode); void print_inode(uint32_t inode); diff --git a/kernel/include/font.h b/kernel/include/font.h index debaba9..c5ac621 100644 --- a/kernel/include/font.h +++ b/kernel/include/font.h @@ -6,364 +6,364 @@ #define PSF_FONT_MAGIC 0x864ab572 typedef struct { - uint32_t magic; /* magic bytes to identify PSF */ - uint32_t version; /* zero */ - uint32_t headersize; /* offset of bitmaps in file, 32 */ - uint32_t flags; /* 0 if there's no unicode table */ - uint32_t numglyph; /* number of glyphs */ - uint32_t bytesperglyph; /* size of each glyph */ - uint32_t height; /* height in pixels */ - uint32_t width; /* width in pixels */ + uint32_t magic; /* magic bytes to identify PSF */ + uint32_t version; /* zero */ + uint32_t headersize; /* offset of bitmaps in file, 32 */ + uint32_t flags; /* 0 if there's no unicode table */ + uint32_t numglyph; /* number of glyphs */ + uint32_t bytesperglyph; /* size of each glyph */ + uint32_t height; /* height in pixels */ + uint32_t width; /* width in pixels */ } PSF_font; /* font i used: /usr/share/kbd/consolefonts/lat9-16.psf.gz */ /* xxd -i font.psf */ const unsigned char font[] = { - 0x72, 0xb5, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xc3, - 0x99, 0x99, 0xf3, 0xe7, 0xe7, 0xff, 0xe7, 0xe7, 0x7e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0xf8, 0xd8, 0xd8, 0xdc, 0xd8, - 0xd8, 0xd8, 0xf8, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6e, 0xdb, 0xdb, 0xdf, 0xd8, 0xdb, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x00, 0x3e, - 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x80, 0xe0, - 0x80, 0x80, 0x00, 0x3e, 0x20, 0x38, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x70, 0x88, 0x80, 0x88, 0x70, 0x00, 0x3c, 0x22, 0x3c, 0x24, 0x22, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xf8, 0x00, 0x3e, - 0x20, 0x38, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x11, 0x44, 0x11, 0x44, - 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, - 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, - 0x55, 0xaa, 0x55, 0xaa, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, - 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, - 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, - 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, - 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x00, 0x20, - 0x20, 0x20, 0x20, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x50, - 0x50, 0x20, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0xe0, 0x38, 0x0e, 0x00, 0xfe, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x38, 0x0e, 0x38, - 0xe0, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, - 0x0c, 0xfe, 0x18, 0x30, 0xfe, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x1e, 0x7e, 0xfe, 0x7e, 0x1e, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xfc, 0xfe, - 0xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, - 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, - 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, - 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x36, 0x66, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, - 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, - 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7c, - 0xd6, 0xd0, 0xd0, 0x7c, 0x16, 0x16, 0xd6, 0x7c, 0x10, 0x10, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, - 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, - 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, - 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, - 0x30, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, - 0xc6, 0xc6, 0xd6, 0xd6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, - 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, - 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, - 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x60, - 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, - 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, - 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, - 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, - 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, - 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, - 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, - 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, - 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x66, - 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, - 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, - 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, - 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x66, - 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xe6, - 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, - 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00, - 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x64, 0x38, 0x0c, - 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, - 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, - 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0xee, 0x6c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, - 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, - 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x60, 0x30, - 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x0c, - 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x30, 0x30, 0x30, - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, - 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, - 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, - 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, - 0x0c, 0xcc, 0x78, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, - 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, - 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, - 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, - 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, - 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, - 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, - 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, - 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, - 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, - 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x18, - 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, - 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x7c, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x60, - 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6f, 0x60, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, - 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0xec, 0x0c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xef, 0x00, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xfc, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, - 0xef, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x6c, 0x6c, 0xef, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0xfe, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, - 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x7c, 0xd6, 0xd0, 0xd0, 0xd0, 0xd6, 0x7c, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x38, 0x6c, 0x60, 0x60, 0xf0, 0x60, 0x60, 0x66, 0xf6, 0x6c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x32, 0x60, 0x60, 0xfc, 0x60, 0xfc, - 0x60, 0x60, 0x32, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, - 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x6c, 0x38, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, - 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x38, 0x00, - 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3c, 0x42, 0x99, 0xa5, 0xa1, 0xa5, 0x99, 0x42, 0x3c, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, - 0xb9, 0xa5, 0xb9, 0xa5, 0xa5, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, - 0x38, 0x6c, 0x18, 0x30, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x18, 0x6c, 0x38, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x38, 0x00, 0xfe, - 0xc6, 0x8c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xf6, - 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x7f, 0xd6, 0xd6, 0x76, 0x36, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x6c, 0x38, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, - 0x00, 0x00, 0x00, 0x00, 0x30, 0x70, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, - 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xcc, 0xcc, 0xcc, 0xcf, 0xcf, - 0xcc, 0xcc, 0xcc, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6e, 0xdb, 0xdb, 0xdf, 0xd8, 0xdb, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, - 0x30, 0x30, 0x60, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x60, 0x30, 0x00, 0x38, - 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x18, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x38, 0x6c, 0xc6, 0xc6, - 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x38, - 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6c, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, - 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, - 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x78, - 0xd8, 0xd8, 0xfc, 0xd8, 0xd8, 0xd8, 0xd8, 0xde, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, - 0x0c, 0x66, 0x3c, 0x00, 0x60, 0x30, 0x00, 0xfe, 0x66, 0x60, 0x60, 0x7c, - 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00, 0xfe, - 0x66, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, - 0x10, 0x38, 0x6c, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0xfe, 0x66, 0x60, 0x60, 0x7c, - 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x3c, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x0c, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, 0x00, 0x3c, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x3c, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0xf6, 0x66, 0x66, 0x66, 0x6c, 0xf8, - 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, - 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x7c, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x0c, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x7c, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0x18, - 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xc6, - 0xce, 0xce, 0xde, 0xf6, 0xe6, 0xe6, 0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00, - 0x60, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, - 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x6c, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, - 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x60, - 0x7c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xcc, 0xc6, 0xc6, 0xc6, 0xd6, 0xdc, - 0x80, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, - 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, - 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x78, 0x0c, 0x7c, - 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, - 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0x1b, - 0x7f, 0xd8, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x6c, 0x38, 0x00, - 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, - 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, - 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, - 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x38, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x30, 0x78, - 0x0c, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, - 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x7c, 0xc6, 0xc6, - 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, - 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xce, 0xde, - 0xfe, 0xf6, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, - 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, - 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, - 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x0c, 0x18, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, - 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0xf0, 0x60, 0x60, 0x7c, 0x66, 0x66, - 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, - 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00 + 0x72, 0xb5, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xc3, + 0x99, 0x99, 0xf3, 0xe7, 0xe7, 0xff, 0xe7, 0xe7, 0x7e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x76, 0xdc, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0xf8, 0xd8, 0xd8, 0xdc, 0xd8, + 0xd8, 0xd8, 0xf8, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x6e, 0xdb, 0xdb, 0xdf, 0xd8, 0xdb, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0xf8, 0x88, 0x88, 0x00, 0x3e, + 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x80, 0xe0, + 0x80, 0x80, 0x00, 0x3e, 0x20, 0x38, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x70, 0x88, 0x80, 0x88, 0x70, 0x00, 0x3c, 0x22, 0x3c, 0x24, 0x22, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0xf8, 0x00, 0x3e, + 0x20, 0x38, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x11, 0x44, 0x11, 0x44, + 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, + 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, + 0x55, 0xaa, 0x55, 0xaa, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, + 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xdd, 0x77, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, + 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x88, 0xc8, 0xa8, 0x98, 0x88, 0x00, 0x20, + 0x20, 0x20, 0x20, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88, 0x50, + 0x50, 0x20, 0x00, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x38, 0xe0, 0x38, 0x0e, 0x00, 0xfe, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x38, 0x0e, 0x38, + 0xe0, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x0c, 0xfe, 0x18, 0x30, 0xfe, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x1e, 0x7e, 0xfe, 0x7e, 0x1e, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xfc, 0xfe, + 0xfc, 0xf0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, + 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0xfe, + 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6c, 0xfe, + 0x6c, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x36, 0x66, 0xfe, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, + 0x3c, 0x3c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0xfe, 0x6c, 0x6c, + 0x6c, 0xfe, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x7c, + 0xd6, 0xd0, 0xd0, 0x7c, 0x16, 0x16, 0xd6, 0x7c, 0x10, 0x10, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc6, 0x0c, 0x18, 0x30, 0x60, 0xc6, 0x86, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x76, 0xdc, + 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, + 0x0c, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18, + 0x30, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, + 0xc6, 0xc6, 0xd6, 0xd6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x06, 0x0c, 0x18, 0x30, + 0x60, 0xc0, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, + 0x06, 0x06, 0x3c, 0x06, 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x0c, 0x1e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc0, 0xc0, 0xc0, 0xfc, 0x06, + 0x06, 0x06, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x60, + 0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0xc6, 0x06, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0xc6, + 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, + 0xc6, 0xc6, 0x7e, 0x06, 0x06, 0x06, 0x0c, 0x78, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, + 0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, + 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, + 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xde, 0xde, 0xde, 0xdc, 0xc0, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, + 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, + 0x66, 0x66, 0x7c, 0x66, 0x66, 0x66, 0x66, 0xfc, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x6c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x66, + 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0xf0, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xde, + 0xc6, 0xc6, 0x66, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, + 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, + 0xcc, 0xcc, 0xcc, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe6, 0x66, + 0x66, 0x6c, 0x78, 0x78, 0x6c, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, + 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xe6, + 0xf6, 0xfe, 0xde, 0xce, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x60, + 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xd6, 0xde, 0x7c, 0x0c, 0x0e, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x66, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x66, 0xe6, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x64, 0x38, 0x0c, + 0x06, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, + 0x5a, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, + 0xc6, 0x6c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, + 0xc6, 0xc6, 0xd6, 0xd6, 0xd6, 0xfe, 0xee, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc6, 0xc6, 0x6c, 0x7c, 0x38, 0x38, 0x7c, 0x6c, 0xc6, 0xc6, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, + 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xc6, + 0x86, 0x0c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x60, 0x30, + 0x18, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x0c, + 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x30, 0x30, 0x30, + 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x78, 0x6c, 0x66, + 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x1c, 0x0c, 0x0c, 0x3c, 0x6c, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0xfe, + 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, + 0x64, 0x60, 0xf0, 0x60, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c, + 0x0c, 0xcc, 0x78, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x6c, 0x76, 0x66, + 0x66, 0x66, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, + 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x06, 0x00, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x66, 0x66, 0x3c, 0x00, 0x00, 0x00, 0xe0, 0x60, 0x60, 0x66, 0x6c, 0x78, + 0x78, 0x6c, 0x66, 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xd6, 0xd6, 0xd6, 0xc6, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7c, + 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xcc, 0xcc, + 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0x0c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xdc, 0x76, 0x66, 0x60, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 0x30, 0xfc, 0x30, 0x30, + 0x30, 0x30, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xd6, + 0xd6, 0xd6, 0xfe, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc6, 0x6c, 0x38, 0x38, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, + 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xcc, 0x18, + 0x30, 0x60, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x18, + 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x0e, 0x18, + 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x3c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x1f, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xf8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0xf8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x7c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x60, + 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0x6f, 0x60, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6f, 0x60, 0x6f, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x0c, + 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0xec, 0x0c, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xef, 0x00, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xfc, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0xec, 0x0c, 0xec, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, + 0xef, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, + 0x6c, 0x6c, 0xef, 0x00, 0xef, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, 0x6c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0xfe, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, + 0x18, 0x18, 0x3c, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x7c, 0xd6, 0xd0, 0xd0, 0xd0, 0xd6, 0x7c, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x38, 0x6c, 0x60, 0x60, 0xf0, 0x60, 0x60, 0x66, 0xf6, 0x6c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x32, 0x60, 0x60, 0xfc, 0x60, 0xfc, + 0x60, 0x60, 0x32, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, + 0x3c, 0x18, 0x7e, 0x18, 0x7e, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, + 0x6c, 0x38, 0x00, 0x7c, 0xc6, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x6c, 0xc6, 0xc6, + 0x6c, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x38, 0x00, + 0x00, 0x7c, 0xc6, 0x60, 0x38, 0x0c, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x42, 0x99, 0xa5, 0xa1, 0xa5, 0x99, 0x42, 0x3c, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x36, 0x6c, 0xd8, 0x6c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x06, 0x06, 0x06, 0x06, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x42, + 0xb9, 0xa5, 0xb9, 0xa5, 0xa5, 0x42, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, + 0x38, 0x6c, 0x18, 0x30, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x18, 0x6c, 0x38, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x38, 0x00, 0xfe, + 0xc6, 0x8c, 0x18, 0x30, 0x60, 0xc2, 0xc6, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xf6, + 0xc0, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x7f, 0xd6, 0xd6, 0x76, 0x36, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x6c, 0x38, 0x00, 0xfe, 0xcc, 0x18, 0x30, 0x60, 0xc6, 0xfe, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x70, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, + 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xd8, 0x6c, 0x36, 0x6c, 0xd8, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xcc, 0xcc, 0xcc, 0xcf, 0xcf, + 0xcc, 0xcc, 0xcc, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x6e, 0xdb, 0xdb, 0xdf, 0xd8, 0xdb, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x3c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x30, + 0x30, 0x30, 0x60, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x60, 0x30, 0x00, 0x38, + 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x18, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x38, 0x6c, 0xc6, 0xc6, + 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x38, + 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x6c, 0x00, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0xc6, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x6c, 0x38, 0x00, 0x38, 0x6c, 0xc6, 0xc6, + 0xfe, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x78, + 0xd8, 0xd8, 0xfc, 0xd8, 0xd8, 0xd8, 0xd8, 0xde, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x3c, 0x66, 0xc2, 0xc0, 0xc0, 0xc0, 0xc0, 0xc2, 0x66, 0x3c, + 0x0c, 0x66, 0x3c, 0x00, 0x60, 0x30, 0x00, 0xfe, 0x66, 0x60, 0x60, 0x7c, + 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00, 0xfe, + 0x66, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x38, 0x6c, 0x00, 0xfe, 0x66, 0x60, 0x7c, 0x60, 0x60, 0x66, 0xfe, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0xfe, 0x66, 0x60, 0x60, 0x7c, + 0x60, 0x60, 0x66, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x3c, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x0c, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, + 0x00, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x66, 0x00, 0x3c, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x3c, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0x6c, 0x66, 0x66, 0xf6, 0x66, 0x66, 0x66, 0x6c, 0xf8, + 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0xc6, 0xe6, 0xf6, 0xfe, 0xde, + 0xce, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x00, 0x7c, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x18, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x7c, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x3c, 0x18, + 0x3c, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xc6, + 0xce, 0xce, 0xde, 0xf6, 0xe6, 0xe6, 0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00, + 0x60, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, 0x00, + 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x6c, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, + 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x60, + 0x7c, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xcc, 0xc6, 0xc6, 0xc6, 0xd6, 0xdc, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x78, 0x0c, 0x7c, + 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x60, + 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x78, 0x0c, 0x7c, + 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, + 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x38, 0x6c, 0x38, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0xcc, 0xcc, 0x76, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0x1b, + 0x7f, 0xd8, 0xdb, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0xc0, 0xc6, 0x7c, 0x18, 0x6c, 0x38, 0x00, + 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x7c, 0xc6, 0xfe, + 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6c, + 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x6c, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0xc0, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x38, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, + 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x3c, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x38, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x30, 0x78, + 0x0c, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x76, 0xdc, 0x00, 0xdc, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x00, 0x7c, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x18, 0x30, + 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x38, 0x6c, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdc, 0x00, 0x7c, 0xc6, 0xc6, + 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, + 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0xce, 0xde, + 0xfe, 0xf6, 0xe6, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x30, 0x18, + 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x18, 0x30, 0x60, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, + 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, + 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0c, 0x18, 0x30, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, + 0x06, 0x0c, 0xf8, 0x00, 0x00, 0x00, 0xf0, 0x60, 0x60, 0x7c, 0x66, 0x66, + 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, + 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x06, 0x0c, 0xf8, 0x00 }; const uint32_t font_len = 4128; diff --git a/kernel/include/gdt.h b/kernel/include/gdt.h index ca2cc0e..d47ffa1 100644 --- a/kernel/include/gdt.h +++ b/kernel/include/gdt.h @@ -31,10 +31,12 @@ struct gdt_p { } __attribute__((packed)); typedef struct gdt_p gdt_p; -void add_gdt_entry(uint32_t num, uint32_t offset, uint32_t limit, uint8_t access, uint8_t flags); -void add_gdt_tss(uint32_t num, uint64_t offset, uint32_t limit, uint8_t access, uint8_t flags); +void add_gdt_entry(uint32_t num, uint32_t offset, uint32_t limit, + uint8_t access, uint8_t flags); +void add_gdt_tss(uint32_t num, uint64_t offset, uint32_t limit, uint8_t access, + uint8_t flags); void reload_gdt(void); -void load_gdt(gdt_p* pointer); +void load_gdt(gdt_p *pointer); void init_gdt(void); extern gdt_p gdt_pointer; diff --git a/kernel/include/graphics.h b/kernel/include/graphics.h index f19a579..7a32f7c 100644 --- a/kernel/include/graphics.h +++ b/kernel/include/graphics.h @@ -19,20 +19,23 @@ typedef struct fb_t fb_t; extern fb_t main_fb; -#define RED 0x00ff0000 -#define GREEN 0x0000ff00 -#define BLUE 0x000000ff -#define YELLOW 0x00ffff00 -#define PURPLE 0x00ff00ff -#define WHITE 0x00ffffff -#define BLACK 0x00000000 +#define RED 0x00ff0000 +#define GREEN 0x0000ff00 +#define BLUE 0x000000ff +#define YELLOW 0x00ffff00 +#define PURPLE 0x00ff00ff +#define WHITE 0x00ffffff +#define BLACK 0x00000000 -void set_color(fb_t* fb, uint32_t char_col, uint32_t bg_col); +void set_color(fb_t *fb, uint32_t char_col, uint32_t bg_col); void clear_screen(fb_t fb); void fb_draw_pixel(fb_t fb, int32_t x, int32_t y, uint32_t col); -void fb_draw_line_low(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t col); -void fb_draw_line_high(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t col); -void fb_draw_line(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t col); +void fb_draw_line_low(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, + uint32_t col); +void fb_draw_line_high(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, + uint32_t col); +void fb_draw_line(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, + uint32_t col); void fb_draw_character(fb_t fb, char c, int32_t x, int32_t y); #endif diff --git a/kernel/include/heap.h b/kernel/include/heap.h index 464a36a..16476c6 100644 --- a/kernel/include/heap.h +++ b/kernel/include/heap.h @@ -4,18 +4,18 @@ #include <types.h> #include <kernel_vma.h> -#define HEAP1_VMEM_ADDR KERNEL_VMA + 0x01000000 -#define HEAP1_PMEM_ADDR 0x01000000 -#define HEAP1_SIZE 0x01000000 -#define HEAP1_BLOCK_SIZE 0x00000010 +#define HEAP1_VMEM_ADDR KERNEL_VMA + 0x01000000 +#define HEAP1_PMEM_ADDR 0x01000000 +#define HEAP1_SIZE 0x01000000 +#define HEAP1_BLOCK_SIZE 0x00000010 -#define HEAP2_VMEM_ADDR KERNEL_VMA + 0x02000000 -#define HEAP2_PMEM_ADDR 0x02000000 -#define HEAP2_SIZE 0x01000000 -#define HEAP2_BLOCK_SIZE 0x00001000 +#define HEAP2_VMEM_ADDR KERNEL_VMA + 0x02000000 +#define HEAP2_PMEM_ADDR 0x02000000 +#define HEAP2_SIZE 0x01000000 +#define HEAP2_BLOCK_SIZE 0x00001000 struct kheapblock_t { - struct kheapblock_t* next; + struct kheapblock_t *next; uint32_t size; uint32_t used; uint32_t bsize; @@ -23,17 +23,17 @@ struct kheapblock_t { typedef struct kheapblock_t kheapblock_t; struct kheap_t { - struct kheapblock_t* fblock; + struct kheapblock_t *fblock; }; typedef struct kheap_t kheap_t; - extern kheap_t main_kheap; -void kheap_init(kheap_t* kheap); -void kheap_add_block(kheap_t* kheap, uint64_t addr, uint32_t size, uint32_t block_size); -void* kheap_alloc(kheap_t* kheap, uint32_t size); -void kheap_free(kheap_t* kheap, void* pointer); +void kheap_init(kheap_t *kheap); +void kheap_add_block(kheap_t *kheap, uint64_t addr, uint32_t size, + uint32_t block_size); +void *kheap_alloc(kheap_t *kheap, uint32_t size); +void kheap_free(kheap_t *kheap, void *pointer); void init_heap(void); diff --git a/kernel/include/idt.h b/kernel/include/idt.h index ffb0859..22e05ec 100644 --- a/kernel/include/idt.h +++ b/kernel/include/idt.h @@ -3,19 +3,19 @@ #include <types.h> -#define GDT_CODE_SEG 0x08 +#define GDT_CODE_SEG 0x08 -#define INTERRUPT_GATE 0x8E -#define TRAP_GATE 0x8F +#define INTERRUPT_GATE 0x8E +#define TRAP_GATE 0x8F struct idt_entry { - uint16_t offset_1; // offset bits 0..15 - uint16_t selector; // a code segment selector in GDT or LDT - uint8_t ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero. - uint8_t type_attributes; // gate type, dpl, and p fields - uint16_t offset_2; // offset bits 16..31 - uint32_t offset_3; // offset bits 32..63 - uint32_t zero; // reserved + uint16_t offset_1; // offset bits 0..15 + uint16_t selector; // a code segment selector in GDT or LDT + uint8_t ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero. + uint8_t type_attributes; // gate type, dpl, and p fields + uint16_t offset_2; // offset bits 16..31 + uint32_t offset_3; // offset bits 32..63 + uint32_t zero; // reserved } __attribute__((packed)); typedef struct idt_entry idt_entry; @@ -28,7 +28,7 @@ typedef struct idtp idtp; void enable_interrupts(void); void disable_interrupts(void); void init_idt(void); -void load_idt(idtp* pointer); +void load_idt(idtp *pointer); void init_idt_table(void); void add_to_idt(uint16_t num, uint64_t offset, uint16_t selector, uint8_t type); diff --git a/kernel/include/kcpuid.h b/kernel/include/kcpuid.h index f3a0e0c..161b350 100644 --- a/kernel/include/kcpuid.h +++ b/kernel/include/kcpuid.h @@ -3,8 +3,7 @@ #include <types.h> -struct CPUIDinfo -{ +struct CPUIDinfo { uint32_t EAX; uint32_t EBX; uint32_t ECX; @@ -12,6 +11,6 @@ struct CPUIDinfo }; typedef struct CPUIDinfo CPUIDinfo; -void kcpuid(uint32_t func, uint32_t subfunc, CPUIDinfo* info); +void kcpuid(uint32_t func, uint32_t subfunc, CPUIDinfo *info); #endif diff --git a/kernel/include/keyboard.h b/kernel/include/keyboard.h index 8b4085a..9fb4e7c 100644 --- a/kernel/include/keyboard.h +++ b/kernel/include/keyboard.h @@ -3,9 +3,9 @@ #include <types.h> -#define KEYBOARD_DATA_PORT 0x60 -#define KEYBOARD_CMD_PORT 0x60 -#define KEYBOARD_STATUS_PORT 0x64 +#define KEYBOARD_DATA_PORT 0x60 +#define KEYBOARD_CMD_PORT 0x60 +#define KEYBOARD_STATUS_PORT 0x64 void keyboard_handler(void); void init_keyboard(void); diff --git a/kernel/include/keymap.h b/kernel/include/keymap.h index 62d6a96..2c30bd2 100644 --- a/kernel/include/keymap.h +++ b/kernel/include/keymap.h @@ -3,354 +3,118 @@ #include <types.h> -#define KEY_ESCAPE 0x01 -#define KEY_1 0x02 -#define KEY_2 0x03 -#define KEY_3 0x04 -#define KEY_4 0x05 -#define KEY_5 0x06 -#define KEY_6 0x07 -#define KEY_7 0x08 -#define KEY_8 0x09 -#define KEY_9 0x0A -#define KEY_0 0x0B -#define KEY_MINUS 0x0C -#define KEY_EQUAL 0x0D -#define KEY_BACKSPACE 0x0E -#define KEY_TAB 0x0F -#define KEY_Q 0x10 -#define KEY_W 0x11 -#define KEY_E 0x12 -#define KEY_R 0x13 -#define KEY_T 0x14 -#define KEY_Y 0x15 -#define KEY_U 0x16 -#define KEY_I 0x17 -#define KEY_O 0x18 -#define KEY_P 0x19 -#define KEY_LBRACKET 0x1A -#define KEY_RBRACKET 0x1B -#define KEY_ENTER 0x1C -#define KEY_LEFT 0x1D -#define KEY_A 0x1E -#define KEY_S 0x1F -#define KEY_D 0x20 -#define KEY_F 0x21 -#define KEY_G 0x22 -#define KEY_H 0x23 -#define KEY_J 0x24 -#define KEY_K 0x25 -#define KEY_L 0x26 -#define KEY_ 0x27 -#define KEY_SQUOTE 0x28 -#define KEY_BACK_TICK 0x29 -#define KEY_LSHIFT 0x2A -#define KEY_LSLASH 0x2B -#define KEY_Z 0x2C -#define KEY_X 0x2D -#define KEY_C 0x2E -#define KEY_V 0x2F -#define KEY_B 0x30 -#define KEY_N 0x31 -#define KEY_M 0x32 -#define KEY_COMMA 0x33 -#define KEY_DOT 0x34 -#define KEY_RSLASH 0x35 -#define KEY_RSHIFT 0x36 -#define KEY_ASTERISK 0x37 -#define KEY_LALT 0x38 -#define KEY_SPACE 0x39 -#define KEY_CAPSLOCK 0x3A -#define KEY_F1 0x3B -#define KEY_F2 0x3C -#define KEY_F3 0x3D -#define KEY_F4 0x3E -#define KEY_F5 0x3F -#define KEY_F6 0x40 -#define KEY_F7 0x41 -#define KEY_F8 0x42 -#define KEY_F9 0x43 -#define KEY_F10 0x44 -#define KEY_NUMLOCK 0x45 -#define KEY_SCLOCK 0x46 -#define KEY_NUMPAD_7 0x47 -#define KEY_NUMPAD_8 0x48 -#define KEY_NUMPAD_9 0x49 -#define KEY_NUMPAD_MINUS 0x4A -#define KEY_NUMPAD_4 0x4B -#define KEY_NUMPAD_5 0x4C -#define KEY_NUMPAD_6 0x4D -#define KEY_NUMPAD_PLUS 0x4E -#define KEY_NUMPAD_1 0x4F -#define KEY_NUMPAD_2 0x50 -#define KEY_NUMPAD_3 0x51 -#define KEY_NUMPAD_0 0x52 -#define KEY_NUMPAD_DOT 0x53 -#define KEY_F11 0x57 -#define KEY_F12 0x58 +#define KEY_ESCAPE 0x01 +#define KEY_1 0x02 +#define KEY_2 0x03 +#define KEY_3 0x04 +#define KEY_4 0x05 +#define KEY_5 0x06 +#define KEY_6 0x07 +#define KEY_7 0x08 +#define KEY_8 0x09 +#define KEY_9 0x0A +#define KEY_0 0x0B +#define KEY_MINUS 0x0C +#define KEY_EQUAL 0x0D +#define KEY_BACKSPACE 0x0E +#define KEY_TAB 0x0F +#define KEY_Q 0x10 +#define KEY_W 0x11 +#define KEY_E 0x12 +#define KEY_R 0x13 +#define KEY_T 0x14 +#define KEY_Y 0x15 +#define KEY_U 0x16 +#define KEY_I 0x17 +#define KEY_O 0x18 +#define KEY_P 0x19 +#define KEY_LBRACKET 0x1A +#define KEY_RBRACKET 0x1B +#define KEY_ENTER 0x1C +#define KEY_LEFT 0x1D +#define KEY_A 0x1E +#define KEY_S 0x1F +#define KEY_D 0x20 +#define KEY_F 0x21 +#define KEY_G 0x22 +#define KEY_H 0x23 +#define KEY_J 0x24 +#define KEY_K 0x25 +#define KEY_L 0x26 +#define KEY_ 0x27 +#define KEY_SQUOTE 0x28 +#define KEY_BACK_TICK 0x29 +#define KEY_LSHIFT 0x2A +#define KEY_LSLASH 0x2B +#define KEY_Z 0x2C +#define KEY_X 0x2D +#define KEY_C 0x2E +#define KEY_V 0x2F +#define KEY_B 0x30 +#define KEY_N 0x31 +#define KEY_M 0x32 +#define KEY_COMMA 0x33 +#define KEY_DOT 0x34 +#define KEY_RSLASH 0x35 +#define KEY_RSHIFT 0x36 +#define KEY_ASTERISK 0x37 +#define KEY_LALT 0x38 +#define KEY_SPACE 0x39 +#define KEY_CAPSLOCK 0x3A +#define KEY_F1 0x3B +#define KEY_F2 0x3C +#define KEY_F3 0x3D +#define KEY_F4 0x3E +#define KEY_F5 0x3F +#define KEY_F6 0x40 +#define KEY_F7 0x41 +#define KEY_F8 0x42 +#define KEY_F9 0x43 +#define KEY_F10 0x44 +#define KEY_NUMLOCK 0x45 +#define KEY_SCLOCK 0x46 +#define KEY_NUMPAD_7 0x47 +#define KEY_NUMPAD_8 0x48 +#define KEY_NUMPAD_9 0x49 +#define KEY_NUMPAD_MINUS 0x4A +#define KEY_NUMPAD_4 0x4B +#define KEY_NUMPAD_5 0x4C +#define KEY_NUMPAD_6 0x4D +#define KEY_NUMPAD_PLUS 0x4E +#define KEY_NUMPAD_1 0x4F +#define KEY_NUMPAD_2 0x50 +#define KEY_NUMPAD_3 0x51 +#define KEY_NUMPAD_0 0x52 +#define KEY_NUMPAD_DOT 0x53 +#define KEY_F11 0x57 +#define KEY_F12 0x58 const char keymap[] = { - ' ', - ' ', - '1', - '2', - '3', - '4', - '5', - '6', - '7', - '8', - '9', - '0', - '-', - '=', - ' ', - ' ', - 'q', - 'w', - 'e', - 'r', - 't', - 'y', - 'u', - 'i', - 'o', - 'p', - '[', - ']', - '\n', - ' ', - 'a', - 's', - 'd', - 'f', - 'g', - 'h', - 'j', - 'k', - 'l', - ';', - '\'', - '`', - ' ', - '\\', - 'z', - 'x', - 'c', - 'v', - 'b', - 'n', - 'm', - ',', - '.', - '/', - ' ', - '*', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - '7', - '8', - '9', - '-', - '4', - '5', - '6', - '+', - '1', - '2', - '3', - '0', - '.', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', + ' ', ' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', + '=', ' ', ' ', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', + '[', ']', '\n', ' ', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', + ';', '\'', '`', ' ', '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', + '.', '/', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', '7', '8', '9', '-', '4', '5', '6', + '+', '1', '2', '3', '0', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', }; const uint16_t keymap_len = 128; const char shift_keymap[] = { - ' ', - ' ', - '!', - '@', - '#', - '$', - '%', - '^', - '&', - '*', - '(', - ')', - '_', - '+', - ' ', - ' ', - 'Q', - 'W', - 'E', - 'R', - 'T', - 'Y', - 'U', - 'I', - 'O', - 'P', - '{', - '}', - '\n', - ' ', - 'A', - 'S', - 'D', - 'F', - 'G', - 'H', - 'J', - 'K', - 'L', - ':', - '\"', - '~', - ' ', - '|', - 'Z', - 'X', - 'C', - 'V', - 'B', - 'N', - 'M', - '<', - '>', - '?', - ' ', - '*', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - '7', - '8', - '9', - '-', - '4', - '5', - '6', - '+', - '1', - '2', - '3', - '0', - '.', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', - ' ', + ' ', ' ', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', + '+', ' ', ' ', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', + '{', '}', '\n', ' ', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', + ':', '\"', '~', ' ', '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', + '>', '?', ' ', '*', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', '7', '8', '9', '-', '4', '5', '6', + '+', '1', '2', '3', '0', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', }; const uint16_t shift_keymap_len = 128; diff --git a/kernel/include/libk/list.h b/kernel/include/libk/list.h index 690f3d7..607dfb1 100644 --- a/kernel/include/libk/list.h +++ b/kernel/include/libk/list.h @@ -4,15 +4,15 @@ #include <containter_of.h> struct list_t { - struct list_t* next; - struct list_t* prev; + struct list_t *next; + struct list_t *prev; }; typedef struct list_t list_t; -void add_to_list(list_t* head, list_t* prev, list_t* next); -void free_node(list_t* head); +void add_to_list(list_t *head, list_t *prev, list_t *next); +void free_node(list_t *head); -#define INIT_LIST(name) \ +#define INIT_LIST(name) \ name.next = &name; \ name.prev = &name; @@ -25,16 +25,22 @@ void free_node(list_t* head); #define list_prev_entry(pos, member) \ container_of(pos->member.prev, typeof(*pos), member) -#define list_for_each_entry(pos, head, member) \ - for (pos = container_of(head->next, typeof(*pos), member); pos != container_of(head, typeof(*pos), member); pos = container_of(pos->member.next, typeof(*pos), member)) +#define list_for_each_entry(pos, head, member) \ + for (pos = container_of(head->next, typeof(*pos), member); \ + pos != container_of(head, typeof(*pos), member); \ + pos = container_of(pos->member.next, typeof(*pos), member)) -#define list_for_each_entry_prev(pos, head, member) \ - for (pos = container_of(head->prev, typeof(*pos), member); pos != container_of(head, typeof(*pos), member); pos = container_of(pos->member.prev, typeof(*pos), member)) +#define list_for_each_entry_prev(pos, head, member) \ + for (pos = container_of(head->prev, typeof(*pos), member); \ + pos != container_of(head, typeof(*pos), member); \ + pos = container_of(pos->member.prev, typeof(*pos), member)) -#define list_for_each_entry_del(pos, head, member) \ - for (pos = container_of(head->next, typeof(*pos), member); pos != container_of(head, typeof(*pos), member); free_node(&pos->list), pos = container_of(head->next, typeof(*pos), member)) +#define list_for_each_entry_del(pos, head, member) \ + for (pos = container_of(head->next, typeof(*pos), member); \ + pos != container_of(head, typeof(*pos), member); \ + free_node(&pos->list), \ + pos = container_of(head->next, typeof(*pos), member)) -#define list_is_empty(pos) \ - (pos == pos->next) +#define list_is_empty(pos) (pos == pos->next) #endif diff --git a/kernel/include/libk/math.h b/kernel/include/libk/math.h index aff847c..80860c9 100644 --- a/kernel/include/libk/math.h +++ b/kernel/include/libk/math.h @@ -3,9 +3,10 @@ #include <types.h> -#define min(a,b) ((a) > (b) ? (b) : (a)) -#define max(a,b) ((a) > (b) ? (a) : (b)) -#define upper_div(a,b) ((((a) / (b) * b) < (a)) ? (((a) / (b)) + 1) : ((a) / (b))) +#define min(a, b) ((a) > (b) ? (b) : (a)) +#define max(a, b) ((a) > (b) ? (a) : (b)) +#define upper_div(a, b) \ + ((((a) / (b)*b) < (a)) ? (((a) / (b)) + 1) : ((a) / (b))) int64_t abs(int64_t val); diff --git a/kernel/include/libk/serial_stdio.h b/kernel/include/libk/serial_stdio.h index 638d46a..1fefbfc 100644 --- a/kernel/include/libk/serial_stdio.h +++ b/kernel/include/libk/serial_stdio.h @@ -5,7 +5,7 @@ #include <atomic.h> void serial_print_char(char c); -void serial_print_string(const char* s); +void serial_print_string(const char *s); void serial_print_int(uint64_t num); void serial_print_hex(uint64_t num); void serial_printf(const char *s, ...); diff --git a/kernel/include/libk/stdio.h b/kernel/include/libk/stdio.h index f7b204e..fc31077 100644 --- a/kernel/include/libk/stdio.h +++ b/kernel/include/libk/stdio.h @@ -5,7 +5,7 @@ #include <atomic.h> void print_char(char c); -void print_string(const char* s); +void print_string(const char *s); void print_int(uint64_t num); void print_hex(uint64_t num); void printf(const char *s, ...); diff --git a/kernel/include/libk/string.h b/kernel/include/libk/string.h index fd25cac..88df3a4 100644 --- a/kernel/include/libk/string.h +++ b/kernel/include/libk/string.h @@ -3,13 +3,13 @@ #include <types.h> -size_t strlen(const char* s); +size_t strlen(const char *s); uint64_t stoi(const char *s); -void itos(uint64_t num, char* s); -void itoh(uint64_t num, char* s); +void itos(uint64_t num, char *s); +void itoh(uint64_t num, char *s); void strrev(char *s); -void memcpy(const void* destptr, const void* srcptr, size_t n); -void memset(const void* destptr, uint8_t value, size_t n); -int32_t memcmp(const void* aptr, const void* bptr); +void memcpy(const void *destptr, const void *srcptr, size_t n); +void memset(const void *destptr, uint8_t value, size_t n); +int32_t memcmp(const void *aptr, const void *bptr); #endif diff --git a/kernel/include/madt.h b/kernel/include/madt.h index 344a6e5..571f92a 100644 --- a/kernel/include/madt.h +++ b/kernel/include/madt.h @@ -9,7 +9,7 @@ struct MADT { uint32_t flags; } __attribute__((packed)); -struct MADT_type_header { +struct MADT_type_header { uint8_t type; uint8_t len; } __attribute__((packed)); diff --git a/kernel/include/multiboot2.h b/kernel/include/multiboot2.h index ff91092..5891a56 100644 --- a/kernel/include/multiboot2.h +++ b/kernel/include/multiboot2.h @@ -43,7 +43,7 @@ struct mb2_tag_module { uint32_t size; uint32_t mod_start; uint32_t mod_end; - char* name; + char *name; }; typedef struct mb2_tag_module mb2_tag_module; @@ -55,26 +55,25 @@ typedef struct mmap_t mmap_t; extern mmap_t mmap; - // multiboot2 magic check -#define MB2_MAGIC 0x36D76289 +#define MB2_MAGIC 0x36D76289 // multiboot2 tag -#define MB2_TAG_END 0 -#define MB2_TAG_CMDLINE 1 -#define MB2_TAG_BOOTLOADER 2 -#define MB2_TAG_MODULE 3 -#define MB2_TAG_MEM 4 -#define MB2_TAG_BIOS 5 -#define MB2_TAG_MMAP 6 -#define MB2_TAG_VBE 7 -#define MB2_TAG_FB 8 +#define MB2_TAG_END 0 +#define MB2_TAG_CMDLINE 1 +#define MB2_TAG_BOOTLOADER 2 +#define MB2_TAG_MODULE 3 +#define MB2_TAG_MEM 4 +#define MB2_TAG_BIOS 5 +#define MB2_TAG_MMAP 6 +#define MB2_TAG_VBE 7 +#define MB2_TAG_FB 8 -extern mb2_tag_module* ext2_module; +extern mb2_tag_module *ext2_module; -void read_mb2(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic); -void init_fb(mb2_tag_fb* tag_fb); -void init_mmap(mb2_tag_mmap* tag_mmap); -void init_module(mb2_tag_module* tag_module); +void read_mb2(mb2_tag_header *multiboot_bootinfo, uint32_t multiboot_magic); +void init_fb(mb2_tag_fb *tag_fb); +void init_mmap(mb2_tag_mmap *tag_mmap); +void init_module(mb2_tag_module *tag_module); #endif diff --git a/kernel/include/paging.h b/kernel/include/paging.h index c56c8e8..4aaf6af 100644 --- a/kernel/include/paging.h +++ b/kernel/include/paging.h @@ -9,7 +9,7 @@ #define FLAG_USER 0x4 #define FLAG_HUGE 0x80 -void load_pt_lvl4(uint64_t*); +void load_pt_lvl4(uint64_t *); void init_paging(void); void map_addr(uint64_t virt, uint64_t phys, uint32_t flags); void page_fault(uint64_t error); diff --git a/kernel/include/pic.h b/kernel/include/pic.h index 7e81293..7a244ad 100644 --- a/kernel/include/pic.h +++ b/kernel/include/pic.h @@ -1,29 +1,29 @@ #ifndef PIC_H #define PIC_H -#define PIC1 0x20 /* IO base address for master PIC */ -#define PIC2 0xA0 /* IO base address for slave PIC */ -#define PIC1_COMMAND 0x20 -#define PIC1_DATA 0x21 -#define PIC2_COMMAND 0xA0 -#define PIC2_DATA 0xA1 +#define PIC1 0x20 /* IO base address for master PIC */ +#define PIC2 0xA0 /* IO base address for slave PIC */ +#define PIC1_COMMAND 0x20 +#define PIC1_DATA 0x21 +#define PIC2_COMMAND 0xA0 +#define PIC2_DATA 0xA1 -#define PIC_EOI 0x20 /* End-of-interrupt command code */ +#define PIC_EOI 0x20 /* End-of-interrupt command code */ /* reinitialize the PIC controllers, giving them specified vector offsets rather than 8h and 70h, as configured by default */ -#define ICW1_ICW4 0x01 /* ICW4 (not) needed */ -#define ICW1_SINGLE 0x02 /* Single (cascade) mode */ -#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */ -#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */ -#define ICW1_INIT 0x10 /* Initialization - required! */ +#define ICW1_ICW4 0x01 /* ICW4 (not) needed */ +#define ICW1_SINGLE 0x02 /* Single (cascade) mode */ +#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */ +#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */ +#define ICW1_INIT 0x10 /* Initialization - required! */ -#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */ -#define ICW4_AUTO 0x02 /* Auto (normal) EOI */ -#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */ -#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */ -#define ICW4_SFNM 0x10 /* Special fully nested (not) */ +#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */ +#define ICW4_AUTO 0x02 /* Auto (normal) EOI */ +#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */ +#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */ +#define ICW4_SFNM 0x10 /* Special fully nested (not) */ void remap_pic(void); diff --git a/kernel/include/rsdp.h b/kernel/include/rsdp.h index ef76311..1613149 100644 --- a/kernel/include/rsdp.h +++ b/kernel/include/rsdp.h @@ -23,9 +23,8 @@ struct ACPI_header { uint32_t CreatorRevision; } __attribute__((packed)); - -uint64_t* find_rsdp(void); +uint64_t *find_rsdp(void); void list_sys_tables(void); -uint64_t* find_sys_table_addr(const char* signature); +uint64_t *find_sys_table_addr(const char *signature); #endif diff --git a/kernel/include/stdbuff.h b/kernel/include/stdbuff.h index 908fee2..8150621 100644 --- a/kernel/include/stdbuff.h +++ b/kernel/include/stdbuff.h @@ -7,12 +7,12 @@ struct stdbuff { size_t head; size_t tail; uint32_t size; - char* data; + char *data; }; typedef struct stdbuff stdbuff; -stdbuff* init_buff(uint32_t buff_size); -void read_buff(stdbuff* buffer, char* dest_ptr, size_t read_size); -void write_buff(stdbuff* buffer, const char* src_ptr, size_t write_size); +stdbuff *init_buff(uint32_t buff_size); +void read_buff(stdbuff *buffer, char *dest_ptr, size_t read_size); +void write_buff(stdbuff *buffer, const char *src_ptr, size_t write_size); #endif diff --git a/kernel/include/syscall.h b/kernel/include/syscall.h index 399e668..018db64 100644 --- a/kernel/include/syscall.h +++ b/kernel/include/syscall.h @@ -8,6 +8,6 @@ void syscall_handler(void); void syscall_read(void); -void syscall_write(char* buff, size_t count); +void syscall_write(char *buff, size_t count); #endif diff --git a/kernel/include/ubsan.h b/kernel/include/ubsan.h index 733cca0..43bf7c5 100644 --- a/kernel/include/ubsan.h +++ b/kernel/include/ubsan.h @@ -1,5 +1,4 @@ #ifndef UBSAN_H #define UBSAN_H - #endif diff --git a/kernel/src/apic/apic.c b/kernel/src/apic/apic.c index 06c0661..2b650b0 100644 --- a/kernel/src/apic/apic.c +++ b/kernel/src/apic/apic.c @@ -16,7 +16,10 @@ uint8_t cpu_apic_ids[256]; uint8_t curr_cpu_apic_id() { - return (uint8_t)(((*((__volatile__ uint32_t*)((uint64_t)lapic_addr + 0x20))) >> 24) & 0xFF); + return (uint8_t)(((*((__volatile__ uint32_t *)((uint64_t)lapic_addr + + 0x20))) >> + 24) & + 0xFF); } void init_ap_cpus() @@ -26,43 +29,75 @@ void init_ap_cpus() init_mutex(&cnt_lock); map_addr(lapic_addr, lapic_addr, FLAG_PRESENT); - for(size_t i = 0; i < numcores; i++) { + for (size_t i = 0; i < numcores; i++) { // do not start BSP, that's already running this code - if(cpu_apic_ids[i] == bspid) + if (cpu_apic_ids[i] == bspid) continue; // send INIT IPI // clear APIC errors - *((__volatile__ uint32_t*)(lapic_addr + 0x280)) = 0; + *((__volatile__ uint32_t *)(lapic_addr + 0x280)) = 0; // select AP - *((__volatile__ uint32_t*)(lapic_addr + 0x310)) = (*((__volatile__ uint32_t*)(lapic_addr + 0x310)) & 0x00ffffff) | ((uint32_t)cpu_apic_ids[i] << 24); + *((__volatile__ uint32_t *)(lapic_addr + 0x310)) = + (*((__volatile__ uint32_t *)(lapic_addr + 0x310)) & + 0x00ffffff) | + ((uint32_t)cpu_apic_ids[i] << 24); // trigger INIT IPI - *((__volatile__ uint32_t*)(lapic_addr + 0x300)) = (*((__volatile__ uint32_t*)(lapic_addr + 0x300)) & 0xfff00000) | 0x00C500; + *((__volatile__ uint32_t *)(lapic_addr + 0x300)) = + (*((__volatile__ uint32_t *)(lapic_addr + 0x300)) & + 0xfff00000) | + 0x00C500; // wait for delivery - do { __asm__ __volatile__ ("pause" : : : "memory"); }while(*((__volatile__ uint32_t*)(uint64_t)(lapic_addr + 0x300)) & (1 << 12)); + do { + __asm__ __volatile__("pause" : : : "memory"); + } while (*((__volatile__ uint32_t *)(uint64_t)(lapic_addr + + 0x300)) & + (1 << 12)); // select AP - *((__volatile__ uint32_t*)(lapic_addr + 0x310)) = (*((__volatile__ uint32_t*)(lapic_addr + 0x310)) & 0x00ffffff) | ((uint32_t)cpu_apic_ids[i] << 24); + *((__volatile__ uint32_t *)(lapic_addr + 0x310)) = + (*((__volatile__ uint32_t *)(lapic_addr + 0x310)) & + 0x00ffffff) | + ((uint32_t)cpu_apic_ids[i] << 24); // deassert - *((__volatile__ uint32_t*)(lapic_addr + 0x300)) = (*((__volatile__ uint32_t*)(lapic_addr + 0x300)) & 0xfff00000) | 0x008500; + *((__volatile__ uint32_t *)(lapic_addr + 0x300)) = + (*((__volatile__ uint32_t *)(lapic_addr + 0x300)) & + 0xfff00000) | + 0x008500; // wait for delivery - do { __asm__ __volatile__ ("pause" : : : "memory"); }while(*((__volatile__ uint32_t*)(uint64_t)(lapic_addr + 0x300)) & (1 << 12)); + do { + __asm__ __volatile__("pause" : : : "memory"); + } while (*((__volatile__ uint32_t *)(uint64_t)(lapic_addr + + 0x300)) & + (1 << 12)); // wait 10 msec wait(10); // send STARTUP IPI (twice) - for(size_t j = 0; j < 2; j++) { + for (size_t j = 0; j < 2; j++) { // clear APIC errors - *((__volatile__ uint32_t*)(lapic_addr + 0x280)) = 0; + *((__volatile__ uint32_t *)(lapic_addr + 0x280)) = 0; // select AP - *((__volatile__ uint32_t*)(lapic_addr + 0x310)) = (*((__volatile__ uint32_t*)(lapic_addr + 0x310)) & 0x00ffffff) | ((uint32_t)cpu_apic_ids[i] << 24); + *((__volatile__ uint32_t *)(lapic_addr + 0x310)) = + (*((__volatile__ uint32_t *)(lapic_addr + + 0x310)) & + 0x00ffffff) | + ((uint32_t)cpu_apic_ids[i] << 24); // trigger STARTUP IPI for 0800:0000 - *((__volatile__ uint32_t*)(lapic_addr + 0x300)) = (*((__volatile__ uint32_t*)(lapic_addr + 0x300)) & 0xfff0f800) | 0x000608; + *((__volatile__ uint32_t *)(lapic_addr + 0x300)) = + (*((__volatile__ uint32_t *)(lapic_addr + + 0x300)) & + 0xfff0f800) | + 0x000608; // wait 200 usec wait(1); // wait for delivery - do { __asm__ __volatile__ ("pause" : : : "memory"); }while(*((__volatile__ uint32_t*)(uint64_t)(lapic_addr + 0x300)) & (1 << 12)); + do { + __asm__ __volatile__("pause" : : : "memory"); + } while (*((__volatile__ uint32_t + *)(uint64_t)(lapic_addr + 0x300)) & + (1 << 12)); } } diff --git a/kernel/src/apic/ioapic.c b/kernel/src/apic/ioapic.c index bcd5a4d..cfda8be 100644 --- a/kernel/src/apic/ioapic.c +++ b/kernel/src/apic/ioapic.c @@ -7,29 +7,29 @@ void ioapic_eoi() { - *((__volatile__ uint32_t*)((uint64_t)lapic_addr + 0xB0)) = 0; + *((__volatile__ uint32_t *)((uint64_t)lapic_addr + 0xB0)) = 0; } uint32_t ioapic_read(const uint8_t offset) { - /* tell IOREGSEL where we want to read from */ - *(__volatile__ uint32_t*)(uint64_t)ioapic_addr = offset; - /* return the data from IOWIN */ - return *(__volatile__ uint32_t*)((uint64_t)ioapic_addr + 0x10); + /* tell IOREGSEL where we want to read from */ + *(__volatile__ uint32_t *)(uint64_t)ioapic_addr = offset; + /* return the data from IOWIN */ + return *(__volatile__ uint32_t *)((uint64_t)ioapic_addr + 0x10); } void ioapic_write(const uint8_t offset, const uint32_t val) { - /* tell IOREGSEL where we want to write to */ - *(__volatile__ uint32_t*)(uint64_t)ioapic_addr = offset; - /* write the value to IOWIN */ - *(__volatile__ uint32_t*)((uint64_t)ioapic_addr + 0x10) = val; + /* tell IOREGSEL where we want to write to */ + *(__volatile__ uint32_t *)(uint64_t)ioapic_addr = offset; + /* write the value to IOWIN */ + *(__volatile__ uint32_t *)((uint64_t)ioapic_addr + 0x10) = val; } void ioapic_set_irq(uint8_t irq, uint64_t apic_id, uint8_t vector) { - const uint32_t low_index = (uint32_t)0x10 + irq*2; - const uint32_t high_index = (uint32_t)0x10 + irq*2 + 1; + const uint32_t low_index = (uint32_t)0x10 + irq * 2; + const uint32_t high_index = (uint32_t)0x10 + irq * 2 + 1; uint32_t high = ioapic_read((uint8_t)high_index); // set APIC ID @@ -40,10 +40,10 @@ void ioapic_set_irq(uint8_t irq, uint64_t apic_id, uint8_t vector) uint32_t low = ioapic_read((uint8_t)low_index); // unmask the IRQ - low &= (uint32_t)~(1<<16); + low &= (uint32_t) ~(1 << 16); // set to physical delivery mode - low &= (uint32_t)~(1<<11); + low &= (uint32_t) ~(1 << 11); // set to fixed delivery mode low &= (uint32_t)~0x700; @@ -66,6 +66,7 @@ void apic_remap_interrupts() ioapic_set_irq(0x2, bspid, 0x20); // timer ioapic_set_irq(0x1, bspid, 0x21); // keyboard - write_msr(APIC_BASE_MSR, read_msr(APIC_BASE_MSR) | (1<<11)); - *((__volatile__ uint32_t*)(lapic_addr + 0xF0)) = (*(__volatile__ uint32_t*)(lapic_addr + 0xF0) | 0x1FF ); + write_msr(APIC_BASE_MSR, read_msr(APIC_BASE_MSR) | (1 << 11)); + *((__volatile__ uint32_t *)(lapic_addr + 0xF0)) = + (*(__volatile__ uint32_t *)(lapic_addr + 0xF0) | 0x1FF); } diff --git a/kernel/src/apic/madt.c b/kernel/src/apic/madt.c index f69887d..5a6e914 100644 --- a/kernel/src/apic/madt.c +++ b/kernel/src/apic/madt.c @@ -6,28 +6,37 @@ void parse_madt() { - uint64_t* madt_addr = find_sys_table_addr("APIC"); + uint64_t *madt_addr = find_sys_table_addr("APIC"); if (madt_addr == NULL) { printf("MADT NOT FOUND\n"); return; } - struct MADT* madt = (struct MADT*)kalloc(sizeof(struct MADT)); + struct MADT *madt = (struct MADT *)kalloc(sizeof(struct MADT)); memcpy(madt, madt_addr, sizeof(struct MADT)); lapic_addr = madt->lapic_addr; - for (size_t curr_size = sizeof(struct MADT); curr_size < madt->h.Length;) { - struct MADT_type_header* m = (struct MADT_type_header*)kalloc(sizeof(struct MADT_type_header)); - memcpy(m, (uint64_t*)((uint64_t)madt_addr + (uint64_t)curr_size), sizeof(struct MADT_type_header)); + for (size_t curr_size = sizeof(struct MADT); + curr_size < madt->h.Length;) { + struct MADT_type_header *m = (struct MADT_type_header *)kalloc( + sizeof(struct MADT_type_header)); + memcpy(m, + (uint64_t *)((uint64_t)madt_addr + (uint64_t)curr_size), + sizeof(struct MADT_type_header)); uint8_t type = m->type; uint8_t len = m->len; kfree(m); if (type == 0) { // Processor Local APIC - struct MADT_cpu_local_apic* cpu = (struct MADT_cpu_local_apic*)kalloc(sizeof(struct MADT_cpu_local_apic)); - memcpy(cpu, (uint64_t*)((uint64_t)madt_addr + (uint64_t)curr_size), sizeof(struct MADT_cpu_local_apic)); + struct MADT_cpu_local_apic *cpu = + (struct MADT_cpu_local_apic *)kalloc( + sizeof(struct MADT_cpu_local_apic)); + memcpy(cpu, + (uint64_t *)((uint64_t)madt_addr + + (uint64_t)curr_size), + sizeof(struct MADT_cpu_local_apic)); if (cpu->flags & 0x1) { cpu_apic_ids[numcores] = cpu->apic_id; @@ -38,8 +47,12 @@ void parse_madt() kfree(cpu); } else if (type == 1) { // I/O APIC - struct MADT_io_apic* io = (struct MADT_io_apic*)kalloc(sizeof(struct MADT_io_apic)); - memcpy(io, (uint64_t*)((uint64_t)madt_addr + (uint64_t)curr_size), sizeof(struct MADT_io_apic)); + struct MADT_io_apic *io = (struct MADT_io_apic *)kalloc( + sizeof(struct MADT_io_apic)); + memcpy(io, + (uint64_t *)((uint64_t)madt_addr + + (uint64_t)curr_size), + sizeof(struct MADT_io_apic)); ioapic_addr = io->io_apic_addr; @@ -47,8 +60,13 @@ void parse_madt() kfree(io); } else if (type == 2) { // IO/APIC Interrupt Source Override - struct MADT_io_apic_int* io_apic_int = (struct MADT_io_apic_int*)kalloc(sizeof(struct MADT_io_apic_int)); - memcpy(io_apic_int, (uint64_t*)((uint64_t)madt_addr + (uint64_t)curr_size), sizeof(struct MADT_io_apic_int)); + struct MADT_io_apic_int *io_apic_int = + (struct MADT_io_apic_int *)kalloc( + sizeof(struct MADT_io_apic_int)); + memcpy(io_apic_int, + (uint64_t *)((uint64_t)madt_addr + + (uint64_t)curr_size), + sizeof(struct MADT_io_apic_int)); // printf("found io_apic_int: bus: 0x%x, irq_source: 0x%x, global_sys_int: 0x%x, flags: 0x%x\n", io_apic_int->bus_source, io_apic_int->irq_source, io_apic_int->global_sys_int, io_apic_int->flags); kfree(io_apic_int); @@ -57,15 +75,25 @@ void parse_madt() printf("MADT entry of type %d\n", type); } else if (type == 4) { // Local APIC Non-maskable interrupts - struct MADT_lapic_nmi* lapic_nmi = (struct MADT_lapic_nmi*)kalloc(sizeof(struct MADT_lapic_nmi)); - memcpy(lapic_nmi, (uint64_t*)((uint64_t)madt_addr + (uint64_t)curr_size), sizeof(struct MADT_lapic_nmi)); + struct MADT_lapic_nmi *lapic_nmi = + (struct MADT_lapic_nmi *)kalloc( + sizeof(struct MADT_lapic_nmi)); + memcpy(lapic_nmi, + (uint64_t *)((uint64_t)madt_addr + + (uint64_t)curr_size), + sizeof(struct MADT_lapic_nmi)); // printf("found lapic_nmi: acpi_cpu_id: 0x%x, flags: 0x%x, lint: 0x%x\n", lapic_nmi->acpi_cpu_id, lapic_nmi->flags, lapic_nmi->lint); kfree(lapic_nmi); } else if (type == 5) { // Local APIC Address Override - struct MADT_lapic_addr* lapic_addr_ovr = (struct MADT_lapic_addr*)kalloc(sizeof(struct MADT_lapic_addr)); - memcpy(lapic_addr_ovr, (uint64_t*)((uint64_t)madt_addr + (uint64_t)curr_size), sizeof(struct MADT_lapic_addr)); + struct MADT_lapic_addr *lapic_addr_ovr = + (struct MADT_lapic_addr *)kalloc( + sizeof(struct MADT_lapic_addr)); + memcpy(lapic_addr_ovr, + (uint64_t *)((uint64_t)madt_addr + + (uint64_t)curr_size), + sizeof(struct MADT_lapic_addr)); // printf("found lapic: addr: 0x%x\n", lapic_addr_ovr->phys_addr); kfree(lapic_addr_ovr); diff --git a/kernel/src/apic/rsdp.c b/kernel/src/apic/rsdp.c index e0127aa..c12b63f 100644 --- a/kernel/src/apic/rsdp.c +++ b/kernel/src/apic/rsdp.c @@ -4,12 +4,12 @@ #include <libk/string.h> #include <libk/stdio.h> -uint64_t* find_rsdp() +uint64_t *find_rsdp() { map_addr(0x0, 0x0, FLAG_PRESENT); - const char* rsdp_cs = "RSD PTR "; + const char *rsdp_cs = "RSD PTR "; for (uint64_t i = 0x10; i < 0x100000; i += 0x10) { - char *x = (char*)i; + char *x = (char *)i; uint8_t ind = 1; for (size_t j = 0; j < strlen(rsdp_cs); j++) { if (rsdp_cs[j] != x[j]) { @@ -18,7 +18,7 @@ uint64_t* find_rsdp() } } if (ind) { - return (uint64_t*)i; + return (uint64_t *)i; } } return NULL; @@ -26,28 +26,35 @@ uint64_t* find_rsdp() void list_sys_tables(void) { - uint64_t* rsdp = find_rsdp(); + uint64_t *rsdp = find_rsdp(); if (rsdp == NULL) { printf("RSDP NOT FOUND\n"); return; } - struct RSDP_descriptor* rsdp_desc = (struct RSDP_descriptor*)rsdp; + struct RSDP_descriptor *rsdp_desc = (struct RSDP_descriptor *)rsdp; map_addr(rsdp_desc->RsdtAddress, rsdp_desc->RsdtAddress, FLAG_PRESENT); - struct ACPI_header* rsdt = (struct ACPI_header*)kalloc(sizeof(struct ACPI_header)); - memcpy(rsdt, (uint64_t*)(uint64_t)rsdp_desc->RsdtAddress, sizeof(struct ACPI_header)); + struct ACPI_header *rsdt = + (struct ACPI_header *)kalloc(sizeof(struct ACPI_header)); + memcpy(rsdt, (uint64_t *)(uint64_t)rsdp_desc->RsdtAddress, + sizeof(struct ACPI_header)); - uint32_t entries = (rsdt->Length - (uint32_t)sizeof(struct ACPI_header)) / 4; + uint32_t entries = + (rsdt->Length - (uint32_t)sizeof(struct ACPI_header)) / 4; for (size_t i = 0; i < entries; i++) { - uint32_t na_addr = (uint32_t)rsdp_desc->RsdtAddress + (uint32_t)sizeof(struct ACPI_header) + (uint32_t)i * 4; + uint32_t na_addr = (uint32_t)rsdp_desc->RsdtAddress + + (uint32_t)sizeof(struct ACPI_header) + + (uint32_t)i * 4; uint32_t addr; - memcpy(&addr, (uint64_t*)(uint64_t)na_addr, 4); + memcpy(&addr, (uint64_t *)(uint64_t)na_addr, 4); - struct ACPI_header* t = (struct ACPI_header*)kalloc(sizeof(struct ACPI_header)); - memcpy(t, (uint64_t*)(uint64_t)addr, sizeof(struct ACPI_header)); + struct ACPI_header *t = (struct ACPI_header *)kalloc( + sizeof(struct ACPI_header)); + memcpy(t, (uint64_t *)(uint64_t)addr, + sizeof(struct ACPI_header)); for (size_t j = 0; j < 4; j++) { printf("%c", t->Signature[j]); @@ -61,30 +68,37 @@ void list_sys_tables(void) kfree(rsdt); } -uint64_t* find_sys_table_addr(const char* signature) +uint64_t *find_sys_table_addr(const char *signature) { - uint64_t* rsdp = find_rsdp(); + uint64_t *rsdp = find_rsdp(); if (rsdp == NULL) { printf("RSDP NOT FOUND\n"); return NULL; } - struct RSDP_descriptor* rsdp_desc = (struct RSDP_descriptor*)rsdp; + struct RSDP_descriptor *rsdp_desc = (struct RSDP_descriptor *)rsdp; map_addr(rsdp_desc->RsdtAddress, rsdp_desc->RsdtAddress, FLAG_PRESENT); - struct ACPI_header* rsdt = (struct ACPI_header*)kalloc(sizeof(struct ACPI_header)); - memcpy(rsdt, (uint64_t*)(uint64_t)rsdp_desc->RsdtAddress, sizeof(struct ACPI_header)); + struct ACPI_header *rsdt = + (struct ACPI_header *)kalloc(sizeof(struct ACPI_header)); + memcpy(rsdt, (uint64_t *)(uint64_t)rsdp_desc->RsdtAddress, + sizeof(struct ACPI_header)); - uint32_t entries = (rsdt->Length - (uint32_t)sizeof(struct ACPI_header)) / 4; + uint32_t entries = + (rsdt->Length - (uint32_t)sizeof(struct ACPI_header)) / 4; for (size_t i = 0; i < entries; i++) { - uint32_t na_addr = (uint32_t)rsdp_desc->RsdtAddress + (uint32_t)sizeof(struct ACPI_header) + (uint32_t)i * 4; + uint32_t na_addr = (uint32_t)rsdp_desc->RsdtAddress + + (uint32_t)sizeof(struct ACPI_header) + + (uint32_t)i * 4; uint32_t addr; - memcpy(&addr, (uint64_t*)(uint64_t)na_addr, 4); + memcpy(&addr, (uint64_t *)(uint64_t)na_addr, 4); - struct ACPI_header* t = (struct ACPI_header*)kalloc(sizeof(struct ACPI_header)); - memcpy(t, (uint64_t*)(uint64_t)addr, sizeof(struct ACPI_header)); + struct ACPI_header *t = (struct ACPI_header *)kalloc( + sizeof(struct ACPI_header)); + memcpy(t, (uint64_t *)(uint64_t)addr, + sizeof(struct ACPI_header)); int ind = 1; for (size_t j = 0; j < 4; j++) { @@ -94,7 +108,7 @@ uint64_t* find_sys_table_addr(const char* signature) if (ind) { kfree(t); kfree(rsdt); - return (uint64_t*)(uint64_t)addr; + return (uint64_t *)(uint64_t)addr; } kfree(t); diff --git a/kernel/src/boot/multiboot2.c b/kernel/src/boot/multiboot2.c index dd3ab78..8a7d0d6 100644 --- a/kernel/src/boot/multiboot2.c +++ b/kernel/src/boot/multiboot2.c @@ -1,9 +1,7 @@ #include <types.h> #include <multiboot2.h> - #include <graphics.h> #include <paging.h> - #include <libk/serial_stdio.h> #include <libk/string.h> #include <libk/list.h> @@ -12,11 +10,11 @@ /* https://www.gnu.org/software/grub/manual/multiboot2/html_node/Boot-information-format.html */ -mb2_tag_module* ext2_module; +mb2_tag_module *ext2_module; mmap_t mmap; -void init_fb(mb2_tag_fb* tag_fb) +void init_fb(mb2_tag_fb *tag_fb) { main_fb.addr = tag_fb->framebuffer_addr; main_fb.width = tag_fb->framebuffer_width; @@ -28,62 +26,70 @@ void init_fb(mb2_tag_fb* tag_fb) // identity map framebuffer address map_addr(main_fb.addr, main_fb.addr, FLAG_PRESENT | FLAG_WRITABLE); - map_addr(main_fb.addr + PAGE_SIZE, main_fb.addr + PAGE_SIZE, FLAG_PRESENT | FLAG_WRITABLE); + map_addr(main_fb.addr + PAGE_SIZE, main_fb.addr + PAGE_SIZE, + FLAG_PRESENT | FLAG_WRITABLE); } -void init_mmap(mb2_tag_mmap* tag_mmap) +void init_mmap(mb2_tag_mmap *tag_mmap) { INIT_LIST(mmap.list) // get data and store it into list - for (size_t i = sizeof(mb2_tag_mmap); i < tag_mmap->size; i += sizeof(mb2_tag_mmap_entry)) { - mmap_t* curr_mmap_entry = (mmap_t*)kalloc(sizeof(mmap_t)); - memcpy(&curr_mmap_entry->mmap_entry, (char*)tag_mmap + i, sizeof(mb2_tag_mmap_entry)); + for (size_t i = sizeof(mb2_tag_mmap); i < tag_mmap->size; + i += sizeof(mb2_tag_mmap_entry)) { + mmap_t *curr_mmap_entry = (mmap_t *)kalloc(sizeof(mmap_t)); + memcpy(&curr_mmap_entry->mmap_entry, (char *)tag_mmap + i, + sizeof(mb2_tag_mmap_entry)); add_to_list(&curr_mmap_entry->list, &mmap.list, mmap.list.next); } } -void init_module(mb2_tag_module* tag_module) +void init_module(mb2_tag_module *tag_module) { // name is utf-8 encoded string! - uint32_t name_size = tag_module->size - sizeof(tag_module) + sizeof(char*); - tag_module->name = (char*)kalloc(name_size); - memcpy(tag_module->name, tag_module + tag_module->size - name_size, name_size); + uint32_t name_size = + tag_module->size - sizeof(tag_module) + sizeof(char *); + tag_module->name = (char *)kalloc(name_size); + memcpy(tag_module->name, tag_module + tag_module->size - name_size, + name_size); kfree(tag_module->name); } -void read_mb2(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic) +void read_mb2(mb2_tag_header *multiboot_bootinfo, uint32_t multiboot_magic) { if (multiboot_magic != MB2_MAGIC) { // not loaded by multiboot2 bootloader - __asm__ __volatile__ ("hlt;"); + __asm__ __volatile__("hlt;"); } // we will store framebuffer information here - static mb2_tag_fb* tag_fb; - static mb2_tag_mmap* tag_mmap; + static mb2_tag_fb *tag_fb; + static mb2_tag_mmap *tag_mmap; // skip first 8 bytes (total_size + reserved) - mb2_tag_header* tag_header = (mb2_tag_header*)((uint64_t)multiboot_bootinfo + 8 + KERNEL_VMA); + mb2_tag_header *tag_header = + (mb2_tag_header *)((uint64_t)multiboot_bootinfo + 8 + + KERNEL_VMA); while (tag_header->type != MB2_TAG_END) { // process tag_type - switch(tag_header->type) { - case MB2_TAG_FB: - tag_fb = (mb2_tag_fb*)tag_header; - break; - case MB2_TAG_MMAP: - tag_mmap = (mb2_tag_mmap*)tag_header; - break; - case MB2_TAG_MODULE: - ext2_module = (mb2_tag_module*)tag_header; - break; - default: - break; + switch (tag_header->type) { + case MB2_TAG_FB: + tag_fb = (mb2_tag_fb *)tag_header; + break; + case MB2_TAG_MMAP: + tag_mmap = (mb2_tag_mmap *)tag_header; + break; + case MB2_TAG_MODULE: + ext2_module = (mb2_tag_module *)tag_header; + break; + default: + break; } // next mb2_tag - tag_header += tag_header->size / 8 + ((tag_header->size % 8) > 0); + tag_header += + tag_header->size / 8 + ((tag_header->size % 8) > 0); } init_fb(tag_fb); diff --git a/kernel/src/check/panic.c b/kernel/src/check/panic.c index 894f22f..7cfaa56 100644 --- a/kernel/src/check/panic.c +++ b/kernel/src/check/panic.c @@ -5,12 +5,11 @@ uint64_t panic_rsp; -__attribute__((noreturn)) -void panic(const char *s, ...) +__attribute__((noreturn)) void panic(const char *s, ...) { set_color(&main_fb, RED, BLACK); printf("KERNEL PANIC\n"); -// set_color(&main_fb, WHITE, BLACK); + // set_color(&main_fb, WHITE, BLACK); va_list list; va_start(list, s); vprintf(s, list); @@ -19,34 +18,38 @@ void panic(const char *s, ...) if (panic_rsp != 0) { printf("info:\n"); uint64_t i = 0; - printf("ss: 0x%x ", (uint16_t)*((uint64_t*)panic_rsp + i++)); - printf("ds: 0x%x ", (uint16_t)*((uint64_t*)panic_rsp + i++)); - printf("es: 0x%x ", (uint16_t)*((uint64_t*)panic_rsp + i++)); - printf("r15: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("r14: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("r13: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("r12: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("r11: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("r10: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("r9: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("r8: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rdi: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rsi: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rdx: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rcx: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rbx: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rax: 0x%x ", *((uint64_t*)panic_rsp + i++)); - if (*((uint64_t*)panic_rsp + i) <= 0xffffffff) - printf("err code: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rip: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("cs: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rflags: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("rsp: 0x%x ", *((uint64_t*)panic_rsp + i++)); - printf("ss: 0x%x ", *((uint64_t*)panic_rsp + i++)); + printf("ss: 0x%x ", + (uint16_t) * ((uint64_t *)panic_rsp + i++)); + printf("ds: 0x%x ", + (uint16_t) * ((uint64_t *)panic_rsp + i++)); + printf("es: 0x%x ", + (uint16_t) * ((uint64_t *)panic_rsp + i++)); + printf("r15: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("r14: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("r13: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("r12: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("r11: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("r10: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("r9: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("r8: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rdi: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rsi: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rdx: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rcx: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rbx: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rax: 0x%x ", *((uint64_t *)panic_rsp + i++)); + if (*((uint64_t *)panic_rsp + i) <= 0xffffffff) + printf("err code: 0x%x ", + *((uint64_t *)panic_rsp + i++)); + printf("rip: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("cs: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rflags: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("rsp: 0x%x ", *((uint64_t *)panic_rsp + i++)); + printf("ss: 0x%x ", *((uint64_t *)panic_rsp + i++)); } disable_interrupts(); - for(;;) { - __asm__ __volatile__ ("hlt;"); + for (;;) { + __asm__ __volatile__("hlt;"); } } diff --git a/kernel/src/check/ssp.c b/kernel/src/check/ssp.c index 86288b1..65271eb 100644 --- a/kernel/src/check/ssp.c +++ b/kernel/src/check/ssp.c @@ -6,8 +6,8 @@ uintptr_t __stack_chk_guard = STACK_CHK_GUARD; -__attribute__((noreturn)) -void __stack_chk_fail(void) +__attribute__((noreturn)) void __stack_chk_fail(void); +__attribute__((noreturn)) void __stack_chk_fail(void) { panic("Stack smashing detected"); } diff --git a/kernel/src/check/ubsan.c b/kernel/src/check/ubsan.c index c3933da..dc6c4b4 100644 --- a/kernel/src/check/ubsan.c +++ b/kernel/src/check/ubsan.c @@ -23,15 +23,13 @@ #include <ubsan.h> #include <panic.h> -struct ubsan_source_location -{ - const char* filename; +struct ubsan_source_location { + const char *filename; uint32_t line; uint32_t column; }; -struct ubsan_type_descriptor -{ +struct ubsan_type_descriptor { uint16_t type_kind; uint16_t type_info; char type_name[]; @@ -39,348 +37,320 @@ struct ubsan_type_descriptor typedef uintptr_t ubsan_value_handle_t; -static const struct ubsan_source_location unknown_location = -{ +static const struct ubsan_source_location unknown_location = { "<unknown file>", 0, 0, }; -__attribute__((noreturn)) -static void ubsan_abort(const struct ubsan_source_location* location, - const char* violation) +__attribute__((noreturn)) static void +ubsan_abort(const struct ubsan_source_location *location, const char *violation) { - if ( !location || !location->filename ) + if (!location || !location->filename) location = &unknown_location; panic_rsp = 0; - panic( - "filename = %s; line = %d; column = %d; violation = %s;\n", - location->filename, location->line, location->column, violation); + panic("filename = %s; line = %d; column = %d; violation = %s;\n", + location->filename, location->line, location->column, violation); } -#define ABORT_VARIANT(name, params, call) \ -__attribute__((noreturn)) \ -void __ubsan_handle_##name##_abort params \ -{ \ - __ubsan_handle_##name call; \ - __builtin_unreachable(); \ -} +#define ABORT_VARIANT(name, params, call) \ + __attribute__((noreturn)) void __ubsan_handle_##name##_abort params \ + { \ + __ubsan_handle_##name call; \ + __builtin_unreachable(); \ + } -#define ABORT_VARIANT_VP(name) \ -ABORT_VARIANT(name, (void* a), (a)) +#define ABORT_VARIANT_VP(name) ABORT_VARIANT(name, (void *a), (a)) #define ABORT_VARIANT_VP_VP(name) \ -ABORT_VARIANT(name, (void* a, void* b), (a, b)) + ABORT_VARIANT(name, (void *a, void *b), (a, b)) #define ABORT_VARIANT_VP_IP(name) \ -ABORT_VARIANT(name, (void* a, intptr_t b), (a, b)) + ABORT_VARIANT(name, (void *a, intptr_t b), (a, b)) #define ABORT_VARIANT_VP_VP_VP(name) \ -ABORT_VARIANT(name, (void* a, void* b, void* c), (a, b, c)) + ABORT_VARIANT(name, (void *a, void *b, void *c), (a, b, c)) -struct ubsan_type_mismatch_v1_data -{ +struct ubsan_type_mismatch_v1_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* type; + struct ubsan_type_descriptor *type; uintptr_t alignment; unsigned char type_check_kind; }; -void __ubsan_handle_type_mismatch_v1(void* data_raw, - void* pointer_raw) +void __ubsan_handle_type_mismatch_v1(void *data_raw, void *pointer_raw) { - struct ubsan_type_mismatch_v1_data* data = - (struct ubsan_type_mismatch_v1_data*) data_raw; - ubsan_value_handle_t pointer = (ubsan_value_handle_t) pointer_raw; - const char* violation = "type mismatch"; - if ( !pointer ) + struct ubsan_type_mismatch_v1_data *data = + (struct ubsan_type_mismatch_v1_data *)data_raw; + ubsan_value_handle_t pointer = (ubsan_value_handle_t)pointer_raw; + const char *violation = "type mismatch"; + if (!pointer) violation = "null pointer access"; - else if ( data->alignment && (pointer & (data->alignment - 1)) ) + else if (data->alignment && (pointer & (data->alignment - 1))) violation = "unaligned access"; ubsan_abort(&data->location, violation); } ABORT_VARIANT_VP_VP(type_mismatch_v1); -struct ubsan_overflow_data -{ +struct ubsan_overflow_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* type; + struct ubsan_type_descriptor *type; }; -void __ubsan_handle_pointer_overflow(void* data_raw, - void* lhs_raw, - void* rhs_raw) +void __ubsan_handle_pointer_overflow(void *data_raw, void *lhs_raw, + void *rhs_raw) { - struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw; - ubsan_value_handle_t lhs = (ubsan_value_handle_t) lhs_raw; - ubsan_value_handle_t rhs = (ubsan_value_handle_t) rhs_raw; - (void) lhs; - (void) rhs; + struct ubsan_overflow_data *data = + (struct ubsan_overflow_data *)data_raw; + ubsan_value_handle_t lhs = (ubsan_value_handle_t)lhs_raw; + ubsan_value_handle_t rhs = (ubsan_value_handle_t)rhs_raw; + (void)lhs; + (void)rhs; ubsan_abort(&data->location, "pointer overflow"); } ABORT_VARIANT_VP_VP_VP(pointer_overflow); -void __ubsan_handle_add_overflow(void* data_raw, - void* lhs_raw, - void* rhs_raw) +void __ubsan_handle_add_overflow(void *data_raw, void *lhs_raw, void *rhs_raw) { - struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw; - ubsan_value_handle_t lhs = (ubsan_value_handle_t) lhs_raw; - ubsan_value_handle_t rhs = (ubsan_value_handle_t) rhs_raw; - (void) lhs; - (void) rhs; + struct ubsan_overflow_data *data = + (struct ubsan_overflow_data *)data_raw; + ubsan_value_handle_t lhs = (ubsan_value_handle_t)lhs_raw; + ubsan_value_handle_t rhs = (ubsan_value_handle_t)rhs_raw; + (void)lhs; + (void)rhs; ubsan_abort(&data->location, "addition overflow"); } ABORT_VARIANT_VP_VP_VP(add_overflow); -void __ubsan_handle_sub_overflow(void* data_raw, - void* lhs_raw, - void* rhs_raw) +void __ubsan_handle_sub_overflow(void *data_raw, void *lhs_raw, void *rhs_raw) { - struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw; - ubsan_value_handle_t lhs = (ubsan_value_handle_t) lhs_raw; - ubsan_value_handle_t rhs = (ubsan_value_handle_t) rhs_raw; - (void) lhs; - (void) rhs; + struct ubsan_overflow_data *data = + (struct ubsan_overflow_data *)data_raw; + ubsan_value_handle_t lhs = (ubsan_value_handle_t)lhs_raw; + ubsan_value_handle_t rhs = (ubsan_value_handle_t)rhs_raw; + (void)lhs; + (void)rhs; ubsan_abort(&data->location, "subtraction overflow"); } ABORT_VARIANT_VP_VP_VP(sub_overflow); -void __ubsan_handle_mul_overflow(void* data_raw, - void* lhs_raw, - void* rhs_raw) +void __ubsan_handle_mul_overflow(void *data_raw, void *lhs_raw, void *rhs_raw) { - struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw; - ubsan_value_handle_t lhs = (ubsan_value_handle_t) lhs_raw; - ubsan_value_handle_t rhs = (ubsan_value_handle_t) rhs_raw; - (void) lhs; - (void) rhs; + struct ubsan_overflow_data *data = + (struct ubsan_overflow_data *)data_raw; + ubsan_value_handle_t lhs = (ubsan_value_handle_t)lhs_raw; + ubsan_value_handle_t rhs = (ubsan_value_handle_t)rhs_raw; + (void)lhs; + (void)rhs; ubsan_abort(&data->location, "multiplication overflow"); } ABORT_VARIANT_VP_VP_VP(mul_overflow); -void __ubsan_handle_negate_overflow(void* data_raw, - void* old_value_raw) +void __ubsan_handle_negate_overflow(void *data_raw, void *old_value_raw) { - struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw; - ubsan_value_handle_t old_value = (ubsan_value_handle_t) old_value_raw; - (void) old_value; + struct ubsan_overflow_data *data = + (struct ubsan_overflow_data *)data_raw; + ubsan_value_handle_t old_value = (ubsan_value_handle_t)old_value_raw; + (void)old_value; ubsan_abort(&data->location, "negation overflow"); } ABORT_VARIANT_VP_VP(negate_overflow); -void __ubsan_handle_divrem_overflow(void* data_raw, - void* lhs_raw, - void* rhs_raw) +void __ubsan_handle_divrem_overflow(void *data_raw, void *lhs_raw, + void *rhs_raw) { - struct ubsan_overflow_data* data = (struct ubsan_overflow_data*) data_raw; - ubsan_value_handle_t lhs = (ubsan_value_handle_t) lhs_raw; - ubsan_value_handle_t rhs = (ubsan_value_handle_t) rhs_raw; - (void) lhs; - (void) rhs; + struct ubsan_overflow_data *data = + (struct ubsan_overflow_data *)data_raw; + ubsan_value_handle_t lhs = (ubsan_value_handle_t)lhs_raw; + ubsan_value_handle_t rhs = (ubsan_value_handle_t)rhs_raw; + (void)lhs; + (void)rhs; ubsan_abort(&data->location, "division remainder overflow"); } ABORT_VARIANT_VP_VP_VP(divrem_overflow); -struct ubsan_shift_out_of_bounds_data -{ +struct ubsan_shift_out_of_bounds_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* lhs_type; - struct ubsan_type_descriptor* rhs_type; + struct ubsan_type_descriptor *lhs_type; + struct ubsan_type_descriptor *rhs_type; }; -void __ubsan_handle_shift_out_of_bounds(void* data_raw, - void* lhs_raw, - void* rhs_raw) +void __ubsan_handle_shift_out_of_bounds(void *data_raw, void *lhs_raw, + void *rhs_raw) { - struct ubsan_shift_out_of_bounds_data* data = - (struct ubsan_shift_out_of_bounds_data*) data_raw; - ubsan_value_handle_t lhs = (ubsan_value_handle_t) lhs_raw; - ubsan_value_handle_t rhs = (ubsan_value_handle_t) rhs_raw; - (void) lhs; - (void) rhs; + struct ubsan_shift_out_of_bounds_data *data = + (struct ubsan_shift_out_of_bounds_data *)data_raw; + ubsan_value_handle_t lhs = (ubsan_value_handle_t)lhs_raw; + ubsan_value_handle_t rhs = (ubsan_value_handle_t)rhs_raw; + (void)lhs; + (void)rhs; ubsan_abort(&data->location, "shift out of bounds"); } ABORT_VARIANT_VP_VP_VP(shift_out_of_bounds); -struct ubsan_out_of_bounds_data -{ +struct ubsan_out_of_bounds_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* array_type; - struct ubsan_type_descriptor* index_type; + struct ubsan_type_descriptor *array_type; + struct ubsan_type_descriptor *index_type; }; -void __ubsan_handle_out_of_bounds(void* data_raw, - void* index_raw) +void __ubsan_handle_out_of_bounds(void *data_raw, void *index_raw) { - struct ubsan_out_of_bounds_data* data = - (struct ubsan_out_of_bounds_data*) data_raw; - ubsan_value_handle_t index = (ubsan_value_handle_t) index_raw; - (void) index; + struct ubsan_out_of_bounds_data *data = + (struct ubsan_out_of_bounds_data *)data_raw; + ubsan_value_handle_t index = (ubsan_value_handle_t)index_raw; + (void)index; ubsan_abort(&data->location, "out of bounds"); } ABORT_VARIANT_VP_VP(out_of_bounds); -struct ubsan_unreachable_data -{ +struct ubsan_unreachable_data { struct ubsan_source_location location; }; -__attribute__((noreturn)) -void __ubsan_handle_builtin_unreachable(void* data_raw) +__attribute__((noreturn)) void +__ubsan_handle_builtin_unreachable(void *data_raw) { - struct ubsan_unreachable_data* data = - (struct ubsan_unreachable_data*) data_raw; + struct ubsan_unreachable_data *data = + (struct ubsan_unreachable_data *)data_raw; ubsan_abort(&data->location, "reached unreachable"); } -__attribute__((noreturn)) -void __ubsan_handle_missing_return(void* data_raw) +__attribute__((noreturn)) void __ubsan_handle_missing_return(void *data_raw) { - struct ubsan_unreachable_data* data = - (struct ubsan_unreachable_data*) data_raw; + struct ubsan_unreachable_data *data = + (struct ubsan_unreachable_data *)data_raw; ubsan_abort(&data->location, "missing return"); } -struct ubsan_vla_bound_data -{ +struct ubsan_vla_bound_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* type; + struct ubsan_type_descriptor *type; }; -void __ubsan_handle_vla_bound_not_positive(void* data_raw, - void* bound_raw) +void __ubsan_handle_vla_bound_not_positive(void *data_raw, void *bound_raw) { - struct ubsan_vla_bound_data* data = (struct ubsan_vla_bound_data*) data_raw; - ubsan_value_handle_t bound = (ubsan_value_handle_t) bound_raw; - (void) bound; + struct ubsan_vla_bound_data *data = + (struct ubsan_vla_bound_data *)data_raw; + ubsan_value_handle_t bound = (ubsan_value_handle_t)bound_raw; + (void)bound; ubsan_abort(&data->location, "negative variable array length"); } ABORT_VARIANT_VP_VP(vla_bound_not_positive); -struct ubsan_float_cast_overflow_data -{ +struct ubsan_float_cast_overflow_data { // TODO: Remove this GCC 5.x compatibility after switching to GCC 6.x. The // GCC developers accidentally forgot the source location. Their // libubsan probes to see if it looks like a path, but we don't need // to maintain compatibility with multiple gcc releases. See below. -#if !(defined(__GNUC__) && __GNUC__< 6) +#if !(defined(__GNUC__) && __GNUC__ < 6) struct ubsan_source_location location; #endif - struct ubsan_type_descriptor* from_type; - struct ubsan_type_descriptor* to_type; + struct ubsan_type_descriptor *from_type; + struct ubsan_type_descriptor *to_type; }; -void __ubsan_handle_float_cast_overflow(void* data_raw, - void* from_raw) +void __ubsan_handle_float_cast_overflow(void *data_raw, void *from_raw) { - struct ubsan_float_cast_overflow_data* data = - (struct ubsan_float_cast_overflow_data*) data_raw; - ubsan_value_handle_t from = (ubsan_value_handle_t) from_raw; - (void) from; -#if !(defined(__GNUC__) && __GNUC__< 6) + struct ubsan_float_cast_overflow_data *data = + (struct ubsan_float_cast_overflow_data *)data_raw; + ubsan_value_handle_t from = (ubsan_value_handle_t)from_raw; + (void)from; +#if !(defined(__GNUC__) && __GNUC__ < 6) ubsan_abort(&data->location, "float cast overflow"); #else - ubsan_abort(((void) data, &unknown_location), "float cast overflow"); + ubsan_abort(((void)data, &unknown_location), "float cast overflow"); #endif } ABORT_VARIANT_VP_VP(float_cast_overflow); -struct ubsan_invalid_value_data -{ +struct ubsan_invalid_value_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* type; + struct ubsan_type_descriptor *type; }; -void __ubsan_handle_load_invalid_value(void* data_raw, - void* value_raw) +void __ubsan_handle_load_invalid_value(void *data_raw, void *value_raw) { - struct ubsan_invalid_value_data* data = - (struct ubsan_invalid_value_data*) data_raw; - ubsan_value_handle_t value = (ubsan_value_handle_t) value_raw; - (void) value; + struct ubsan_invalid_value_data *data = + (struct ubsan_invalid_value_data *)data_raw; + ubsan_value_handle_t value = (ubsan_value_handle_t)value_raw; + (void)value; ubsan_abort(&data->location, "invalid value load"); } ABORT_VARIANT_VP_VP(load_invalid_value); -struct ubsan_function_type_mismatch_v1_data -{ +struct ubsan_function_type_mismatch_v1_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* type; + struct ubsan_type_descriptor *type; }; -void __ubsan_handle_function_type_mismatch_v1(void* data_raw, - void* value_raw) +void __ubsan_handle_function_type_mismatch_v1(void *data_raw, void *value_raw) { - struct ubsan_function_type_mismatch_v1_data* data = - (struct ubsan_function_type_mismatch_v1_data*) data_raw; - ubsan_value_handle_t value = (ubsan_value_handle_t) value_raw; - (void) value; + struct ubsan_function_type_mismatch_v1_data *data = + (struct ubsan_function_type_mismatch_v1_data *)data_raw; + ubsan_value_handle_t value = (ubsan_value_handle_t)value_raw; + (void)value; ubsan_abort(&data->location, "function type mismatch"); } ABORT_VARIANT_VP_VP(function_type_mismatch_v1); -struct ubsan_nonnull_return_data -{ +struct ubsan_nonnull_return_data { struct ubsan_source_location location; struct ubsan_source_location attr_location; }; -void __ubsan_handle_nonnull_return(void* data_raw) +void __ubsan_handle_nonnull_return(void *data_raw) { - struct ubsan_nonnull_return_data* data = - (struct ubsan_nonnull_return_data*) data_raw; + struct ubsan_nonnull_return_data *data = + (struct ubsan_nonnull_return_data *)data_raw; ubsan_abort(&data->location, "null return"); } ABORT_VARIANT_VP(nonnull_return); -struct ubsan_nonnull_arg_data -{ +struct ubsan_nonnull_arg_data { struct ubsan_source_location location; struct ubsan_source_location attr_location; }; // TODO: GCC's libubsan does not have the second parameter, but its builtin // somehow has it and conflict if we don't match it. -void __ubsan_handle_nonnull_arg(void* data_raw, - intptr_t index_raw) +void __ubsan_handle_nonnull_arg(void *data_raw, intptr_t index_raw) { - struct ubsan_nonnull_arg_data* data = - (struct ubsan_nonnull_arg_data*) data_raw; - ubsan_value_handle_t index = (ubsan_value_handle_t) index_raw; - (void) index; + struct ubsan_nonnull_arg_data *data = + (struct ubsan_nonnull_arg_data *)data_raw; + ubsan_value_handle_t index = (ubsan_value_handle_t)index_raw; + (void)index; ubsan_abort(&data->location, "null argument"); } ABORT_VARIANT_VP_IP(nonnull_arg); -struct ubsan_cfi_bad_icall_data -{ +struct ubsan_cfi_bad_icall_data { struct ubsan_source_location location; - struct ubsan_type_descriptor* type; + struct ubsan_type_descriptor *type; }; -void __ubsan_handle_cfi_bad_icall(void* data_raw, - void* value_raw) +void __ubsan_handle_cfi_bad_icall(void *data_raw, void *value_raw) { - struct ubsan_cfi_bad_icall_data* data = - (struct ubsan_cfi_bad_icall_data*) data_raw; - ubsan_value_handle_t value = (ubsan_value_handle_t) value_raw; - (void) value; - ubsan_abort(&data->location, - "control flow integrity check failure during indirect call"); + struct ubsan_cfi_bad_icall_data *data = + (struct ubsan_cfi_bad_icall_data *)data_raw; + ubsan_value_handle_t value = (ubsan_value_handle_t)value_raw; + (void)value; + ubsan_abort( + &data->location, + "control flow integrity check failure during indirect call"); } ABORT_VARIANT_VP_VP(cfi_bad_icall); diff --git a/kernel/src/cpu/gdt.c b/kernel/src/cpu/gdt.c index 58db962..7460474 100644 --- a/kernel/src/cpu/gdt.c +++ b/kernel/src/cpu/gdt.c @@ -4,7 +4,8 @@ gdt_seg_entry gdt[7]; gdt_p gdt_pointer; -void add_gdt_entry(uint32_t num, uint32_t offset, uint32_t limit, uint8_t access, uint8_t flags) +void add_gdt_entry(uint32_t num, uint32_t offset, uint32_t limit, + uint8_t access, uint8_t flags) { gdt[num].offset1 = offset & 0xffff; gdt[num].offset2 = (offset >> 16) & 0xff; @@ -15,31 +16,31 @@ void add_gdt_entry(uint32_t num, uint32_t offset, uint32_t limit, uint8_t access gdt[num].limitflags = (uint8_t)(flags << 4); } -void add_gdt_tss(uint32_t num, uint64_t offset, uint32_t limit, uint8_t access, uint8_t flags) +void add_gdt_tss(uint32_t num, uint64_t offset, uint32_t limit, uint8_t access, + uint8_t flags) { uint32_t offset_low = (offset & 0xffffffff); uint32_t offset_high = (uint32_t)(offset >> 32); add_gdt_entry(num, offset_low, limit, access, flags); - gdt[num+1].limit = (offset_high & 0xffff); - gdt[num+1].offset1 = (uint16_t)(offset_high >> 16); + gdt[num + 1].limit = (offset_high & 0xffff); + gdt[num + 1].offset1 = (uint16_t)(offset_high >> 16); } void reload_gdt() { - __asm__ __volatile__ ( - // reload segment registers - "mov $0x10, %ax;" - "mov %ax, %ds;" - "mov %ax, %es;" - "mov %ax, %ss;" - "mov %ax, %fs;" - "mov %ax, %gs;" - ); + __asm__ __volatile__( + // reload segment registers + "mov $0x10, %ax;" + "mov %ax, %ds;" + "mov %ax, %es;" + "mov %ax, %ss;" + "mov %ax, %fs;" + "mov %ax, %gs;"); } -void load_gdt(gdt_p* pointer) +void load_gdt(gdt_p *pointer) { - __asm__ __volatile__ ("lgdt (%0);" : : "r"(pointer) : ); + __asm__ __volatile__("lgdt (%0);" : : "r"(pointer) :); reload_gdt(); } diff --git a/kernel/src/cpu/idt.c b/kernel/src/cpu/idt.c index 1b0fffb..9134d84 100644 --- a/kernel/src/cpu/idt.c +++ b/kernel/src/cpu/idt.c @@ -1,5 +1,4 @@ #include <idt.h> - #include <irq.h> #include <pic.h> @@ -8,17 +7,17 @@ idtp idt_pointer; void enable_interrupts(void) { - __asm__ __volatile__ ("sti;"); + __asm__ __volatile__("sti;"); } void disable_interrupts(void) { - __asm__ __volatile__ ("cli;"); + __asm__ __volatile__("cli;"); } -void load_idt(idtp* pointer) +void load_idt(idtp *pointer) { - __asm__ __volatile__ ("lidt (%0);" : : "r"(pointer) : ); + __asm__ __volatile__("lidt (%0);" : : "r"(pointer) :); } void add_to_idt(uint16_t num, uint64_t offset, uint16_t selector, uint8_t type) @@ -72,7 +71,8 @@ void init_idt_table(void) add_to_idt(32, (uint64_t)irq0, GDT_CODE_SEG, INTERRUPT_GATE); add_to_idt(33, (uint64_t)irq1, GDT_CODE_SEG, INTERRUPT_GATE); for (size_t i = 34; i < 256; i++) { - add_to_idt((uint16_t)i, (uint64_t)irq2, GDT_CODE_SEG, INTERRUPT_GATE); + add_to_idt((uint16_t)i, (uint64_t)irq2, GDT_CODE_SEG, + INTERRUPT_GATE); } } diff --git a/kernel/src/cpu/io.c b/kernel/src/cpu/io.c index 4b5e5ac..e638ae7 100644 --- a/kernel/src/cpu/io.c +++ b/kernel/src/cpu/io.c @@ -4,13 +4,13 @@ uint8_t inb(uint32_t port) { uint8_t ret; - __asm__ __volatile__ ("inb %%dx, %%al;" : "=a"(ret) : "d"(port)); + __asm__ __volatile__("inb %%dx, %%al;" : "=a"(ret) : "d"(port)); return ret; } void outb(uint32_t port, uint8_t value) { - __asm__ __volatile__ ("outb %%al, %%dx;" : : "d"(port), "a"(value)); + __asm__ __volatile__("outb %%al, %%dx;" : : "d"(port), "a"(value)); } void io_wait(void) diff --git a/kernel/src/cpu/irq.c b/kernel/src/cpu/irq.c index e5f811c..5eadd39 100644 --- a/kernel/src/cpu/irq.c +++ b/kernel/src/cpu/irq.c @@ -1,6 +1,5 @@ #include <types.h> #include <irq_handler.h> - #include <pic.h> #include <io.h> #include <keyboard.h> @@ -13,7 +12,7 @@ #define PIT 0 -const char* const exception_name[] = { +const char *const exception_name[] = { "Divide-by-zero Error", "Debug", "Non-maskable Interrupt", @@ -50,13 +49,13 @@ const char* const exception_name[] = { void isr_def_handler(uint64_t number, uint64_t error) { - switch(number) { - case 14: - printf("%s, error: 0x%x\n", exception_name[14], error); - page_fault(error); - break; - default: - panic("%s, error: 0x%x\n", exception_name[number], error); + switch (number) { + case 14: + printf("%s, error: 0x%x\n", exception_name[14], error); + page_fault(error); + break; + default: + panic("%s, error: 0x%x\n", exception_name[number], error); } } @@ -76,17 +75,16 @@ void eoi(uint64_t number) void irq_def_handler(uint64_t number) { - switch(number) - { - case 0: - timer_handler(); - break; - case 1: - keyboard_handler(); - break; - default: - printf("spurious interrupt\n"); - break; + switch (number) { + case 0: + timer_handler(); + break; + case 1: + keyboard_handler(); + break; + default: + printf("spurious interrupt\n"); + break; } eoi(number); } diff --git a/kernel/src/cpu/kcpuid.c b/kernel/src/cpu/kcpuid.c index 30a4d3e..c400be4 100644 --- a/kernel/src/cpu/kcpuid.c +++ b/kernel/src/cpu/kcpuid.c @@ -1,7 +1,11 @@ #include <types.h> #include <kcpuid.h> -void kcpuid(uint32_t func, uint32_t subfunc, CPUIDinfo* info) +void kcpuid(uint32_t func, uint32_t subfunc, CPUIDinfo *info) { - __asm__ __volatile__ ( "cpuid" : "=a"(info->EAX), "=b"(info->EBX), "=c"(info->ECX), "=d"(info->EDX) : "a"(func), "c"(subfunc) : ); + __asm__ __volatile__("cpuid" + : "=a"(info->EAX), "=b"(info->EBX), + "=c"(info->ECX), "=d"(info->EDX) + : "a"(func), "c"(subfunc) + :); } diff --git a/kernel/src/cpu/msr.c b/kernel/src/cpu/msr.c index e904d5f..d61b218 100644 --- a/kernel/src/cpu/msr.c +++ b/kernel/src/cpu/msr.c @@ -6,7 +6,7 @@ uint64_t read_msr(uint32_t addr) uint64_t edx; uint64_t ecx = addr; - __asm__ __volatile__ ("rdmsr;" : "=a"(eax), "=d"(edx) : "c"(ecx) :); + __asm__ __volatile__("rdmsr;" : "=a"(eax), "=d"(edx) : "c"(ecx) :); return (edx << 32) | eax; } @@ -17,5 +17,5 @@ void write_msr(uint32_t addr, uint64_t value) uint64_t edx = value >> 32; uint64_t ecx = addr; - __asm__ __volatile__ ("wrmsr;" : : "a"(eax), "d"(edx), "c"(ecx) :); + __asm__ __volatile__("wrmsr;" : : "a"(eax), "d"(edx), "c"(ecx) :); } diff --git a/kernel/src/cpu/pic.c b/kernel/src/cpu/pic.c index 83bb524..cfcc4d5 100644 --- a/kernel/src/cpu/pic.c +++ b/kernel/src/cpu/pic.c @@ -6,10 +6,12 @@ void remap_pic(void) // starts the initialization sequence (in cascade mode) outb(PIC1_COMMAND, ICW1_INIT | ICW1_ICW4); outb(PIC2_COMMAND, ICW1_INIT | ICW1_ICW4); - outb(PIC1_DATA, 0xe0); // ICW2: Master PIC vector offset - outb(PIC2_DATA, 0xe8); // ICW2: Slave PIC vector offset - outb(PIC1_DATA, 4); // ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100) - outb(PIC2_DATA, 2); // ICW3: tell Slave PIC its cascade identity (0000 0010) + outb(PIC1_DATA, 0xe0); // ICW2: Master PIC vector offset + outb(PIC2_DATA, 0xe8); // ICW2: Slave PIC vector offset + outb(PIC1_DATA, + 4); // ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100) + outb(PIC2_DATA, + 2); // ICW3: tell Slave PIC its cascade identity (0000 0010) outb(PIC1_DATA, ICW4_8086); outb(PIC2_DATA, ICW4_8086); diff --git a/kernel/src/cpu/tss.c b/kernel/src/cpu/tss.c index 03b3475..cdfe2cc 100644 --- a/kernel/src/cpu/tss.c +++ b/kernel/src/cpu/tss.c @@ -7,14 +7,14 @@ tss_type tss; void load_tss() { - __asm__ __volatile__ ("push %rax; mov $0x28, %ax; ltr %ax; pop %rax;"); + __asm__ __volatile__("push %rax; mov $0x28, %ax; ltr %ax; pop %rax;"); } void init_tss() { memset(&tss, 0, sizeof(tss_type)); tss.iopb = sizeof(tss_type); - uint32_t stack_size = 4096*4; + uint32_t stack_size = 4096 * 4; uint64_t stack = (uint64_t)kalloc(stack_size) + stack_size - 8; tss.rsp0_low = (uint32_t)stack; tss.rsp0_high = (uint32_t)(stack >> 32); diff --git a/kernel/src/devices/disc.c b/kernel/src/devices/disc.c index b378fc1..75ed1ef 100644 --- a/kernel/src/devices/disc.c +++ b/kernel/src/devices/disc.c @@ -4,25 +4,24 @@ #include <paging.h> #include <libk/math.h> #include <kernel_vma.h> +#include <libk/stdio.h> -#include <libk/serial_stdio.h> - -disc_sector_t* disc; +disc_sector_t *disc; void disc_init() { - disc = (disc_sector_t*)((uint64_t)ext2_module->mod_start + KERNEL_VMA); + disc = (disc_sector_t *)((uint64_t)ext2_module->mod_start + KERNEL_VMA); if (disc == NULL) { printf("Error opening disc\n"); } } -void read_sector(size_t sector_num, disc_sector_t* disc_sector) +void read_sector(size_t sector_num, disc_sector_t *disc_sector) { memcpy(disc_sector, disc + sector_num, SECTOR_SIZE); } -void write_sector(size_t sector_num, disc_sector_t* disc_sector) +void write_sector(size_t sector_num, disc_sector_t *disc_sector) { memcpy(disc + sector_num, disc_sector, SECTOR_SIZE); } diff --git a/kernel/src/devices/keyboard.c b/kernel/src/devices/keyboard.c index 549a0ca..67c2f19 100644 --- a/kernel/src/devices/keyboard.c +++ b/kernel/src/devices/keyboard.c @@ -7,23 +7,23 @@ #include <libk/stdio.h> #include <libk/math.h> #include <libk/string.h> +#include <stdbuff.h> +#include <heap.h> bool is_pressed[128]; -#include <stdbuff.h> -#include <heap.h> #define BUFFER_SIZE 10000 -stdbuff* keyboard_buffer; +stdbuff *keyboard_buffer; void init_keyboard() { -// outb(KEYBOARD_CMD_PORT, 0xF3); -// io_wait(); -// outb(KEYBOARD_DATA_PORT, 0x00); -// io_wait(); -// while (!(inb(KEYBOARD_STATUS_PORT) & 1)) {} -// if (inb(KEYBOARD_DATA_PORT) == 0xFA) -// printf("[keyboard init]\n"); + // outb(KEYBOARD_CMD_PORT, 0xF3); + // io_wait(); + // outb(KEYBOARD_DATA_PORT, 0x00); + // io_wait(); + // while (!(inb(KEYBOARD_STATUS_PORT) & 1)) {} + // if (inb(KEYBOARD_DATA_PORT) == 0xFA) + // printf("[keyboard init]\n"); } void keyboard_handler() @@ -48,13 +48,14 @@ void keyboard_handler() if (main_fb.x != 0) write_buff(keyboard_buffer, "\b \b", 3); } else if (keycode == KEY_ENTER) { - char* output = kalloc(sizeof(char) + 1); + char *output = kalloc(sizeof(char) + 1); output[0] = keymap[keycode]; write_buff(keyboard_buffer, output, 1); kfree(output); } else { - char* output = kalloc(sizeof(char) + 1); - if (keymap[keycode] == ' ') return; + char *output = kalloc(sizeof(char) + 1); + if (keymap[keycode] == ' ') + return; if (is_pressed[KEY_LSHIFT] || is_pressed[KEY_RSHIFT]) output[0] = shift_keymap[keycode]; else @@ -66,8 +67,13 @@ void keyboard_handler() is_pressed[keycode - 128] = false; } - uint32_t len = (uint32_t)(keyboard_buffer->head >= keyboard_buffer->tail ? keyboard_buffer->head - keyboard_buffer->tail : BUFFER_SIZE + keyboard_buffer->head - keyboard_buffer->tail); - char* print_buff = kalloc(len + 1); + uint32_t len = + (uint32_t)(keyboard_buffer->head >= keyboard_buffer->tail ? + keyboard_buffer->head - + keyboard_buffer->tail : + BUFFER_SIZE + keyboard_buffer->head - + keyboard_buffer->tail); + char *print_buff = kalloc(len + 1); read_buff(keyboard_buffer, print_buff, len); printf("%s", print_buff); kfree(print_buff); diff --git a/kernel/src/devices/serial.c b/kernel/src/devices/serial.c index 76bc71a..2d2da51 100644 --- a/kernel/src/devices/serial.c +++ b/kernel/src/devices/serial.c @@ -3,13 +3,13 @@ void init_serial() { - outb(PORT + 1, 0x00); // Disable all interrupts - outb(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor) - outb(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud - outb(PORT + 1, 0x00); // (hi byte) - outb(PORT + 3, 0x03); // 8 bits, no parity, one stop bit - outb(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold - outb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set + outb(PORT + 1, 0x00); // Disable all interrupts + outb(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor) + outb(PORT + 0, 0x03); // Set divisor to 3 (lo byte) 38400 baud + outb(PORT + 1, 0x00); // (hi byte) + outb(PORT + 3, 0x03); // 8 bits, no parity, one stop bit + outb(PORT + 2, 0xC7); // Enable FIFO, clear them, with 14-byte threshold + outb(PORT + 4, 0x0B); // IRQs enabled, RTS/DSR set } uint8_t serial_received() @@ -19,7 +19,8 @@ uint8_t serial_received() char read_serial() { - while (serial_received() == 0); + while (serial_received() == 0) + ; return (char)inb(PORT); } @@ -31,7 +32,8 @@ uint8_t is_transmit_empty() void write_serial(char c) { - while (is_transmit_empty() == 0); + while (is_transmit_empty() == 0) + ; outb(PORT, (uint8_t)c); } diff --git a/kernel/src/devices/timer.c b/kernel/src/devices/timer.c index c2fa887..f6463ab 100644 --- a/kernel/src/devices/timer.c +++ b/kernel/src/devices/timer.c @@ -18,7 +18,7 @@ wait_queue timer_queue; void timer_handler() { - wait_queue* pos; + wait_queue *pos; list_for_each_entry(pos, (&timer_queue.list), list) { pos->ticks--; } @@ -33,12 +33,13 @@ void timer_handler() void wait(uint64_t ms) { disable_interrupts(); - wait_queue* queue = (wait_queue*)kalloc(sizeof(wait_queue)); + wait_queue *queue = (wait_queue *)kalloc(sizeof(wait_queue)); queue->ticks = (int64_t)ms; add_to_list(&queue->list, &timer_queue.list, timer_queue.list.next); enable_interrupts(); - while (queue->ticks > 0) ; + while (queue->ticks > 0) + ; kfree(queue); free_node(&queue->list); @@ -52,7 +53,7 @@ void init_timer(uint32_t frequency) outb(0x43, 0x36); uint8_t l = (uint8_t)(divisor & 0xFF); - uint8_t h = (uint8_t)((divisor>>8) & 0xFF); + uint8_t h = (uint8_t)((divisor >> 8) & 0xFF); outb(0x40, l); outb(0x40, h); diff --git a/kernel/src/fs/ext2.c b/kernel/src/fs/ext2.c index 72eb776..7750a50 100644 --- a/kernel/src/fs/ext2.c +++ b/kernel/src/fs/ext2.c @@ -5,32 +5,34 @@ #include <disc.h> #include <ext2.h> -ext2_superblock_t* ext2_superblock; +ext2_superblock_t *ext2_superblock; -void read_block(uint32_t block_num, void* block_ptr) +void read_block(uint32_t block_num, void *block_ptr) { uint32_t sectors_per_block = BLOCK_SIZE / SECTOR_SIZE; for (size_t i = 0; i < sectors_per_block; i++) { - read_sector(block_num * sectors_per_block + i, (disc_sector_t*)block_ptr + i); + read_sector(block_num * sectors_per_block + i, + (disc_sector_t *)block_ptr + i); } } -void read_superblock(ext2_superblock_t* superblock) +void read_superblock(ext2_superblock_t *superblock) { char block[1024]; - read_sector(2, (disc_sector_t*)block); - read_sector(3, (disc_sector_t*)block + 1); + read_sector(2, (disc_sector_t *)block); + read_sector(3, (disc_sector_t *)block + 1); memcpy(superblock, block, sizeof(ext2_superblock_t)); } void ext2_init() { - ext2_superblock = (ext2_superblock_t*)kalloc(sizeof(ext2_superblock_t)); + ext2_superblock = + (ext2_superblock_t *)kalloc(sizeof(ext2_superblock_t)); read_superblock(ext2_superblock); } -void read_bg_desc(uint32_t bg_desc, ext2_bg_desc_t* ext2_bg_desc) +void read_bg_desc(uint32_t bg_desc, ext2_bg_desc_t *ext2_bg_desc) { uint32_t starting_block_num = BLOCK_SIZE == 1024 ? 2 : 1; uint32_t bg_descs_per_block = BLOCK_SIZE / BG_DESC_SIZE; @@ -39,40 +41,44 @@ void read_bg_desc(uint32_t bg_desc, ext2_bg_desc_t* ext2_bg_desc) char block[BLOCK_SIZE]; read_block(block_num, block); - memcpy(ext2_bg_desc, (char*)block + BG_DESC_SIZE * block_index, sizeof(ext2_bg_desc_t)); + memcpy(ext2_bg_desc, (char *)block + BG_DESC_SIZE * block_index, + sizeof(ext2_bg_desc_t)); } -void read_inode(uint32_t starting_block_num, uint32_t inode_index, ext2_inode_t* ext2_inode) +void read_inode(uint32_t starting_block_num, uint32_t inode_index, + ext2_inode_t *ext2_inode) { - uint32_t block_num = starting_block_num + inode_index / INODES_PER_BLOCK; + uint32_t block_num = + starting_block_num + inode_index / INODES_PER_BLOCK; uint32_t block_index = inode_index % INODES_PER_BLOCK; char block[BLOCK_SIZE]; read_block(block_num, block); - memcpy(ext2_inode, (char*)block + block_index * INODE_SIZE, sizeof(ext2_inode_t)); + memcpy(ext2_inode, (char *)block + block_index * INODE_SIZE, + sizeof(ext2_inode_t)); } -dentry_list_t* directory_to_entries(uint32_t inode) +dentry_list_t *directory_to_entries(uint32_t inode) { - dentry_list_t* dentry_list = (dentry_list_t*)kalloc(sizeof(dentry_list_t)); + dentry_list_t *dentry_list = + (dentry_list_t *)kalloc(sizeof(dentry_list_t)); INIT_LIST(dentry_list->list); if (inode < 2) { return dentry_list; } - uint32_t bg_desc = (inode - 1) / ext2_superblock->inodes_per_group; uint32_t inode_index = (inode - 1) % ext2_superblock->inodes_per_group; // block group descriptor - ext2_bg_desc_t* ext2_bg_desc; - ext2_bg_desc = (ext2_bg_desc_t*)kalloc(sizeof(ext2_bg_desc_t)); + ext2_bg_desc_t *ext2_bg_desc; + ext2_bg_desc = (ext2_bg_desc_t *)kalloc(sizeof(ext2_bg_desc_t)); read_bg_desc(bg_desc, ext2_bg_desc); // inode table - ext2_inode_t* ext2_inode; - ext2_inode = (ext2_inode_t*)kalloc(sizeof(ext2_inode_t)); + ext2_inode_t *ext2_inode; + ext2_inode = (ext2_inode_t *)kalloc(sizeof(ext2_inode_t)); read_inode(ext2_bg_desc->inode_block_address, inode_index, ext2_inode); // if it is not directory @@ -91,8 +97,11 @@ dentry_list_t* directory_to_entries(uint32_t inode) // parse block for (size_t block_offset = 0; block_offset < BLOCK_SIZE;) { // get dentry header - dentry_list_t* ext2_dentry_list = (dentry_list_t*)kalloc(sizeof(dentry_list_t)); - memcpy(&ext2_dentry_list->ext2_dentry, (char*)block + block_offset, sizeof(ext2_dentry_t) - sizeof(char*)); + dentry_list_t *ext2_dentry_list = + (dentry_list_t *)kalloc(sizeof(dentry_list_t)); + memcpy(&ext2_dentry_list->ext2_dentry, + (char *)block + block_offset, + sizeof(ext2_dentry_t) - sizeof(char *)); // dentry is unused if (ext2_dentry_list->ext2_dentry.inode == 0) { @@ -101,26 +110,33 @@ dentry_list_t* directory_to_entries(uint32_t inode) } // get dentry name - ext2_dentry_list->ext2_dentry.name = (char*)kalloc(ext2_dentry_list->ext2_dentry.name_length_lower + 1); - memcpy(ext2_dentry_list->ext2_dentry.name, (char*)block + block_offset + sizeof(ext2_dentry_t) - sizeof(char*), ext2_dentry_list->ext2_dentry.name_length_lower); - ext2_dentry_list->ext2_dentry.name[ext2_dentry_list->ext2_dentry.name_length_lower] = '\0'; + ext2_dentry_list->ext2_dentry.name = (char *)kalloc( + ext2_dentry_list->ext2_dentry.name_length_lower + + 1); + memcpy(ext2_dentry_list->ext2_dentry.name, + (char *)block + block_offset + + sizeof(ext2_dentry_t) - sizeof(char *), + ext2_dentry_list->ext2_dentry.name_length_lower); + ext2_dentry_list->ext2_dentry + .name[ext2_dentry_list->ext2_dentry + .name_length_lower] = '\0'; // put dentry in list - add_to_list(&ext2_dentry_list->list, &dentry_list->list, dentry_list->list.next); + add_to_list(&ext2_dentry_list->list, &dentry_list->list, + dentry_list->list.next); // offset block_offset += ext2_dentry_list->ext2_dentry.size; } } - kfree(ext2_bg_desc); kfree(ext2_inode); return dentry_list; } -char* files_to_buffer(uint32_t inode) +char *files_to_buffer(uint32_t inode) { if (inode < 2) { return NULL; @@ -130,13 +146,13 @@ char* files_to_buffer(uint32_t inode) uint32_t inode_index = (inode - 1) % ext2_superblock->inodes_per_group; // block group descriptor - ext2_bg_desc_t* ext2_bg_desc; - ext2_bg_desc = (ext2_bg_desc_t*)kalloc(sizeof(ext2_bg_desc_t)); + ext2_bg_desc_t *ext2_bg_desc; + ext2_bg_desc = (ext2_bg_desc_t *)kalloc(sizeof(ext2_bg_desc_t)); read_bg_desc(bg_desc, ext2_bg_desc); // inode table - ext2_inode_t* ext2_inode; - ext2_inode = (ext2_inode_t*)kalloc(sizeof(ext2_inode_t)); + ext2_inode_t *ext2_inode; + ext2_inode = (ext2_inode_t *)kalloc(sizeof(ext2_inode_t)); read_inode(ext2_bg_desc->inode_block_address, inode_index, ext2_inode); if (ext2_inode->type_perms & TYPE_DIR) { @@ -146,16 +162,18 @@ char* files_to_buffer(uint32_t inode) return NULL; } - char* data; + char *data; uint32_t size = ext2_inode->size_lower; - data = (char*)kalloc(size + 1); + data = (char *)kalloc(size + 1); uint32_t block_num = upper_div(size, BLOCK_SIZE); for (size_t i = 0; i < min(block_num, 12); i++) { char block[BLOCK_SIZE]; read_block(ext2_inode->dbp[i], block); - memcpy(data + i * BLOCK_SIZE, block, size >= (i + 1) * BLOCK_SIZE ? BLOCK_SIZE : size % BLOCK_SIZE); + memcpy(data + i * BLOCK_SIZE, block, + size >= (i + 1) * BLOCK_SIZE ? BLOCK_SIZE : + size % BLOCK_SIZE); } data[size] = '\0'; @@ -165,10 +183,10 @@ char* files_to_buffer(uint32_t inode) return data; } -path_t* path_to_list(const char* path) +path_t *path_to_list(const char *path) { size_t i, j; - path_t* divided_path = (path_t*)kalloc(sizeof(path_t)); + path_t *divided_path = (path_t *)kalloc(sizeof(path_t)); INIT_LIST(divided_path->list) size_t n = strlen(path); @@ -176,19 +194,27 @@ path_t* path_to_list(const char* path) if (i == n || path[i] == '/') { // add data before slash if (i != j) { - path_t* curr_path = (path_t*)kalloc(sizeof(path_t)); - curr_path->name = (char*)kalloc(sizeof(char) * (uint32_t)(i - j + 1)); + path_t *curr_path = + (path_t *)kalloc(sizeof(path_t)); + curr_path->name = (char *)kalloc( + sizeof(char) * (uint32_t)(i - j + 1)); memcpy(curr_path->name, path + j, i - j); curr_path->name[i - j] = '\0'; - add_to_list(&curr_path->list, ÷d_path->list, divided_path->list.next); + add_to_list(&curr_path->list, + ÷d_path->list, + divided_path->list.next); } // add slash if (i != n) { - path_t* curr_path = (path_t*)kalloc(sizeof(path_t)); - curr_path->name = (char*)kalloc(sizeof(char) * 2); + path_t *curr_path = + (path_t *)kalloc(sizeof(path_t)); + curr_path->name = + (char *)kalloc(sizeof(char) * 2); curr_path->name[0] = '/'; curr_path->name[1] = '\0'; - add_to_list(&curr_path->list, ÷d_path->list, divided_path->list.next); + add_to_list(&curr_path->list, + ÷d_path->list, + divided_path->list.next); j = i + 1; } } @@ -197,19 +223,19 @@ path_t* path_to_list(const char* path) return divided_path; } -uint32_t path_to_inode(const char* path) +uint32_t path_to_inode(const char *path) { uint32_t inode = 0; - path_t* divided_path = path_to_list(path); + path_t *divided_path = path_to_list(path); // first entry is / - path_t* curr_path = list_prev_entry(divided_path, list); + path_t *curr_path = list_prev_entry(divided_path, list); curr_path = list_prev_entry(curr_path, list); inode = 2; while (curr_path != divided_path) { // list of dentry - dentry_list_t* dentry_list = directory_to_entries(inode); + dentry_list_t *dentry_list = directory_to_entries(inode); // check if inode is actually a dir if (list_is_empty((&dentry_list->list))) { @@ -219,9 +245,10 @@ uint32_t path_to_inode(const char* path) // iterate through all direntries uint8_t ind = 1; - dentry_list_t* curr_dir; - list_for_each_entry_prev (curr_dir, (&dentry_list->list), list) { - if (!memcmp(curr_dir->ext2_dentry.name, curr_path->name)) { + dentry_list_t *curr_dir; + list_for_each_entry_prev(curr_dir, (&dentry_list->list), list) { + if (!memcmp(curr_dir->ext2_dentry.name, + curr_path->name)) { ind = 0; inode = curr_dir->ext2_dentry.inode; break; @@ -240,7 +267,7 @@ uint32_t path_to_inode(const char* path) curr_path = list_prev_entry(curr_path, list); } - path_t* pos; + path_t *pos; list_for_each_entry_del(pos, (÷d_path->list), list) { kfree(pos->name); kfree(pos); @@ -252,15 +279,16 @@ uint32_t path_to_inode(const char* path) void ls(uint32_t inode) { - dentry_list_t* dir = directory_to_entries(inode); + dentry_list_t *dir = directory_to_entries(inode); if (list_is_empty((&dir->list))) { return; } printf("ls dir with inode %d:\n", inode); - dentry_list_t* pos; + dentry_list_t *pos; list_for_each_entry(pos, (&dir->list), list) { - printf("inode: %d, name: %s\n", pos->ext2_dentry.inode, pos->ext2_dentry.name); + printf("inode: %d, name: %s\n", pos->ext2_dentry.inode, + pos->ext2_dentry.name); } list_for_each_entry_del(pos, (&dir->list), list) { diff --git a/kernel/src/libk/list.c b/kernel/src/libk/list.c index 21dac16..fb7e20d 100644 --- a/kernel/src/libk/list.c +++ b/kernel/src/libk/list.c @@ -1,7 +1,7 @@ #include <libk/list.h> #include <heap.h> -void add_to_list(list_t* head, list_t* prev, list_t* next) +void add_to_list(list_t *head, list_t *prev, list_t *next) { head->prev = prev; head->next = next; @@ -9,7 +9,7 @@ void add_to_list(list_t* head, list_t* prev, list_t* next) next->prev = head; } -void free_node(list_t* head) +void free_node(list_t *head) { if (list_is_empty(head)) { head = NULL; diff --git a/kernel/src/libk/math.c b/kernel/src/libk/math.c index f625fb5..7e0046f 100644 --- a/kernel/src/libk/math.c +++ b/kernel/src/libk/math.c @@ -3,6 +3,7 @@ int64_t abs(int64_t val) { - if (val < 0) return -val; + if (val < 0) + return -val; return val; } diff --git a/kernel/src/libk/mem.c b/kernel/src/libk/mem.c deleted file mode 100644 index e69de29..0000000 --- a/kernel/src/libk/mem.c +++ /dev/null diff --git a/kernel/src/libk/serial_stdio.c b/kernel/src/libk/serial_stdio.c index 8c0c527..002eb9e 100644 --- a/kernel/src/libk/serial_stdio.c +++ b/kernel/src/libk/serial_stdio.c @@ -12,7 +12,7 @@ void serial_print_char(char c) write_serial(c); } -void serial_print_string(const char* s) +void serial_print_string(const char *s) { for (size_t i = 0; i < strlen(s); i++) { serial_print_char(s[i]); @@ -47,24 +47,30 @@ void serial_vprintf(const char *s, va_list list) { lock(serial_stdio_lock); size_t count = 0; - for(size_t i = 0; i < strlen(s); i++) if(s[i] == '%') count++; + for (size_t i = 0; i < strlen(s); i++) + if (s[i] == '%') + count++; - for(size_t i = 0; i < strlen(s); i++) - { - if(s[i] == '%') - { + for (size_t i = 0; i < strlen(s); i++) { + if (s[i] == '%') { i++; - if(s[i] == 'c') serial_print_char((char)va_arg(list, uint32_t)); - else if(s[i] == 's') serial_print_string(va_arg(list, char*)); - else if(s[i] == 'd') serial_print_int((uint64_t)va_arg(list, uint64_t)); - else if(s[i] == 'x') serial_print_hex((uint64_t)va_arg(list, uint64_t)); - else - { - serial_print_string("Wrong format using printf\n"); + if (s[i] == 'c') + serial_print_char((char)va_arg(list, uint32_t)); + else if (s[i] == 's') + serial_print_string(va_arg(list, char *)); + else if (s[i] == 'd') + serial_print_int( + (uint64_t)va_arg(list, uint64_t)); + else if (s[i] == 'x') + serial_print_hex( + (uint64_t)va_arg(list, uint64_t)); + else { + serial_print_string( + "Wrong format using printf\n"); return; } - } - else serial_print_char(s[i]); + } else + serial_print_char(s[i]); } unlock(serial_stdio_lock); } diff --git a/kernel/src/libk/stdio.c b/kernel/src/libk/stdio.c index 18f3d3f..f410ccd 100644 --- a/kernel/src/libk/stdio.c +++ b/kernel/src/libk/stdio.c @@ -27,13 +27,14 @@ void print_char(char c) } return; } - fb_draw_character(main_fb, c, (int32_t)main_fb.x * 8, (int32_t)main_fb.y * 16); + fb_draw_character(main_fb, c, (int32_t)main_fb.x * 8, + (int32_t)main_fb.y * 16); main_fb.x++; write_serial(c); } -void print_string(const char* s) +void print_string(const char *s) { for (size_t i = 0; i < strlen(s); i++) { print_char(s[i]); @@ -68,24 +69,27 @@ void vprintf(const char *s, va_list list) { lock(stdio_lock); size_t count = 0; - for(size_t i = 0; i < strlen(s); i++) if(s[i] == '%') count++; + for (size_t i = 0; i < strlen(s); i++) + if (s[i] == '%') + count++; - for(size_t i = 0; i < strlen(s); i++) - { - if(s[i] == '%') - { + for (size_t i = 0; i < strlen(s); i++) { + if (s[i] == '%') { i++; - if(s[i] == 'c') print_char((char)va_arg(list, uint32_t)); - else if(s[i] == 's') print_string(va_arg(list, char*)); - else if(s[i] == 'd') print_int((uint64_t)va_arg(list, uint64_t)); - else if(s[i] == 'x') print_hex((uint64_t)va_arg(list, uint64_t)); - else - { + if (s[i] == 'c') + print_char((char)va_arg(list, uint32_t)); + else if (s[i] == 's') + print_string(va_arg(list, char *)); + else if (s[i] == 'd') + print_int((uint64_t)va_arg(list, uint64_t)); + else if (s[i] == 'x') + print_hex((uint64_t)va_arg(list, uint64_t)); + else { print_string("Wrong format using printf\n"); return; } - } - else print_char(s[i]); + } else + print_char(s[i]); } unlock(stdio_lock); } diff --git a/kernel/src/libk/string.c b/kernel/src/libk/string.c index 8b2b2c6..b8fd659 100644 --- a/kernel/src/libk/string.c +++ b/kernel/src/libk/string.c @@ -1,13 +1,14 @@ #include <types.h> #include <libk/string.h> -size_t strlen(const char* s) +size_t strlen(const char *s) { if (s == NULL) return 0; - char *p = (char*)s; - while (*p) p++; + char *p = (char *)s; + while (*p) + p++; return (size_t)(p - s); } @@ -36,7 +37,7 @@ void strrev(char *s) } } -void itos(uint64_t num, char* s) +void itos(uint64_t num, char *s) { if (num == 0) { s[0] = '0'; @@ -52,7 +53,7 @@ void itos(uint64_t num, char* s) strrev(s); } -void itoh(uint64_t num, char* s) +void itoh(uint64_t num, char *s) { if (num == 0) { s[0] = '0'; @@ -71,35 +72,35 @@ void itoh(uint64_t num, char* s) strrev(s); } -void memcpy(const void* destptr, const void* srcptr, size_t n) +void memcpy(const void *destptr, const void *srcptr, size_t n) { if (destptr == NULL || srcptr == NULL) return; - uint8_t* dest = (uint8_t*)destptr; - const uint8_t* src = (const uint8_t*)srcptr; + uint8_t *dest = (uint8_t *)destptr; + const uint8_t *src = (const uint8_t *)srcptr; - for(size_t i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { dest[i] = src[i]; } } -void memset(const void* destptr, uint8_t value, size_t n) +void memset(const void *destptr, uint8_t value, size_t n) { - uint8_t* dest = (uint8_t*)destptr; + uint8_t *dest = (uint8_t *)destptr; for (size_t i = 0; i < n; i++) { dest[i] = value; } } -int32_t memcmp(const void* aptr, const void* bptr) +int32_t memcmp(const void *aptr, const void *bptr) { - const uint8_t* a = (const uint8_t*)aptr; - const uint8_t* b = (const uint8_t*)bptr; + const uint8_t *a = (const uint8_t *)aptr; + const uint8_t *b = (const uint8_t *)bptr; - const size_t len_a = strlen((char*)a); - const size_t len_b = strlen((char*)b); + const size_t len_a = strlen((char *)a); + const size_t len_b = strlen((char *)b); for (size_t i = 0; i < len_a && i < len_b; i++) { if (a[i] != b[i]) diff --git a/kernel/src/main.c b/kernel/src/main.c index 106576f..037c43e 100644 --- a/kernel/src/main.c +++ b/kernel/src/main.c @@ -24,11 +24,11 @@ #include <atomic.h> #include <pmm.h> -int kernel_main(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic); -int kernel_main(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic) +int kernel_main(mb2_tag_header *multiboot_bootinfo, uint32_t multiboot_magic); +int kernel_main(mb2_tag_header *multiboot_bootinfo, uint32_t multiboot_magic) { init_serial(); -// serial is enabled from this point + // serial is enabled from this point init_gdt(); init_paging(); init_heap(); @@ -36,7 +36,7 @@ int kernel_main(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic) clear_screen(main_fb); init_mutex(&stdio_lock); init_mutex(&serial_stdio_lock); -// framebuffer is enabled from this point + // framebuffer is enabled from this point init_pmm(); memory_usage(); init_keyboard(); @@ -52,8 +52,8 @@ int kernel_main(mb2_tag_header* multiboot_bootinfo, uint32_t multiboot_magic) init_ap_cpus(); jump_userspace(); - for(;;) { - __asm__ __volatile__ ("hlt;"); + for (;;) { + __asm__ __volatile__("hlt;"); } return 0; } diff --git a/kernel/src/mem/heap.c b/kernel/src/mem/heap.c index b49eefb..537a2fe 100644 --- a/kernel/src/mem/heap.c +++ b/kernel/src/mem/heap.c @@ -1,6 +1,5 @@ #include <types.h> #include <heap.h> - #include <libk/math.h> #include <paging.h> #include <libk/serial_stdio.h> @@ -8,17 +7,18 @@ kheap_t main_kheap; -void kheap_init(kheap_t* kheap) +void kheap_init(kheap_t *kheap) { kheap->fblock = NULL; } -void kheap_add_block(kheap_t* kheap, uint64_t addr, uint32_t size, uint32_t bsize) +void kheap_add_block(kheap_t *kheap, uint64_t addr, uint32_t size, + uint32_t bsize) { kheapblock_t *kheapblock; // store size & bsize into kheapblock - kheapblock = (kheapblock_t*)addr; + kheapblock = (kheapblock_t *)addr; kheapblock->size = size - (uint32_t)sizeof(kheapblock_t); kheapblock->bsize = bsize; @@ -28,14 +28,15 @@ void kheap_add_block(kheap_t* kheap, uint64_t addr, uint32_t size, uint32_t bsiz // block count & bitmap uint32_t bcnt = kheapblock->size / kheapblock->bsize; - uint8_t* bm = (uint8_t*)&kheapblock[1]; + uint8_t *bm = (uint8_t *)&kheapblock[1]; // clear bitmap for (size_t i = 0; i < bcnt; i++) { bm[i] = 0; } - uint32_t bcnt_used = upper_div((bcnt + (uint32_t)sizeof(kheapblock_t)), bsize); + uint32_t bcnt_used = + upper_div((bcnt + (uint32_t)sizeof(kheapblock_t)), bsize); for (size_t i = 0; i < bcnt_used; i++) { bm[i] = 5; } @@ -43,13 +44,15 @@ void kheap_add_block(kheap_t* kheap, uint64_t addr, uint32_t size, uint32_t bsiz kheapblock->used = bcnt_used; } -void* kheap_alloc(kheap_t* kheap, uint32_t size) +void *kheap_alloc(kheap_t *kheap, uint32_t size) { - kheapblock_t* kheapblock; + kheapblock_t *kheapblock; // find kheapblock that has enough space - for (kheapblock = kheap->fblock; kheapblock; kheapblock = kheapblock->next) { - if (kheapblock->size - (kheapblock->used * kheapblock->bsize) < size) { + for (kheapblock = kheap->fblock; kheapblock; + kheapblock = kheapblock->next) { + if (kheapblock->size - (kheapblock->used * kheapblock->bsize) < + size) { continue; } @@ -57,12 +60,12 @@ void* kheap_alloc(kheap_t* kheap, uint32_t size) bool ind1 = ((size % 4096) == 0); bool ind2 = (kheapblock->bsize == 4096); if (ind1 + ind2 == 1) { - continue; + continue; } uint32_t bcnt = kheapblock->size / kheapblock->bsize; uint32_t bneed = upper_div(size, kheapblock->bsize); - uint8_t* bm = (uint8_t*)&kheapblock[1]; + uint8_t *bm = (uint8_t *)&kheapblock[1]; // find empty block for (size_t i = 0; i < bcnt; i++) { @@ -72,7 +75,9 @@ void* kheap_alloc(kheap_t* kheap, uint32_t size) // find bneed consecutive empty blocks size_t j; - for (j = 0; bm[i + j] == 0 && j < bneed && i + j < bcnt; j++); + for (j = 0; bm[i + j] == 0 && j < bneed && i + j < bcnt; + j++) + ; if (j != bneed) { i += j - 1; continue; @@ -80,7 +85,8 @@ void* kheap_alloc(kheap_t* kheap, uint32_t size) // using id for the block that is different from previous or next block uint8_t idp = bm[i - 1], idn = bm[i + j], id; - for (id = idp + 1; id == idn || id == 0; id++); + for (id = idp + 1; id == idn || id == 0; id++) + ; // mark blocks as used for (j = 0; j < bneed; j++) { @@ -89,24 +95,31 @@ void* kheap_alloc(kheap_t* kheap, uint32_t size) kheapblock->used += bneed; - return (void*)(i * kheapblock->bsize + (uintptr_t)&kheapblock[0]); + return (void *)(i * kheapblock->bsize + + (uintptr_t)&kheapblock[0]); } } printf("Error: there is no remaining memory in kheap\n"); return NULL; } -void kheap_free(kheap_t* kheap, void* pointer) +void kheap_free(kheap_t *kheap, void *pointer) { - kheapblock_t* kheapblock; - for (kheapblock = kheap->fblock; kheapblock; kheapblock = kheapblock->next) { - if ((uintptr_t)(pointer) > (uintptr_t)kheapblock && (uintptr_t)(pointer) < (uintptr_t)kheapblock + sizeof(kheapblock_t) + kheapblock->size) { + kheapblock_t *kheapblock; + for (kheapblock = kheap->fblock; kheapblock; + kheapblock = kheapblock->next) { + if ((uintptr_t)(pointer) > (uintptr_t)kheapblock && + (uintptr_t)(pointer) < (uintptr_t)kheapblock + + sizeof(kheapblock_t) + + kheapblock->size) { // found block // get index of bitmap entry - uintptr_t pointer_offset = (uintptr_t)pointer - (uintptr_t)&kheapblock[0]; - uint32_t bi = (uint32_t)pointer_offset / kheapblock->bsize; - uint8_t* bm = (uint8_t*)&kheapblock[1]; + uintptr_t pointer_offset = + (uintptr_t)pointer - (uintptr_t)&kheapblock[0]; + uint32_t bi = + (uint32_t)pointer_offset / kheapblock->bsize; + uint8_t *bm = (uint8_t *)&kheapblock[1]; uint8_t id = bm[bi]; uint32_t max = kheapblock->size / kheapblock->bsize; @@ -126,6 +139,8 @@ void kheap_free(kheap_t* kheap, void* pointer) void init_heap() { kheap_init(&main_kheap); - kheap_add_block(&main_kheap, HEAP1_VMEM_ADDR, HEAP1_SIZE, HEAP1_BLOCK_SIZE); - kheap_add_block(&main_kheap, HEAP2_VMEM_ADDR, HEAP2_SIZE, HEAP2_BLOCK_SIZE); + kheap_add_block(&main_kheap, HEAP1_VMEM_ADDR, HEAP1_SIZE, + HEAP1_BLOCK_SIZE); + kheap_add_block(&main_kheap, HEAP2_VMEM_ADDR, HEAP2_SIZE, + HEAP2_BLOCK_SIZE); } diff --git a/kernel/src/mem/paging.c b/kernel/src/mem/paging.c index b8c44c0..aa61c5d 100644 --- a/kernel/src/mem/paging.c +++ b/kernel/src/mem/paging.c @@ -1,7 +1,6 @@ #include <types.h> #include <paging.h> #include <panic.h> - #include <heap.h> #include <libk/serial_stdio.h> #include <libk/stdio.h> @@ -21,24 +20,28 @@ void map_addr(uint64_t virt, uint64_t phys, uint32_t flags) size_t pt_lvl4_i = (virt >> 39) % 0x200; // 512gb entry size_t pt_lvl3_i = (virt >> 30) % 0x200; // 1gb entry size_t pt_lvl2_i = (virt >> 21) % 0x200; // 2mb entry -// size_t pt_lvl1_i = (virt >> 12) % 0x200; // 4kb entry + // size_t pt_lvl1_i = (virt >> 12) % 0x200; // 4kb entry - uint64_t* pt_lvl3 = (uint64_t*)(page_table_lvl4[pt_lvl4_i] + KERNEL_VMA); + uint64_t *pt_lvl3 = + (uint64_t *)(page_table_lvl4[pt_lvl4_i] + KERNEL_VMA); if (!((uint64_t)pt_lvl3 & FLAG_PRESENT)) { - pt_lvl3 = (uint64_t*)kalloc(4096); + pt_lvl3 = (uint64_t *)kalloc(4096); memset(pt_lvl3, 0, 4096); - page_table_lvl4[pt_lvl4_i] = ((uint64_t)pt_lvl3 - KERNEL_VMA) | flags; + page_table_lvl4[pt_lvl4_i] = ((uint64_t)pt_lvl3 - KERNEL_VMA) | + flags; } else { - pt_lvl3 = (uint64_t*)((uint64_t)pt_lvl3 - (uint64_t)pt_lvl3 % 4096); + pt_lvl3 = (uint64_t *)((uint64_t)pt_lvl3 - + (uint64_t)pt_lvl3 % 4096); } - uint64_t* pt_lvl2 = (uint64_t*)(pt_lvl3[pt_lvl3_i] + KERNEL_VMA); + uint64_t *pt_lvl2 = (uint64_t *)(pt_lvl3[pt_lvl3_i] + KERNEL_VMA); if (!((uint64_t)pt_lvl2 & FLAG_PRESENT)) { - pt_lvl2 = (uint64_t*)kalloc(4096); + pt_lvl2 = (uint64_t *)kalloc(4096); memset(pt_lvl2, 0, 4096); pt_lvl3[pt_lvl3_i] = ((uint64_t)pt_lvl2 - KERNEL_VMA) | flags; } else { - pt_lvl2 = (uint64_t*)((uint64_t)pt_lvl2 - (uint64_t)pt_lvl2 % 4096); + pt_lvl2 = (uint64_t *)((uint64_t)pt_lvl2 - + (uint64_t)pt_lvl2 % 4096); } pt_lvl2[pt_lvl2_i] = phys | flags | FLAG_HUGE; @@ -46,11 +49,15 @@ void map_addr(uint64_t virt, uint64_t phys, uint32_t flags) void init_paging(void) { - page_table_lvl4[511] = (uint64_t)page_table_lvl3 - KERNEL_VMA + (FLAG_PRESENT | FLAG_WRITABLE | FLAG_USER); - page_table_lvl3[510] = (uint64_t)page_table_lvl2 - KERNEL_VMA + (FLAG_PRESENT | FLAG_WRITABLE | FLAG_USER); + page_table_lvl4[511] = (uint64_t)page_table_lvl3 - KERNEL_VMA + + (FLAG_PRESENT | FLAG_WRITABLE | FLAG_USER); + page_table_lvl3[510] = (uint64_t)page_table_lvl2 - KERNEL_VMA + + (FLAG_PRESENT | FLAG_WRITABLE | FLAG_USER); // 16mb kernel + 32mb heap + 2mb (32kb stack * 64 threads) = first 50mb for (size_t i = 0; i < 25; i++) { - page_table_lvl2[i] = (uint64_t)0x0 + PAGE_SIZE * i + (FLAG_PRESENT | FLAG_WRITABLE | FLAG_USER | FLAG_HUGE); + page_table_lvl2[i] = + (uint64_t)0x0 + PAGE_SIZE * i + + (FLAG_PRESENT | FLAG_WRITABLE | FLAG_USER | FLAG_HUGE); } load_pt_lvl4(page_table_lvl4); @@ -59,7 +66,7 @@ void init_paging(void) void page_fault(uint64_t error) { uint64_t addr; - __asm__ __volatile__ ("mov %%cr2, %0;" : "=r"(addr) : : "memory"); + __asm__ __volatile__("mov %%cr2, %0;" : "=r"(addr) : : "memory"); printf("address: 0x%x, error code: 0x%x\n", addr, error); diff --git a/kernel/src/mem/pmm.c b/kernel/src/mem/pmm.c index f0b4884..043043c 100644 --- a/kernel/src/mem/pmm.c +++ b/kernel/src/mem/pmm.c @@ -6,7 +6,7 @@ #include <multiboot2.h> #include <pmm.h> -#define MEM_USED_BELOW 50*1024*1024 +#define MEM_USED_BELOW 50 * 1024 * 1024 uint64_t free_mem_cnt; uint64_t all_mem_cnt; @@ -16,17 +16,23 @@ void init_pmm() { INIT_LIST(pmm_list); - mmap_t* pos; + mmap_t *pos; list_for_each_entry_prev(pos, (&mmap.list), list) { mb2_tag_mmap_entry entry = pos->mmap_entry; if (entry.type != 1) continue; - uint64_t base = entry.base_addr & (PAGE_SIZE - 1) ? (entry.base_addr & (uint64_t)~(PAGE_SIZE - 1)) + PAGE_SIZE : entry.base_addr; - for (uint64_t i = base; i + PAGE_SIZE <= entry.base_addr + entry.length; i += PAGE_SIZE) { + uint64_t base = entry.base_addr & (PAGE_SIZE - 1) ? + (entry.base_addr & + (uint64_t) ~(PAGE_SIZE - 1)) + + PAGE_SIZE : + entry.base_addr; + for (uint64_t i = base; + i + PAGE_SIZE <= entry.base_addr + entry.length; + i += PAGE_SIZE) { if (i >= MEM_USED_BELOW) { free_mem_cnt++; map_addr(i, i, FLAG_PRESENT); - list_t* list = (list_t*)i; + list_t *list = (list_t *)i; add_to_list(list, &pmm_list, pmm_list.next); } } @@ -36,6 +42,8 @@ void init_pmm() void memory_usage() { - printf("memory used: %dMB\n", (MEM_USED_BELOW + (all_mem_cnt - free_mem_cnt) * PAGE_SIZE) / 1024 / 1024); + printf("memory used: %dMB\n", + (MEM_USED_BELOW + (all_mem_cnt - free_mem_cnt) * PAGE_SIZE) / + 1024 / 1024); printf("memory free: %dMB\n", free_mem_cnt * PAGE_SIZE / 1024 / 1024); } diff --git a/kernel/src/misc/graphics.c b/kernel/src/misc/graphics.c index 7ab67f3..f595146 100644 --- a/kernel/src/misc/graphics.c +++ b/kernel/src/misc/graphics.c @@ -1,6 +1,5 @@ #include <types.h> #include <graphics.h> - #include <multiboot2.h> #include <font.h> #include <libk/string.h> @@ -10,15 +9,17 @@ fb_t main_fb; void fb_draw_pixel(fb_t fb, int32_t x, int32_t y, uint32_t col) { - if (x < 0 || y < 0) return; - if (x >= (int32_t)fb.width || y >= (int32_t)fb.height) return; + if (x < 0 || y < 0) + return; + if (x >= (int32_t)fb.width || y >= (int32_t)fb.height) + return; uint32_t fb_offset = (uint32_t)y * fb.pitch + (uint32_t)x * fb.bpp / 8; - __volatile__ uint32_t* fb_buff = (uint32_t*)fb.addr; + __volatile__ uint32_t *fb_buff = (uint32_t *)fb.addr; fb_buff[fb_offset / 4] = col; } -void set_color(fb_t* fb, uint32_t char_col, uint32_t bg_col) +void set_color(fb_t *fb, uint32_t char_col, uint32_t bg_col) { fb->char_col = char_col; fb->bg_col = bg_col; @@ -37,7 +38,8 @@ void clear_screen(fb_t fb) /* https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm */ -void fb_draw_line_low(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t col) +void fb_draw_line_low(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, + uint32_t col) { int32_t dx = x1 - x0; int32_t dy = y1 - y0; @@ -58,10 +60,10 @@ void fb_draw_line_low(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, u D = D + 2 * dy; } } - } -void fb_draw_line_high(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t col) +void fb_draw_line_high(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, + uint32_t col) { int32_t dx = x1 - x0; int32_t dy = y1 - y0; @@ -84,7 +86,8 @@ void fb_draw_line_high(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, } } -void fb_draw_line(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t col) +void fb_draw_line(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, + uint32_t col) { if (abs(y1 - y0) < abs(x1 - x0)) { if (x0 > x1) @@ -101,13 +104,12 @@ void fb_draw_line(fb_t fb, int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint3 void fb_draw_character(fb_t fb, char c, int32_t x, int32_t y) { - if (c < 0) return; + if (c < 0) + return; int32_t offset = 32 + c * 16; - for (int32_t i = 0 ; i < 16; i++) - { - for (int32_t j = 0 ; j < 8; j++) - { + for (int32_t i = 0; i < 16; i++) { + for (int32_t j = 0; j < 8; j++) { if (font[offset + i] & (1 << (7 - j))) { fb_draw_pixel(fb, x + j, y + i, fb.char_col); } else { diff --git a/kernel/src/misc/stdbuff.c b/kernel/src/misc/stdbuff.c index cca58d6..4362882 100644 --- a/kernel/src/misc/stdbuff.c +++ b/kernel/src/misc/stdbuff.c @@ -2,9 +2,9 @@ #include <heap.h> #include <stdbuff.h> -stdbuff* init_buff(uint32_t buff_size) +stdbuff *init_buff(uint32_t buff_size) { - stdbuff* buffer = kalloc(sizeof(stdbuff)); + stdbuff *buffer = kalloc(sizeof(stdbuff)); buffer->head = 0; buffer->tail = 0; buffer->size = buff_size; @@ -12,19 +12,21 @@ stdbuff* init_buff(uint32_t buff_size) return buffer; } -void read_buff(stdbuff* buffer, char* dest_ptr, size_t read_size) +void read_buff(stdbuff *buffer, char *dest_ptr, size_t read_size) { for (size_t i = 0; i < read_size; i++) { - memcpy(dest_ptr + i, buffer->data + ((buffer->tail + i) % buffer->size), 1); + memcpy(dest_ptr + i, + buffer->data + ((buffer->tail + i) % buffer->size), 1); } dest_ptr[read_size] = '\0'; buffer->tail = (buffer->tail + read_size) % buffer->size; } -void write_buff(stdbuff* buffer, const char* src_ptr, size_t write_size) +void write_buff(stdbuff *buffer, const char *src_ptr, size_t write_size) { for (size_t i = 0; i < write_size; i++) { - memcpy(buffer->data + ((buffer->head + i) % buffer->size), src_ptr + i, 1); + memcpy(buffer->data + ((buffer->head + i) % buffer->size), + src_ptr + i, 1); } buffer->head = (buffer->head + write_size) % buffer->size; } diff --git a/kernel/src/scheduler/ap_startup.c b/kernel/src/scheduler/ap_startup.c index f4a2055..92fc51c 100644 --- a/kernel/src/scheduler/ap_startup.c +++ b/kernel/src/scheduler/ap_startup.c @@ -5,13 +5,14 @@ #include <gdt.h> #include <paging.h> -void ap_startup(void) { +void ap_startup(void) +{ load_idt(&idt_pointer); load_gdt(&gdt_pointer); load_pt_lvl4(page_table_lvl4); - while (bspdone) { - __asm__ __volatile__ ("pause;"); + while (!bspdone) { + __asm__ __volatile__("pause;"); } printf("curr_cpu_apic_id: 0x%x\n", curr_cpu_apic_id()); @@ -19,7 +20,7 @@ void ap_startup(void) { ap_cnt++; unlock(cnt_lock); - for(;;) { - __asm__ __volatile__ ("hlt;"); + for (;;) { + __asm__ __volatile__("hlt;"); } } diff --git a/kernel/src/scheduler/atomic.c b/kernel/src/scheduler/atomic.c index c466f0b..d5ae02f 100644 --- a/kernel/src/scheduler/atomic.c +++ b/kernel/src/scheduler/atomic.c @@ -3,22 +3,25 @@ #include <libk/stdio.h> #include <heap.h> -void init_mutex(mutex_t* mutex) +void init_mutex(mutex_t *mutex) { - mutex->addr = (uint64_t*)kalloc(sizeof(uint64_t)); + mutex->addr = (uint64_t *)kalloc(sizeof(uint64_t)); *(mutex->addr) = 0; } bool test_and_set(mutex_t mutex, bool value) { bool rax; - __asm__ __volatile__ ("lock xchg %%rax, (%%rbx);" : "=a"(rax) : "b"(mutex.addr), "a"(value)); + __asm__ __volatile__("lock xchg %%rax, (%%rbx);" + : "=a"(rax) + : "b"(mutex.addr), "a"(value)); return rax; } void lock(mutex_t mutex) { - while (test_and_set(mutex, 1)) ; + while (test_and_set(mutex, 1)) + ; } void unlock(mutex_t mutex) diff --git a/kernel/src/scheduler/scheduler.c b/kernel/src/scheduler/scheduler.c index 000d20c..b8f3dab 100644 --- a/kernel/src/scheduler/scheduler.c +++ b/kernel/src/scheduler/scheduler.c @@ -3,5 +3,4 @@ void schedule(void) { - } diff --git a/kernel/src/sys/syscall.c b/kernel/src/sys/syscall.c index debd70f..bd3c52c 100644 --- a/kernel/src/sys/syscall.c +++ b/kernel/src/sys/syscall.c @@ -8,18 +8,18 @@ void syscall_handler() uint64_t rax; uint64_t rdi; uint64_t rsi; - __asm__ __volatile__ ("mov %%rax, %0;" : "=r"(rax) : :); - __asm__ __volatile__ ("mov %%rdi, %0;" : "=r"(rdi) : :); - __asm__ __volatile__ ("mov %%rsi, %0;" : "=r"(rsi) : :); - switch(rax) { - case SYSCALL_READ: - syscall_read(); - break; - case SYSCALL_WRITE: - syscall_write((char*)rdi, rsi); - break; - default: - printf("invalid syscall (%d)\n", rax); + __asm__ __volatile__("mov %%rax, %0;" : "=r"(rax) : :); + __asm__ __volatile__("mov %%rdi, %0;" : "=r"(rdi) : :); + __asm__ __volatile__("mov %%rsi, %0;" : "=r"(rsi) : :); + switch (rax) { + case SYSCALL_READ: + syscall_read(); + break; + case SYSCALL_WRITE: + syscall_write((char *)rdi, rsi); + break; + default: + printf("invalid syscall (%d)\n", rax); } } @@ -28,7 +28,7 @@ void syscall_read() printf("syscall_read()\n"); } -void syscall_write(char* buff, size_t count) +void syscall_write(char *buff, size_t count) { printf("syscall_write()\n"); printf("buff = 0x%x, count = %d\n", buff, count); diff --git a/kernel/src/sys/userspace.c b/kernel/src/sys/userspace.c index 00cd758..7091a3f 100644 --- a/kernel/src/sys/userspace.c +++ b/kernel/src/sys/userspace.c @@ -6,10 +6,10 @@ void begin_userspace() { // read - __asm__ __volatile__ ("mov $0x0, %rax; syscall;"); + __asm__ __volatile__("mov $0x0, %rax; syscall;"); // write - __asm__ __volatile__ ("mov $0x1, %rax; syscall;"); + __asm__ __volatile__("mov $0x1, %rax; syscall;"); - while(true) { + while (true) { } } |
