mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-27 16:31:31 +00:00
Merge pull request #479 from TomHarte/8272Logging
Returns sanity to 8272 logging.
This commit is contained in:
commit
17251997c2
@ -114,7 +114,7 @@ void i8272::run_for(Cycles cycles) {
|
||||
while(steps--) {
|
||||
// Perform a step.
|
||||
int direction = (drives_[c].target_head_position < drives_[c].head_position) ? -1 : 1;
|
||||
LOG("Target " << std::dec << drives_[c].target_head_position << " versus believed " << drives_[c].head_position);
|
||||
LOG("Target " << PADDEC(0) << drives_[c].target_head_position << " versus believed " << static_cast<int>(drives_[c].head_position));
|
||||
select_drive(c);
|
||||
get_drive().step(Storage::Disk::HeadPosition(direction));
|
||||
if(drives_[c].target_head_position >= 0) drives_[c].head_position += direction;
|
||||
@ -385,7 +385,7 @@ void i8272::posit_event(int event_type) {
|
||||
// the index hole limit is breached or a sector is found with a cylinder, head, sector and size equal to the
|
||||
// values in the internal registers.
|
||||
index_hole_limit_ = 2;
|
||||
// LOG("Seeking " << std::dec << cylinder_ << " " << head_ " " << sector_ << " " << size_);
|
||||
// LOG("Seeking " << PADDEC(0) << cylinder_ << " " << head_ " " << sector_ << " " << size_);
|
||||
find_next_sector:
|
||||
FIND_HEADER();
|
||||
if(!index_hole_limit_) {
|
||||
@ -406,7 +406,7 @@ void i8272::posit_event(int event_type) {
|
||||
// This implies a CRC error in the header; mark as such but continue.
|
||||
SetDataError();
|
||||
}
|
||||
// LOG("Considering << std::hex << header_[0] << " " << header_[1] << " " << header_[2] << " " << header_[3] << " [" << get_crc_generator().get_value() << "]");
|
||||
// LOG("Considering << PADHEX(2) << header_[0] << " " << header_[1] << " " << header_[2] << " " << header_[3] << " [" << get_crc_generator().get_value() << "]");
|
||||
if(header_[0] != cylinder_ || header_[1] != head_ || header_[2] != sector_ || header_[3] != size_) goto find_next_sector;
|
||||
|
||||
// Branch to whatever is supposed to happen next
|
||||
@ -424,7 +424,13 @@ void i8272::posit_event(int event_type) {
|
||||
|
||||
// Performs the read data or read deleted data command.
|
||||
read_data:
|
||||
LOG("Read [deleted] data [" << std::hex << command_[2] << " " << command_[3] << " " << command_[4] << " " << command_[5] << " ... " << command_[6] << " " << command_[8] << "]");
|
||||
LOG(PADHEX(2) << "Read [deleted] data ["
|
||||
<< static_cast<int>(command_[2]) << " "
|
||||
<< static_cast<int>(command_[3]) << " "
|
||||
<< static_cast<int>(command_[4]) << " "
|
||||
<< static_cast<int>(command_[5]) << " ... "
|
||||
<< static_cast<int>(command_[6]) << " "
|
||||
<< static_cast<int>(command_[8]) << "]");
|
||||
read_next_data:
|
||||
goto read_write_find_header;
|
||||
|
||||
@ -508,7 +514,13 @@ void i8272::posit_event(int event_type) {
|
||||
goto post_st012chrn;
|
||||
|
||||
write_data:
|
||||
LOG("Write [deleted] data [" << std::hex << command_[2] << " " << command_[3] << " " << command_[4] << " " << command_[5] << " ... " << command_[6] << " " << command_[8] << "]");
|
||||
LOG(PADHEX(2) << "Write [deleted] data ["
|
||||
<< static_cast<int>(command_[2]) << " "
|
||||
<< static_cast<int>(command_[3]) << " "
|
||||
<< static_cast<int>(command_[4]) << " "
|
||||
<< static_cast<int>(command_[5]) << " ... "
|
||||
<< static_cast<int>(command_[6]) << " "
|
||||
<< static_cast<int>(command_[8]) << "]");
|
||||
|
||||
if(get_drive().get_is_read_only()) {
|
||||
SetNotWriteable();
|
||||
@ -543,7 +555,7 @@ void i8272::posit_event(int event_type) {
|
||||
goto write_loop;
|
||||
}
|
||||
|
||||
LOG("Wrote " << std::dec << distance_into_section_ << " bytes");
|
||||
LOG("Wrote " << PADDEC(0) << distance_into_section_ << " bytes");
|
||||
write_crc();
|
||||
expects_input_ = false;
|
||||
WAIT_FOR_EVENT(Event::DataWritten);
|
||||
@ -559,7 +571,7 @@ void i8272::posit_event(int event_type) {
|
||||
// Performs the read ID command.
|
||||
read_id:
|
||||
// Establishes the drive and head being addressed, and whether in double density mode.
|
||||
LOG("Read ID [" << std::hex << command_[0] << " " << command_[1] << "]");
|
||||
LOG(PADHEX(2) << "Read ID [" << static_cast<int>(command_[0]) << " " << static_cast<int>(command_[1]) << "]");
|
||||
|
||||
// Sets a maximum index hole limit of 2 then waits either until it finds a header mark or sees too many index holes.
|
||||
// If a header mark is found, reads in the following bytes that produce a header. Otherwise branches to data not found.
|
||||
@ -581,7 +593,11 @@ void i8272::posit_event(int event_type) {
|
||||
|
||||
// Performs read track.
|
||||
read_track:
|
||||
LOG("Read track [" << std::hex << command_[2] << " " << command_[3] << " " << command_[4] << " " << command_[5] << "]");
|
||||
LOG(PADHEX(2) << "Read track ["
|
||||
<< static_cast<int>(command_[2]) << " "
|
||||
<< static_cast<int>(command_[3]) << " "
|
||||
<< static_cast<int>(command_[4]) << " "
|
||||
<< static_cast<int>(command_[5]) << "]");
|
||||
|
||||
// Wait for the index hole.
|
||||
WAIT_FOR_EVENT(Event::IndexHole);
|
||||
@ -666,7 +682,12 @@ void i8272::posit_event(int event_type) {
|
||||
break;
|
||||
}
|
||||
|
||||
LOG("W: " << std::hex << header_[0] << " " << header_[1] << " " << header_[2] << " " << header_[3] << ", " << get_crc_generator().get_value());
|
||||
LOG(PADHEX(2) << "W:"
|
||||
<< static_cast<int>(header_[0]) << " "
|
||||
<< static_cast<int>(header_[1]) << " "
|
||||
<< static_cast<int>(header_[2]) << " "
|
||||
<< static_cast<int>(header_[3]) << ", "
|
||||
<< get_crc_generator().get_value());
|
||||
write_crc();
|
||||
|
||||
// Write the sector body.
|
||||
@ -737,7 +758,7 @@ void i8272::posit_event(int event_type) {
|
||||
// up in run_for understands to mean 'keep going until track 0 is active').
|
||||
if(command_.size() > 2) {
|
||||
drives_[drive].target_head_position = command_[2];
|
||||
LOG("Seek to " << std::hex << command_[2]);
|
||||
LOG(PADHEX(2) << "Seek to " << static_cast<int>(command_[2]));
|
||||
} else {
|
||||
drives_[drive].target_head_position = -1;
|
||||
drives_[drive].head_position = 0;
|
||||
@ -832,9 +853,9 @@ void i8272::posit_event(int event_type) {
|
||||
// Posts whatever is in result_stack_ as a result phase. Be aware that it is a stack, so the
|
||||
// last thing in it will be returned first.
|
||||
post_result:
|
||||
LOGNBR("Result to " << std::hex << (command_[0] & 0x1f) << ", main " << main_status_);
|
||||
LOGNBR(PADHEX(2) << "Result to " << static_cast<int>(command_[0] & 0x1f) << ", main " << static_cast<int>(main_status_));
|
||||
for(std::size_t c = 0; c < result_stack_.size(); c++) {
|
||||
LOGNBR(result_stack_[result_stack_.size() - 1 - c]);
|
||||
LOGNBR(static_cast<int>(result_stack_[result_stack_.size() - 1 - c]));
|
||||
}
|
||||
LOGNBR(std::endl);
|
||||
|
||||
|
@ -13,15 +13,22 @@
|
||||
|
||||
#define LOG(x)
|
||||
#define LOGNBR(x)
|
||||
|
||||
#define ERROR(x)
|
||||
#define ERRORNBR(x)
|
||||
|
||||
#else
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <ios>
|
||||
|
||||
#define PADHEX(n) std::hex << std::setw(n) << std::right << std::setfill('0')
|
||||
#define PADDEC(n) std::dec << std::setw(n) << std::right << std::setfill('0')
|
||||
|
||||
#define LOG(x) std::cout << x << std::endl
|
||||
#define LOGNBR(x) std::cout << x
|
||||
|
||||
#define ERROR(x) std::cerr << x << std::endl
|
||||
#define ERRORNBR(x) std::cerr << x
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user