1

implement exercise 04 interrupts

This commit is contained in:
churl
2022-05-14 21:12:32 +02:00
parent deb0ebd8eb
commit 13df44fb6f
8 changed files with 208 additions and 120 deletions

View File

@ -12,43 +12,41 @@
#ifndef __CPU_include__
#define __CPU_include__
class CPU {
private:
CPU(const CPU &copy); // Verhindere Kopieren
CPU(const CPU& copy); // Verhindere Kopieren
public:
CPU() {}
// Erlauben von (Hardware-)Interrupts
inline void enable_int () {
asm volatile ( "sti" );
inline void enable_int() {
asm volatile("sti");
}
// Interrupts werden ignoriert/verboten
inline void disable_int () {
asm volatile ( "cli" );
inline void disable_int() {
asm volatile("cli");
}
// Prozessor bis zum naechsten Interrupt anhalten
inline void idle () {
asm volatile ( "sti;"
"hlt"
);
inline void idle() {
asm volatile("sti;"
"hlt");
}
// Prozessor anhalten
inline void halt () {
asm volatile ( "cli;"
"hlt"
);
inline void halt() {
asm volatile("cli;"
"hlt");
}
// Time-Stamp-Counter auslesen
inline unsigned long long int rdtsc() {
unsigned long long int ret;
asm volatile ( "rdtsc" : "=A"(ret) );
unsigned long long int ret;
asm volatile("rdtsc"
: "=A"(ret));
return ret;
}
};