Skip to content

Commit

Permalink
[P8048] Support P8048
Browse files Browse the repository at this point in the history
  • Loading branch information
tgtakaoka committed Apr 21, 2024
1 parent 272e363 commit ec22a9f
Show file tree
Hide file tree
Showing 59 changed files with 14,622 additions and 2,461 deletions.
9 changes: 9 additions & 0 deletions debugger/char_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ CharBuffer::CharBuffer(const char *str) : _str(new char[strlen(str) + 1]) {
strcpy(_str, str);
}

void CharBuffer::hex1(uint8_t pos, uint8_t val) {
_str[pos] = val ? '1' : '0';
}

void CharBuffer::hex4(uint8_t pos, uint8_t val) {
_str[pos] = toHex4(val & 0xF);
}
Expand All @@ -26,6 +30,11 @@ void CharBuffer::hex8(uint8_t pos, uint8_t val) {
hex4(pos + 1, val);
}

void CharBuffer::hex12(uint8_t pos, uint16_t val) {
hex4(pos, val >> 8);
hex8(pos + 1, val);
}

void CharBuffer::hex16(uint8_t pos, uint16_t val) {
hex8(pos, val >> 8);
hex8(pos + 2, val);
Expand Down
2 changes: 2 additions & 0 deletions debugger/char_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ struct CharBuffer final {
operator const char *() const { return _str; }
char &operator[](int pos) { return _str[pos]; }

void hex1(uint8_t pos, uint8_t value);
void hex4(uint8_t pos, uint8_t value);
void hex8(uint8_t pos, uint8_t value);
void hex12(uint8_t pos, uint16_t value);
void hex16(uint8_t pos, uint16_t value);
void hex20(uint8_t pos, uint32_t value);
void hex24(uint8_t pos, uint32_t value);
Expand Down
14 changes: 8 additions & 6 deletions debugger/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,15 @@ void Debugger::exec(char c) {
goto regs;
case 'G':
cli.println(F("Go"));
if (pins().step(false)) { // step over possible break point
pins().setRun();
pins().run();
pins().setHalt();
goto regs;
if (pins().isBreakPoint(regs().nextIp())) {
// step over break point
if (!pins().step(false))
break;
}
break;
pins().setRun();
pins().run();
pins().setHalt();
goto regs;
case 'F':
cli.print(F("Files? "));
cli.readLine(handleFileListing, 0, str_buffer, sizeof(str_buffer));
Expand Down
6 changes: 6 additions & 0 deletions debugger/i8048/compile_flags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-O
-Wall
-std=c++14
-I..
-I../.pio/libdeps/teensy41/libcli/src
-I../.pio/libdeps/teensy41/libasm/src
58 changes: 58 additions & 0 deletions debugger/i8048/devs_i8048.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "devs_i8048.h"
#include <string.h>
#include "debugger.h"
#include "i8251.h"

namespace debugger {
namespace i8048 {

DevsI8048 Devs;

void DevsI8048::reset() {
USART.reset();
USART.setBaseAddr(USART_BASE);
}

void DevsI8048::begin() {
enableDevice(USART);
}

void DevsI8048::loop() {
USART.loop();
}

bool DevsI8048::isSelected(uint32_t addr) const {
return USART.isSelected(addr);
}

uint16_t DevsI8048::read(uint32_t addr) const {
return USART.read(addr);
}

void DevsI8048::write(uint32_t addr, uint16_t data) const {
USART.write(addr, data);
}

Device &DevsI8048::parseDevice(const char *name) const {
if (strcasecmp(name, USART.name()) == 0)
return USART;
return Devs::nullDevice();
}

void DevsI8048::enableDevice(Device &dev) {
USART.enable(&dev == &USART);
}

void DevsI8048::printDevices() const {
printDevice(USART);
}

} // namespace i8048
} // namespace debugger

// Local Variables:
// mode: c++
// c-basic-offset: 4
// tab-width: 4
// End:
// vim: set ft=cpp et ts=4 sw=4:
35 changes: 35 additions & 0 deletions debugger/i8048/devs_i8048.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef __DEVS_I8048_H__
#define __DEVS_I8048_H__

#include "devs.h"

#define USART_BASE 0xFC

namespace debugger {
namespace i8048 {

struct DevsI8048 final : Devs {
void begin() override;
void reset() override;
void loop() override;
bool isSelected(uint32_t addr) const override;
uint16_t read(uint32_t addr) const override;
void write(uint32_t addr, uint16_t data) const override;

Device &parseDevice(const char *name) const override;
void enableDevice(Device &dev) override;
void printDevices() const override;
};

extern struct DevsI8048 Devs;

} // namespace i8048
} // namespace debugger
#endif /* __DEVS_I8048H__ */

// Local Variables:
// mode: c++
// c-basic-offset: 4
// tab-width: 4
// End:
// vim: set ft=cpp et ts=4 sw=4:
Loading

0 comments on commit ec22a9f

Please sign in to comment.