-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "bus.hpp" | ||
#include <ostream> | ||
#include <string_view> | ||
|
||
class SysconDevice : public BusDevice | ||
{ | ||
public: | ||
SysconDevice() = default; | ||
virtual ~SysconDevice() = default; | ||
|
||
uint64_t load(Bus& bus, uint64_t address, uint64_t length) override; | ||
void store(Bus& bus, uint64_t address, uint64_t value, uint64_t length) override; | ||
|
||
public: | ||
uint64_t get_base_address() const override; | ||
uint64_t get_end_address() const override; | ||
|
||
void dump(std::ostream& stream) const override; | ||
std::string_view get_peripheral_name() const override; | ||
|
||
public: | ||
static constexpr uint64_t poweroff_addr = 0x5555; | ||
|
||
static constexpr uint64_t reboot_addr = 0x7777; | ||
|
||
static constexpr uint64_t base_addr = poweroff_addr; | ||
|
||
static constexpr uint64_t end_addr = reboot_addr; | ||
|
||
static constexpr std::string_view peripheral_name = "SYSCON"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "syscon.hpp" | ||
#include <cstdlib> | ||
|
||
uint64_t SysconDevice::load(Bus& bus, uint64_t address, uint64_t length) | ||
{ | ||
return 0; | ||
} | ||
|
||
void SysconDevice::store(Bus& bus, uint64_t address, uint64_t value, uint64_t length) | ||
{ | ||
if (value == poweroff_addr) | ||
{ | ||
std::exit(0); | ||
} | ||
else if (value == reboot_addr) | ||
{ | ||
std::exit(0); | ||
} | ||
} | ||
|
||
void SysconDevice::dump(std::ostream& stream) const | ||
{ | ||
} | ||
|
||
uint64_t SysconDevice::get_base_address() const | ||
{ | ||
return base_addr; | ||
} | ||
|
||
uint64_t SysconDevice::get_end_address() const | ||
{ | ||
return end_addr; | ||
} | ||
|
||
std::string_view SysconDevice::get_peripheral_name() const | ||
{ | ||
return peripheral_name; | ||
} |