machine/psion_ssd.cpp: Can now create new SSD, default to be 128K RAM.

- Flash SSD's are write-protected, RAM SSD's are not.
- RAM SSD's from softlist will write to nvram, non-softlist will write back to file.
This commit is contained in:
Nigel Barnes 2023-07-22 16:39:01 +01:00
parent 1af93b7319
commit 460278695e
2 changed files with 56 additions and 12 deletions

View file

@ -158,15 +158,13 @@ TIMER_CALLBACK_MEMBER(psion_ssd_device::close_door)
std::pair<std::error_condition, std::string> psion_ssd_device::call_load()
{
device_image_interface *image = nullptr;
interface(image);
uint32_t size = image->length();
uint32_t const size = length();
if (size < 0x10000 || size > 0x800000 || (size & (size - 1)) != 0)
return std::make_pair(image_error::INVALIDLENGTH, "Invalid size, must be 64K, 128K, 256K, 512K, 1M, 2M, 4M, 8M");
image->fread(m_ssd_data.get(), size);
if (fread(m_ssd_data, size) != size)
return std::make_pair(std::errc::io_error, std::string());
// check for Flash header
if ((m_ssd_data[0] | (m_ssd_data[1] << 8)) == 0xf1a5) // Flash
@ -174,6 +172,30 @@ std::pair<std::error_condition, std::string> psion_ssd_device::call_load()
else
set_info_byte(size, SSD_RAM);
if (loaded_through_softlist())
battery_load(m_ssd_data.get(), size, nullptr);
// open the door
m_door_cb(ASSERT_LINE);
// setup the timer to close the door
m_door_timer->adjust(attotime::from_msec(200));
return std::make_pair(std::error_condition(), std::string());
}
std::pair<std::error_condition, std::string> psion_ssd_device::call_create(int format_type, util::option_resolution *create_args)
{
uint32_t const size = 0x20000;
// 128k RAM Solid State Disk by default
set_info_byte(size, SSD_RAM);
std::fill_n(m_ssd_data.get(), sizeof(m_ssd_data), 0);
fwrite(m_ssd_data.get(), size);
// open the door
m_door_cb(ASSERT_LINE);
@ -186,8 +208,32 @@ std::pair<std::error_condition, std::string> psion_ssd_device::call_load()
void psion_ssd_device::call_unload()
{
memset(m_ssd_data.get(), 0, sizeof(m_ssd_data));
uint32_t const size = length();
if ((m_info_byte & 0xe0) == 0x00) // not write protected
{
if (!loaded_through_softlist())
{
// write to original file
fseek(0, SEEK_SET);
fwrite(m_ssd_data.get(), size);
}
else
{
// write to nvram
battery_save(m_ssd_data.get(), size);
}
}
set_info_byte(0);
std::fill_n(m_ssd_data.get(), sizeof(m_ssd_data), 0);
// open the door
m_door_cb(ASSERT_LINE);
// setup the timer to close the door
m_door_timer->adjust(attotime::from_msec(200));
}
@ -203,7 +249,7 @@ void psion_ssd_device::set_info_byte(uint32_t size, uint8_t type)
// Type 1 Flash or RAM
if (type != SSD_RAM)
m_info_byte |= 0x20;
m_info_byte |= 0xe0; // write protected
// No. devices and size
switch (size)
@ -218,9 +264,6 @@ void psion_ssd_device::set_info_byte(uint32_t size, uint8_t type)
case 0x800000: m_info_byte |= 0x1f; m_mem_width = 21; break; // 8M (4 x 2M)
}
// write protected
m_info_byte |= 0xe0;
// set pull-ups on ASIC5
m_asic5->set_info_byte(m_info_byte);
}
@ -235,7 +278,7 @@ uint8_t psion_ssd_device::data_r()
return 0x00;
}
void psion_ssd_device::data_w(uint16_t data)
void psion_ssd_device::data_w(uint16_t data)
{
if (m_info_byte & 7)
{

View file

@ -30,7 +30,7 @@ public:
auto door_cb() { return m_door_cb.bind(); }
uint8_t data_r();
void data_w(uint16_t data);
void data_w(uint16_t data);
protected:
// device_t implementation
@ -41,6 +41,7 @@ protected:
// device_image_interface implementation
virtual std::pair<std::error_condition, std::string> call_load() override;
virtual std::pair<std::error_condition, std::string> call_create(int format_type, util::option_resolution *create_args) override;
virtual void call_unload() override;
virtual bool is_reset_on_load() const noexcept override { return false; }