Skip to content

Commit

Permalink
adaptações para PMU seguindo PDF do Leo e criei novo app test_PMU par…
Browse files Browse the repository at this point in the history
…a testar se PMU funciona
  • Loading branch information
emilysk49 committed Nov 27, 2024
1 parent 212b362 commit b2337ce
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 1 deletion.
16 changes: 16 additions & 0 deletions app/test_PMU/test_PMU.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <utility/ostream.h>
#include <architecture.h>

using namespace EPOS;

OStream cout;

int main()
{
long long c = PMU::read(1);
cout << "Hello world!" << endl;
cout << "ABSOLUTES = " << PMU::read(1) << ", " << PMU::read(0) << ", " << PMU::read(2) << endl;
cout << "DIFFERENCE = " << PMU::read(1) - c << endl;

return 0;
}
149 changes: 149 additions & 0 deletions app/test_PMU/test_PMU_traits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#ifndef __traits_h
#define __traits_h

#include <system/config.h>

__BEGIN_SYS

// Build
template<> struct Traits<Build>: public Traits_Tokens
{
// Basic configuration
static const unsigned int SMOD = LIBRARY;
static const unsigned int ARCHITECTURE = IA32;
static const unsigned int MACHINE = PC;
static const unsigned int MODEL = Legacy_PC;
static const unsigned int CPUS = ((MODEL == Legacy_PC) || (MODEL == Raspberry_Pi3) || (MODEL == Realview_PBX) || (MODEL == Zynq) || (MODEL == SiFive_U)) ? 2 : 1;
static const unsigned int NETWORKING = STANDALONE;
static const unsigned int EXPECTED_SIMULATION_TIME = 60; // s (0 => not simulated)

// Default flags
static const bool enabled = true;
static const bool monitored = true;
static const bool debugged = true;
static const bool hysterically_debugged = false;
};


// Utilities
template<> struct Traits<Debug>: public Traits<Build>
{
static const bool error = true;
static const bool warning = true;
static const bool info = false;
static const bool trace = false;
};

template<> struct Traits<Lists>: public Traits<Build>
{
static const bool debugged = hysterically_debugged;
};

template<> struct Traits<Spin>: public Traits<Build>
{
static const bool debugged = hysterically_debugged;
};

template<> struct Traits<Heaps>: public Traits<Build>
{
static const bool debugged = hysterically_debugged;
};

template<> struct Traits<Observers>: public Traits<Build>
{
// Some observed objects are created before initializing the Display
// Enabling debug may cause trouble in some Machines
static const bool debugged = false;
};


// System Parts (mostly to fine control debugging)
template<> struct Traits<Boot>: public Traits<Build>
{
};

template<> struct Traits<Setup>: public Traits<Build>
{
};

template<> struct Traits<Init>: public Traits<Build>
{
};

template<> struct Traits<Framework>: public Traits<Build>
{
};

template<> struct Traits<Aspect>: public Traits<Build>
{
static const bool debugged = hysterically_debugged;
};


__END_SYS

// Mediators
#include __ARCHITECTURE_TRAITS_H
#include __MACHINE_TRAITS_H

__BEGIN_SYS


// API Components
template<> struct Traits<Application>: public Traits<Build>
{
static const unsigned int STACK_SIZE = Traits<Machine>::STACK_SIZE;
static const unsigned int HEAP_SIZE = Traits<Machine>::HEAP_SIZE;
static const unsigned int MAX_THREADS = Traits<Machine>::MAX_THREADS;
};

template<> struct Traits<System>: public Traits<Build>
{
static const bool multithread = (Traits<Application>::MAX_THREADS > 1) || (CPUS > 1);
static const bool multicore = multithread && (CPUS > 1);
static const bool multiheap = Traits<Scratchpad>::enabled;

static const unsigned long LIFE_SPAN = 1 * YEAR; // s
static const unsigned int DUTY_CYCLE = 1000000; // ppm

static const bool reboot = true;

static const unsigned int STACK_SIZE = Traits<Machine>::STACK_SIZE;
static const unsigned int HEAP_SIZE = (Traits<Application>::MAX_THREADS + Traits<Build>::CPUS) * Traits<Application>::STACK_SIZE;
};

template<> struct Traits<Thread>: public Traits<Build>
{
static const bool enabled = Traits<System>::multithread;
static const bool smp = Traits<System>::multicore;
static const bool trace_idle = hysterically_debugged;
static const bool simulate_capacity = false;
static const int priority_inversion_protocol = NONE;


typedef IF<(CPUS > 1), PEAMQ, EAMQ>::Result Criterion;
static const unsigned int QUANTUM = 10000; // us
};

template<> struct Traits<Scheduler<Thread>>: public Traits<Build>
{
static const bool debugged = Traits<Thread>::trace_idle || hysterically_debugged;
};

template<> struct Traits<Synchronizer>: public Traits<Build>
{
static const bool enabled = Traits<System>::multithread;
};

template<> struct Traits<Alarm>: public Traits<Build>
{
static const bool visible = hysterically_debugged;
};

template<> struct Traits<Address_Space>: public Traits<Build> {};

template<> struct Traits<Segment>: public Traits<Build> {};

__END_SYS

#endif
3 changes: 2 additions & 1 deletion makedefs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ endif
pc_CC_FLAGS = -m32 -Wa,--32
pc_AS_FLAGS = --32
pc_LD_FLAGS = -m elf_i386 -z noexecstack
pc_EMULATOR = qemu-system-i386 $(QEMU_DEBUG) -no-acpi -smp $(CPUS) -m $(RAM_SIZE_MB) -nographic -no-reboot -drive format=raw,index=0,if=floppy,read-only=on,file=
# P6 : -enable-kvm -cpu host adicionado
pc_EMULATOR = qemu-system-i386 $(QEMU_DEBUG) -no-acpi -smp $(CPUS) -m $(RAM_SIZE_MB) -enable-kvm -cpu host -nographic -no-reboot -drive format=raw,index=0,if=floppy,read-only=on,file=
pc_DEBUGGER = gdb
pc_FLASHER =
pc_MAGIC = --nmagic
Expand Down
10 changes: 10 additions & 0 deletions src/architecture/ia32/ia32_cpu_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ void CPU::init()
// Initialize the PMU
if(Traits<PMU>::enabled)
PMU::init();
// P6 : adicionando start counters (PDF - Leonardo)
PMU::config(2,2);
PMU::config(1,1);
PMU::config(0,0);
PMU::start(2);
PMU::start(1);
PMU::start(0);
PMU::reset(2);
PMU::reset(1);
PMU::reset(0);
}

void CPU::smp_barrier_init(unsigned int cores) {
Expand Down

0 comments on commit b2337ce

Please sign in to comment.