CTAOS v3
This commit is contained in:
18
SysCore/hal/cpu/compile.bat
Normal file
18
SysCore/hal/cpu/compile.bat
Normal file
@ -0,0 +1,18 @@
|
||||
@echo off
|
||||
rem The name of the loader assembly file (without extension, must be .asm):
|
||||
set loader_name=loader
|
||||
|
||||
rem NASM and DJGPP executable paths:
|
||||
set nasm_path=C:\nasm
|
||||
set djgpp_path=C:\DJGPP\bin
|
||||
set objpath=../../objects
|
||||
set incpath=../../include
|
||||
|
||||
@echo on
|
||||
%djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/cpu.o cpu.c
|
||||
|
||||
@echo off
|
||||
@echo .
|
||||
@echo Done!
|
||||
|
||||
@pause
|
35
SysCore/hal/cpu/cpu.c
Normal file
35
SysCore/hal/cpu/cpu.c
Normal file
@ -0,0 +1,35 @@
|
||||
#include <system.h>
|
||||
#include "cpu.h"
|
||||
#include "../gdt/gdt.h"
|
||||
#include "../idt/idt.h"
|
||||
#define cpuid(in, a, b, c, d) __asm__("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in));
|
||||
|
||||
|
||||
|
||||
// initializes cpu resources
|
||||
void i86_cpu_initialize()
|
||||
{
|
||||
// initialize processor tables
|
||||
i86_gdt_install();
|
||||
i86_idt_install();
|
||||
}
|
||||
|
||||
void i86_cpu_shutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* i86_cpu_get_vender()
|
||||
{
|
||||
static char vender[13];
|
||||
dword unused, arr[3];
|
||||
int i;
|
||||
|
||||
cpuid(0, unused, arr[0], arr[2], arr[1]);
|
||||
|
||||
for (i=0; i<12; i++)
|
||||
vender[i] = (arr[i/4]>>(i%4*8)) && 0xFF;
|
||||
|
||||
vender[12] = 0;
|
||||
return vender;
|
||||
}
|
29
SysCore/hal/cpu/cpu.h
Normal file
29
SysCore/hal/cpu/cpu.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef _CPU_H_INCLUDED
|
||||
#define _CPU_H_INCLUDED
|
||||
//****************************************************************************
|
||||
//**
|
||||
//** cpu.h
|
||||
//**
|
||||
//** This is the processor interface. Everything outside of this module
|
||||
//** must use this interface when working on processor data.
|
||||
//**
|
||||
//** A processor is a module that manages the very basic data structures
|
||||
//** and data within the system. The processor interface provides the interface
|
||||
//** for managing processors, processor cores, accessing processor structures,
|
||||
//** and more
|
||||
//**
|
||||
//****************************************************************************
|
||||
|
||||
#include <stdint.h>
|
||||
#include <regs.h>
|
||||
|
||||
//! initialize the processors
|
||||
extern void i86_cpu_initialize ();
|
||||
|
||||
//! shutdown the processors
|
||||
extern void i86_cpu_shutdown ();
|
||||
|
||||
//! get cpu vender
|
||||
extern char* i86_cpu_get_vender ();
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user