Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion hal/cortex_m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,28 @@ target_include_directories(hal.cortex_m PUBLIC
target_sources(hal.cortex_m PRIVATE
DataWatchpointAndTrace.hpp
DataWatchpointAndTrace.cpp
EventDispatcherCortex.hpp
EventDispatcherCortex.cpp
FaultTracer.hpp
FaultTracer.cpp
InterruptCortex.hpp
InterruptCortex.cpp
LowPriorityInterrupt.hpp
LowPriorityInterrupt.cpp)
LowPriorityInterrupt.cpp
SystemTick.hpp
SystemTick.cpp
SystemTickTimerService.hpp
SystemTickTimerService.cpp
Reset.hpp
Reset.cpp
Semihosting.hpp
Semihosting.cpp)

target_link_libraries(hal.cortex_m PUBLIC
hal.cortex_m.runtime
hal.interfaces
infra.event
infra.timer
infra.util
services.tracer)

Expand Down
38 changes: 38 additions & 0 deletions hal/cortex_m/EventDispatcherCortex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "hal/cortex_m/EventDispatcherCortex.hpp"

namespace
{
void Dsb()
{
__asm volatile("dsb" ::: "memory");
}

void Wfe()
{
__asm volatile("wfe");
}

void Sev()
{
__asm volatile("sev");
}
}

namespace hal::cortex
{
EventDispatcherCortexWorker::EventDispatcherCortexWorker(infra::MemoryRange<std::pair<infra::Function<void()>, std::atomic<bool>>> scheduledActionsStorage)
: infra::EventDispatcherWorkerImpl(scheduledActionsStorage)
{}

void EventDispatcherCortexWorker::Idle()
{
Dsb();
Wfe();
}

void EventDispatcherCortexWorker::RequestExecution()
{
Dsb();
Sev();
}
}
22 changes: 22 additions & 0 deletions hal/cortex_m/EventDispatcherCortex.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef HAL_CORTEX_M_EVENT_DISPATCHER_CORTEX_HPP
#define HAL_CORTEX_M_EVENT_DISPATCHER_CORTEX_HPP

#include "infra/event/EventDispatcher.hpp"

namespace hal::cortex
{
class EventDispatcherCortexWorker
: public infra::EventDispatcherWorkerImpl
{
public:
explicit EventDispatcherCortexWorker(infra::MemoryRange<std::pair<infra::Function<void()>, std::atomic<bool>>> scheduledActionsStorage);

protected:
void Idle() override;
void RequestExecution() override;
};

using EventDispatcherCortex = infra::EventDispatcherConnector<EventDispatcherCortexWorker>;
}

#endif
4 changes: 2 additions & 2 deletions hal/qemu/cortex/Reset.cpp → hal/cortex_m/Reset.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "hal/qemu/cortex/Reset.hpp"
#include "hal/cortex_m/Reset.hpp"
#include <cstdint>

namespace hal::cortex
Expand All @@ -9,7 +9,7 @@ namespace hal::cortex
constexpr uint32_t aircrResetValue = (0x5FAu << 16) | (1u << 2);
}

void Reset::ResetModule()
void Reset::ResetModule(const char* /*resetReason*/)
{
*reinterpret_cast<volatile uint32_t*>(aircrAddress) = aircrResetValue;
}
Expand Down
16 changes: 16 additions & 0 deletions hal/cortex_m/Reset.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef HAL_CORTEX_M_RESET_HPP
#define HAL_CORTEX_M_RESET_HPP

#include "hal/interfaces/Reset.hpp"

namespace hal::cortex
{
class Reset
: public hal::Reset
{
public:
void ResetModule(const char* resetReason) override;
};
}

#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "hal/qemu/cortex/Semihosting.hpp"
#include "hal/cortex_m/Semihosting.hpp"

namespace hal::cortex
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HAL_QEMU_CORTEX_SEMIHOSTING_HPP
#define HAL_QEMU_CORTEX_SEMIHOSTING_HPP
#ifndef HAL_CORTEX_M_SEMIHOSTING_HPP
#define HAL_CORTEX_M_SEMIHOSTING_HPP

#include "infra/util/ByteRange.hpp"
#include <cstdint>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "hal/qemu/cortex/SystemTick.hpp"
#include "hal/cortex_m/SystemTick.hpp"
#include <chrono>
#include <cstdint>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HAL_QEMU_CORTEX_SYSTEM_TICK_HPP
#define HAL_QEMU_CORTEX_SYSTEM_TICK_HPP
#ifndef HAL_CORTEX_M_SYSTEM_TICK_HPP
#define HAL_CORTEX_M_SYSTEM_TICK_HPP

#include "infra/timer/TimerService.hpp"
#include <cstdint>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "hal/qemu/cortex/SystemTickTimerService.hpp"
#include "hal/cortex_m/SystemTickTimerService.hpp"

namespace hal::cortex
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef HAL_QEMU_CORTEX_SYSTEM_TICK_TIMER_SERVICE_HPP
#define HAL_QEMU_CORTEX_SYSTEM_TICK_TIMER_SERVICE_HPP
#ifndef HAL_CORTEX_M_SYSTEM_TICK_TIMER_SERVICE_HPP
#define HAL_CORTEX_M_SYSTEM_TICK_TIMER_SERVICE_HPP

#include "hal/cortex_m/InterruptCortex.hpp"
#include "hal/qemu/cortex/SystemTick.hpp"
#include "hal/cortex_m/SystemTick.hpp"
#include "infra/timer/TickOnInterruptTimerService.hpp"
#include "infra/util/InterfaceConnector.hpp"

Expand Down
22 changes: 3 additions & 19 deletions hal/qemu/cortex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
add_library(hal.qemu.cortex STATIC)
add_library(hal.qemu.cortex INTERFACE)

emil_build_for(hal.qemu.cortex
BOOL EMIL_BUILD_QEMU
HOST Off)

target_include_directories(hal.qemu.cortex PUBLIC
target_include_directories(hal.qemu.cortex INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../..>")

target_sources(hal.qemu.cortex PRIVATE
Semihosting.hpp
Semihosting.cpp
SystemTick.hpp
SystemTick.cpp
SystemTickTimerService.hpp
SystemTickTimerService.cpp
EventDispatcherCortex.hpp
EventDispatcherCortex.cpp
Reset.hpp
Reset.cpp)

target_link_libraries(hal.qemu.cortex PUBLIC
target_link_libraries(hal.qemu.cortex INTERFACE
hal.cortex_m
infra.event
infra.timer
Expand Down
12 changes: 0 additions & 12 deletions hal/qemu/cortex/EventDispatcherCortex.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions hal/qemu/cortex/EventDispatcherCortex.hpp

This file was deleted.

13 changes: 0 additions & 13 deletions hal/qemu/cortex/Reset.hpp

This file was deleted.

5 changes: 3 additions & 2 deletions hal/qemu/default_init/EventInfrastructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#define HAL_QEMU_DEFAULT_INIT_EVENT_INFRASTRUCTURE_HPP

#include "hal/cortex_m/InterruptCortex.hpp"
Comment thread
gabrielfrasantos marked this conversation as resolved.
#include "hal/qemu/cortex/EventDispatcherCortex.hpp"
#include "hal/qemu/cortex/SystemTickTimerService.hpp"
#include "hal/cortex_m/EventDispatcherCortex.hpp"
#include "hal/cortex_m/InterruptCortex.hpp"
#include "hal/cortex_m/SystemTickTimerService.hpp"
#include "infra/timer/TimerService.hpp"
#include <chrono>
#include <cstdint>
Expand Down
2 changes: 1 addition & 1 deletion hal/qemu/default_init/Startup.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "hal/cortex_m/InterruptCortex.hpp"
#include "hal/qemu/cortex/Semihosting.hpp"
#include "hal/cortex_m/Semihosting.hpp"
#include "hal/qemu/default_init/SystemInit.hpp"
#include "hal/qemu/sync/Pl011Registers.hpp"
#include <cstdint>
Expand Down
2 changes: 1 addition & 1 deletion hal/qemu/default_init/Syscalls.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "hal/qemu/cortex/Semihosting.hpp"
#include "hal/cortex_m/Semihosting.hpp"
#include "infra/util/ByteRange.hpp"
#include <cstdint>
#include <cstdlib>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "hal/qemu/default_init/TracerOnSemihostingInfrastructure.hpp"
#include "hal/qemu/cortex/Semihosting.hpp"
#include "hal/cortex_m/Semihosting.hpp"
#include "services/tracer/GlobalTracer.hpp"

namespace bringup
Expand Down
2 changes: 1 addition & 1 deletion hal/qemu/test/TestSystemTickTimerService.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "hal/cortex_m/InterruptCortex.hpp"
#include "hal/qemu/cortex/SystemTickTimerService.hpp"
#include "hal/cortex_m/SystemTickTimerService.hpp"
#include "infra/event/test_helper/EventDispatcherFixture.hpp"
#include "infra/timer/Timer.hpp"
#include "gmock/gmock.h"
Expand Down
Loading