Prepare some basic early logging support

This commit is contained in:
Baptiste Wicht 2014-03-10 19:02:50 +01:00
parent 6af9f457a5
commit c73fc79260
2 changed files with 43 additions and 6 deletions

View File

@ -0,0 +1,22 @@
//=======================================================================
// Copyright Baptiste Wicht 2013-2014.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#include <types.hpp>
#ifndef EARLY_LOGGING_HPP
#define EARLY_LOGGING_HPP
namespace early {
constexpr const uint32_t MAX_EARLY_LOGGING = 128;
extern uint32_t early_logs_count;
extern uint32_t early_logs[MAX_EARLY_LOGGING];
} //end of namespace early
#endif

View File

@ -13,10 +13,14 @@
#include "gdt.hpp" #include "gdt.hpp"
#include "e820.hpp" //Just for the address of the e820 map #include "e820.hpp" //Just for the address of the e820 map
#include "vesa.hpp" #include "vesa.hpp"
#include "early_logging.hpp"
//The Task State Segment //The Task State Segment
gdt::task_state_segment_t gdt::tss; gdt::task_state_segment_t gdt::tss;
uint32_t early::early_logs_count = 0;
uint32_t early::early_logs[early::MAX_EARLY_LOGGING];
e820::bios_e820_entry e820::bios_e820_entries[e820::MAX_E820_ENTRIES]; e820::bios_e820_entry e820::bios_e820_entries[e820::MAX_E820_ENTRIES];
int16_t e820::bios_e820_entry_count = 0; int16_t e820::bios_e820_entry_count = 0;
@ -26,17 +30,25 @@ bool vesa::vesa_enabled = false;
namespace { namespace {
/* Early Logging */
void early_log(const char* s){
early::early_logs[early::early_logs_count++] = reinterpret_cast<uint32_t>(s);
}
/* VESA */
constexpr const uint16_t DEFAULT_WIDTH = 1280; constexpr const uint16_t DEFAULT_WIDTH = 1280;
constexpr const uint16_t DEFAULT_HEIGHT = 1024; constexpr const uint16_t DEFAULT_HEIGHT = 1024;
constexpr const uint16_t DEFAULT_BPP = 32; constexpr const uint16_t DEFAULT_BPP = 32;
void out_byte(uint8_t value, uint16_t port){ void out_byte(uint8_t value, uint16_t port){
__asm__ __volatile__("out %1, %0" : : "a" (value), "dN" (port)); asm volatile("out %1, %0" : : "a" (value), "dN" (port));
} }
uint8_t in_byte(uint16_t port){ uint8_t in_byte(uint16_t port){
uint8_t value; uint8_t value;
__asm__ __volatile__("in %0,%1" : "=a" (value) : "dN" (port)); asm volatile("in %0,%1" : "=a" (value) : "dN" (port));
return value; return value;
} }
@ -74,9 +86,12 @@ int detect_memory_e820(){
: "a"(0xE820), "b"(contID), "c"(24), "d"(0x534D4150), "D"(&buf)); : "a"(0xE820), "b"(contID), "c"(24), "d"(0x534D4150), "D"(&buf));
if (signature != 0x534D4150){ if (signature != 0x534D4150){
early_log("e820 failed");
return -1; return -1;
} }
early_log("Found e820 entry");
if (bytes > 20 && (smap->acpi & 0x0001) == 0){ if (bytes > 20 && (smap->acpi & 0x0001) == 0){
// ignore this entry // ignore this entry
} else { } else {
@ -199,7 +214,7 @@ void setup_vesa(){
} }
void disable_interrupts(){ void disable_interrupts(){
__asm__ __volatile__ ("cli"); asm volatile ("cli");
} }
void enable_a20_gate(){ void enable_a20_gate(){
@ -400,15 +415,15 @@ void __attribute__ ((noreturn)) rm_main(){
//Make sure segments are clean //Make sure segments are clean
reset_segments(); reset_segments();
//Enable VESA
setup_vesa();
//Analyze memory //Analyze memory
detect_memory(); detect_memory();
//Make sure a20 gate is enabled //Make sure a20 gate is enabled
enable_a20_gate(); enable_a20_gate();
//Enable VESA
setup_vesa();
//Disable interrupts //Disable interrupts
disable_interrupts(); disable_interrupts();