100 tasks from the HWE arm-linux code-gen pool (outside the lk/man/pth range given to batch 22), each with at least one independent contract-edge defect and plain public docs. Claude reviewed 100/100 USABLE against current digests; no ID or source overlap with main or batch 22. Difficulty is unmeasured. progress.md records the wrap-up: all Codex sessions and Qwen schedulers stopped for the user's rollout, Qwen results so far (57 HARD of 373), and what is left on each batch branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
5.1 KiB
C++
116 lines
5.1 KiB
C++
#include "poll_model.hpp"
|
|
#include <iostream>
|
|
#include <iomanip>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
static std::vector<std::uint8_t> decode(const std::string &word) {
|
|
std::vector<std::uint8_t> result;
|
|
if (word == "-") return result;
|
|
for (std::size_t i = 0; i < word.size(); i += 2)
|
|
result.push_back(static_cast<std::uint8_t>(std::stoul(word.substr(i, 2), nullptr, 16)));
|
|
return result;
|
|
}
|
|
static std::string encode(const std::vector<std::uint8_t> &data) {
|
|
if (data.empty()) return "-";
|
|
std::ostringstream output;
|
|
output << std::hex << std::setfill('0');
|
|
for (auto value : data) output << std::setw(2) << static_cast<unsigned>(value);
|
|
return output.str();
|
|
}
|
|
int main() {
|
|
ps::Model banks[2];
|
|
int selected = 0;
|
|
std::string command;
|
|
while (std::cin >> command) {
|
|
auto &model = banks[selected];
|
|
int a, b, c, nonce;
|
|
unsigned mask;
|
|
std::uint64_t token;
|
|
std::string word;
|
|
if (command == "U") {
|
|
std::cin >> selected;
|
|
std::cout << "U " << selected;
|
|
} else if (command == "Z") {
|
|
model.reset();
|
|
std::cout << "Z 0";
|
|
} else if (command == "C") {
|
|
std::cin >> a >> b >> c;
|
|
std::cout << "C " << model.create(a, b, c);
|
|
} else if (command == "T") {
|
|
std::cin >> a >> b >> c;
|
|
std::cout << "T " << model.transfer(a, b, c);
|
|
} else if (command == "D") {
|
|
std::cin >> a;
|
|
std::cout << "D " << model.destroy(a);
|
|
} else if (command == "F") {
|
|
std::cin >> a >> word;
|
|
auto bytes = decode(word);
|
|
std::cout << "F " << model.feed(a, bytes);
|
|
} else if (command == "G" || command == "E") {
|
|
std::cin >> a >> b;
|
|
int status = command == "G" ? model.grant(a, b) : model.spend(a, b);
|
|
std::cout << command << ' ' << status;
|
|
} else if (command == "L") {
|
|
std::cin >> a >> mask;
|
|
std::cout << "L " << model.latch(a, mask);
|
|
} else if (command == "A") {
|
|
std::cin >> a;
|
|
std::cout << "A " << model.acknowledge(a);
|
|
} else if (command == "R") {
|
|
std::cin >> a >> b >> c >> word;
|
|
auto output = decode(word);
|
|
int status = model.read(a, b, c, output);
|
|
std::cout << "R " << status << ' ' << encode(output);
|
|
} else if (command == "Q") {
|
|
std::cin >> a >> nonce;
|
|
ps::DeviceView view;
|
|
view.capacity = view.queued = view.credits = nonce;
|
|
view.flags = static_cast<unsigned>(nonce);
|
|
view.generation = static_cast<std::uint64_t>(nonce);
|
|
view.data = {0x55, 0xaa};
|
|
int status = model.inspect(a, view);
|
|
std::cout << "Q " << status << ' ' << view.capacity << ' ' << view.queued
|
|
<< ' ' << view.credits << ' ' << view.flags << ' ' << view.generation
|
|
<< ' ' << encode(view.data);
|
|
} else if (command == "B") {
|
|
std::cin >> a >> b >> mask >> token;
|
|
int status = model.begin(a, b, mask, token);
|
|
std::cout << "B " << status << ' ' << token;
|
|
} else if (command == "S") {
|
|
std::cin >> a >> token >> mask;
|
|
int status = model.step(a, token, mask);
|
|
std::cout << "S " << status << ' ' << mask;
|
|
} else if (command == "X" || command == "I" || command == "V") {
|
|
std::cin >> a >> token;
|
|
int status = command == "X" ? model.cancel(a, token) :
|
|
command == "I" ? model.interrupt(a, token) : model.release(a, token);
|
|
std::cout << command << ' ' << status;
|
|
} else if (command == "W") {
|
|
std::cin >> a >> nonce;
|
|
ps::WatchView view;
|
|
view.token = view.seen = view.pending = view.wakes = static_cast<std::uint64_t>(nonce);
|
|
view.device = view.phase = view.registered = nonce;
|
|
view.requested = view.ready = static_cast<unsigned>(nonce);
|
|
int status = model.watch(a, view);
|
|
std::cout << "W " << status << ' ' << view.token << ' ' << view.device
|
|
<< ' ' << view.requested << ' ' << view.phase << ' ' << view.registered
|
|
<< ' ' << view.ready << ' ' << view.seen << ' ' << view.pending << ' ' << view.wakes;
|
|
} else if (command == "J") {
|
|
std::cin >> token >> a >> nonce;
|
|
ps::Record record;
|
|
record.sequence = record.token = record.generation = static_cast<std::uint64_t>(nonce);
|
|
record.kind = record.device = record.actor = nonce;
|
|
std::vector<ps::Record> output{record};
|
|
std::uint64_t next = static_cast<std::uint64_t>(nonce);
|
|
int status = model.journal(token, a, output, next);
|
|
std::cout << "J " << status << ' ' << next << ' ' << output.size();
|
|
for (const auto &entry : output)
|
|
std::cout << ' ' << entry.sequence << ' ' << entry.kind << ' ' << entry.device
|
|
<< ' ' << entry.actor << ' ' << entry.token << ' ' << entry.generation;
|
|
}
|
|
std::cout << '\n';
|
|
}
|
|
return 0;
|
|
}
|