/* * mykernel/c/kernel.c * * Copyright (C) 2017 - 2021 bzt (bztsrc@gitlab) * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * This file is part of the BOOTBOOT Protocol package. * @brief A sample BOOTBOOT compatible kernel * */ /* function to display a string, see below */ void puts(char *s); /* we don't assume stdint.h exists */ typedef short int int16_t; typedef unsigned char uint8_t; typedef unsigned short int uint16_t; typedef unsigned int uint32_t; typedef unsigned long int uint64_t; #include /* imported virtual addresses, see linker script */ extern BOOTBOOT bootboot; // see bootboot.h extern unsigned char environment[4096]; // configuration, UTF-8 text key=value pairs extern uint8_t fb; // linear framebuffer mapped /****************************************** * Entry point, called by BOOTBOOT Loader * ******************************************/ void _start() { /*** NOTE: this code runs on all cores in parallel ***/ int x, y, s=bootboot.fb_scanline, w=bootboot.fb_width, h=bootboot.fb_height; // cross-hair to see screen dimension detected correctly for(y=0;ywidth+7)/8; while(*s) { unsigned char *glyph = (unsigned char*)&_binary_font_psf_start + font->headersize + (*s>0&&*snumglyph?*s:0)*font->bytesperglyph; offs = (kx * (font->width+1) * 4); for(y=0;yheight;y++) { line=offs; mask=1<<(font->width-1); for(x=0;xwidth;x++) { *((uint32_t*)((uint64_t)&fb+line))=((int)*glyph) & (mask)?0xFFFFFF:0; mask>>=1; line+=4; } *((uint32_t*)((uint64_t)&fb+line))=0; glyph+=bpl; offs+=bootboot.fb_scanline; } s++; kx++; } }