A design for a bootable Disk for a 65C02 system
Posted: Sat Oct 08, 2022 1:23 am
As I've been using a 6GB Microdrive for a while now on a prototype 3.3v system, I've been using a ROM based version of Richard Leary's DOS/65. I just use a Ctrl key from the Monitor code and it starts up DOS/65 and you're off an running.
As I'm looking to go to a more capable system (more memory, banking, faster CPU) I'm also looking to have the operating system booted from the drive and run entirely in RAM (sans the ROM based BIOS).
The memory configuration for the C02 Pocket:
- 32KB SRAM from $0000 - $7FFF
- 32KB EEPROM from $8000 - $FFFF
An I/O window is configure at $FE00 and has 5- 32-byte wide selects
The updated memory configuration for the 3.3V prototype:
- 56KB SRAM from $0000 - $DFFF
- 8KB EEPROM from $E000 - $FFFF
An I/O window is unchanged at $FE00
The 8KB of EEPROM will remain as:
- BIOS from $F800 - $FFFF (sans the I/O window)
- Monitor from $E000 - $F7FF
Rather than enable an autoboot from the Microdrive, I prefer to be able to run the system without the bootable OS so I have options on doing other things... the Monitor supports Xmodem CRC upload and download capability.
Now the fun part... I actually wrote custom partition loaders back in the 80's, as the PC-AT only had a handful of defined disk drive parameters, so if you had a drive that wasn't part of the ROM table, you couldn't really use it fully or maybe worse. I wrote a a custom partition loader that would softload the disk parameters for the BIOS and then load the boot record to kick off the OS load... worked like a charm. So I get to do some of this stuff again.
Here's my basic scheme:
******************************************************************************************************
Microdrive Bootable design:
******************************************************************************************************
LBA mode is used exclusively!
When the C02 Pocket is powered up:
- BIOS initializes the system:
- Clear Page Zero
- Load Page $03 with Vector and Soft Config data
- Initialize SC28L92 DUART and Timer/Counter
- Show BIOS version message
- Initialize additional hardware
- Maxim DS15x1 Realtime Clock
- Microdrive IDE interface
- Cold start System Monitor
- Monitor code will display some version information, user prompt
- Using a Ctrl-B will Load LBA zero from Microdrive to memory $0600
- Will sense Partition code signature (0x02 0x65)
- If signature Valid, will Jump to Boot code in memory
- If signature Invalid, will show error message and warm start monitor
******************************************************************************************************
LBA zero contains an Ontrack Disk Manager partition record.
- 252 bytes of code
- optional 2 byte signature: suggested use as (0x02 0x65) 6502 in little-endian
- There are 4 standard partition entries - 16 bytes each
- There are 12 expanded partition entries - 16 bytes each
- 2 bytes final signature (0x55, 0xAA)
******************************************************************************************************
Note: Partition type for CPM is hex “DB”
A 16-byte partition record is defined as:
Offset: Length Description
0x00 1 byte Status byte - bit 7 set (0x80) = active, else 0x00
0x01 3 bytes CHS address first sector in partition
0x04 1 byte Partition Type (CPM = hex DB)
0x05 3 bytes CHS address last sector in partition
0x08 4 bytes LBA of first block in partition
0x0C 4 bytes Number of Blocks in partition
Note: Will only use the last two entries for LBA addressing.
- this means that both CHS fields are zeroed out.
The Partition Record Boot code will determine the active partition and size.
- it will set parameters for the BIOS/SIM modules.
- It will then load the Boot Record for the active partition
- The Boot Record:
Contains 16KB of system tracks (separate from drive partitions)
System Tracks contain:
- SIM Module - interfaces PEM to BIOS
- Disk Parameter Blocks
- Disk Allocation Maps
- PEM module - core filesystem for DOS/65
The Boot Record code will load the system tracks into high memory
- Memory Locations are contained in the Boot Record
- Once loaded, a jump to SIM entry will start the boot process
for DOS/65. SIM will:
- initialize all of the DPBs and Allocation Maps
- Jump to PEM to initialize the filesystem
PEM starts:
- PEM will cold boot
- PEM will select Drive A for default
- PEM will load CCM from Drive A into high memory
- PEM will jump to CCM and the user is up and running
******************************************************************************************************
Writing a disk setup utility (dare I call it fdisk) will allow multiple partitions to be booted. With 6GB of space, I can have multiple OSes on the drive and even keep multiple versions for testing, etc.
Of course, one of the plans is to get CPM65 up and running as well (see other other thread for that).
I have a plan.... modify the hardware first, update the BIOS and Monitor code as required, write a fdisk style utility and get SYSGEN running for the updated DOS/65 code. It's not going to happen super fast, but this is the plan to get there.
Ideas, feedback, criticism, all welcome.
As I'm looking to go to a more capable system (more memory, banking, faster CPU) I'm also looking to have the operating system booted from the drive and run entirely in RAM (sans the ROM based BIOS).
The memory configuration for the C02 Pocket:
- 32KB SRAM from $0000 - $7FFF
- 32KB EEPROM from $8000 - $FFFF
An I/O window is configure at $FE00 and has 5- 32-byte wide selects
The updated memory configuration for the 3.3V prototype:
- 56KB SRAM from $0000 - $DFFF
- 8KB EEPROM from $E000 - $FFFF
An I/O window is unchanged at $FE00
The 8KB of EEPROM will remain as:
- BIOS from $F800 - $FFFF (sans the I/O window)
- Monitor from $E000 - $F7FF
Rather than enable an autoboot from the Microdrive, I prefer to be able to run the system without the bootable OS so I have options on doing other things... the Monitor supports Xmodem CRC upload and download capability.
Now the fun part... I actually wrote custom partition loaders back in the 80's, as the PC-AT only had a handful of defined disk drive parameters, so if you had a drive that wasn't part of the ROM table, you couldn't really use it fully or maybe worse. I wrote a a custom partition loader that would softload the disk parameters for the BIOS and then load the boot record to kick off the OS load... worked like a charm. So I get to do some of this stuff again.
Here's my basic scheme:
******************************************************************************************************
Microdrive Bootable design:
******************************************************************************************************
LBA mode is used exclusively!
When the C02 Pocket is powered up:
- BIOS initializes the system:
- Clear Page Zero
- Load Page $03 with Vector and Soft Config data
- Initialize SC28L92 DUART and Timer/Counter
- Show BIOS version message
- Initialize additional hardware
- Maxim DS15x1 Realtime Clock
- Microdrive IDE interface
- Cold start System Monitor
- Monitor code will display some version information, user prompt
- Using a Ctrl-B will Load LBA zero from Microdrive to memory $0600
- Will sense Partition code signature (0x02 0x65)
- If signature Valid, will Jump to Boot code in memory
- If signature Invalid, will show error message and warm start monitor
******************************************************************************************************
LBA zero contains an Ontrack Disk Manager partition record.
- 252 bytes of code
- optional 2 byte signature: suggested use as (0x02 0x65) 6502 in little-endian
- There are 4 standard partition entries - 16 bytes each
- There are 12 expanded partition entries - 16 bytes each
- 2 bytes final signature (0x55, 0xAA)
******************************************************************************************************
Note: Partition type for CPM is hex “DB”
A 16-byte partition record is defined as:
Offset: Length Description
0x00 1 byte Status byte - bit 7 set (0x80) = active, else 0x00
0x01 3 bytes CHS address first sector in partition
0x04 1 byte Partition Type (CPM = hex DB)
0x05 3 bytes CHS address last sector in partition
0x08 4 bytes LBA of first block in partition
0x0C 4 bytes Number of Blocks in partition
Note: Will only use the last two entries for LBA addressing.
- this means that both CHS fields are zeroed out.
The Partition Record Boot code will determine the active partition and size.
- it will set parameters for the BIOS/SIM modules.
- It will then load the Boot Record for the active partition
- The Boot Record:
Contains 16KB of system tracks (separate from drive partitions)
System Tracks contain:
- SIM Module - interfaces PEM to BIOS
- Disk Parameter Blocks
- Disk Allocation Maps
- PEM module - core filesystem for DOS/65
The Boot Record code will load the system tracks into high memory
- Memory Locations are contained in the Boot Record
- Once loaded, a jump to SIM entry will start the boot process
for DOS/65. SIM will:
- initialize all of the DPBs and Allocation Maps
- Jump to PEM to initialize the filesystem
PEM starts:
- PEM will cold boot
- PEM will select Drive A for default
- PEM will load CCM from Drive A into high memory
- PEM will jump to CCM and the user is up and running
******************************************************************************************************
Writing a disk setup utility (dare I call it fdisk) will allow multiple partitions to be booted. With 6GB of space, I can have multiple OSes on the drive and even keep multiple versions for testing, etc.
Of course, one of the plans is to get CPM65 up and running as well (see other other thread for that).
I have a plan.... modify the hardware first, update the BIOS and Monitor code as required, write a fdisk style utility and get SYSGEN running for the updated DOS/65 code. It's not going to happen super fast, but this is the plan to get there.
Ideas, feedback, criticism, all welcome.