split wdc_ram.[ch] into wdc_ram.[ch] and additionally wdc_par.[ch]
remove direct accessing of par_table
This commit is contained in:
parent
8c8505b107
commit
8576a53f28
|
|
@ -40,6 +40,7 @@ C_SRCS += \
|
||||||
../uart.c \
|
../uart.c \
|
||||||
../wdc_if_pio.c \
|
../wdc_if_pio.c \
|
||||||
../wdc_if_sdcard.c \
|
../wdc_if_sdcard.c \
|
||||||
|
../wdc_par.c \
|
||||||
../wdc_ram.c
|
../wdc_ram.c
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -55,6 +56,7 @@ mmc.o \
|
||||||
uart.o \
|
uart.o \
|
||||||
wdc_if_pio.o \
|
wdc_if_pio.o \
|
||||||
wdc_if_sdcard.o \
|
wdc_if_sdcard.o \
|
||||||
|
wdc_par.o \
|
||||||
wdc_ram.o
|
wdc_ram.o
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -64,6 +66,7 @@ mmc.o \
|
||||||
uart.o \
|
uart.o \
|
||||||
wdc_if_pio.o \
|
wdc_if_pio.o \
|
||||||
wdc_if_sdcard.o \
|
wdc_if_sdcard.o \
|
||||||
|
wdc_par.o \
|
||||||
wdc_ram.o
|
wdc_ram.o
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -73,6 +76,7 @@ mmc.d \
|
||||||
uart.d \
|
uart.d \
|
||||||
wdc_if_pio.d \
|
wdc_if_pio.d \
|
||||||
wdc_if_sdcard.d \
|
wdc_if_sdcard.d \
|
||||||
|
wdc_par.d \
|
||||||
wdc_ram.d
|
wdc_ram.d
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,6 +86,7 @@ mmc.d \
|
||||||
uart.d \
|
uart.d \
|
||||||
wdc_if_pio.d \
|
wdc_if_pio.d \
|
||||||
wdc_if_sdcard.d \
|
wdc_if_sdcard.d \
|
||||||
|
wdc_par.d \
|
||||||
wdc_ram.d
|
wdc_ram.d
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -107,6 +112,8 @@ OUTPUT_FILE_DEP:= ./makedep.mk
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
./%.o: .././%.c
|
./%.o: .././%.c
|
||||||
@echo Building file: $<
|
@echo Building file: $<
|
||||||
@echo Invoking: AVR/GNU C Compiler : (AVR_8_bit_GNU_Toolchain_3.4.0_663) 4.6.2
|
@echo Invoking: AVR/GNU C Compiler : (AVR_8_bit_GNU_Toolchain_3.4.0_663) 4.6.2
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,7 @@ wdc_if_pio.c
|
||||||
|
|
||||||
wdc_if_sdcard.c
|
wdc_if_sdcard.c
|
||||||
|
|
||||||
|
wdc_par.c
|
||||||
|
|
||||||
wdc_ram.c
|
wdc_ram.c
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,28 +45,28 @@
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<ToolchainSettings>
|
<ToolchainSettings>
|
||||||
<AvrGcc>
|
<AvrGcc>
|
||||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||||
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
|
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
|
||||||
<avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
<avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</avrgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||||
<avrgcc.compiler.warnings.Undefined>True</avrgcc.compiler.warnings.Undefined>
|
<avrgcc.compiler.warnings.Undefined>True</avrgcc.compiler.warnings.Undefined>
|
||||||
<avrgcc.compiler.warnings.WarningsAsErrors>True</avrgcc.compiler.warnings.WarningsAsErrors>
|
<avrgcc.compiler.warnings.WarningsAsErrors>True</avrgcc.compiler.warnings.WarningsAsErrors>
|
||||||
<avrgcc.compiler.warnings.Pedantic>True</avrgcc.compiler.warnings.Pedantic>
|
<avrgcc.compiler.warnings.Pedantic>True</avrgcc.compiler.warnings.Pedantic>
|
||||||
<avrgcc.compiler.warnings.PedanticWarningsAsErrors>True</avrgcc.compiler.warnings.PedanticWarningsAsErrors>
|
<avrgcc.compiler.warnings.PedanticWarningsAsErrors>True</avrgcc.compiler.warnings.PedanticWarningsAsErrors>
|
||||||
<avrgcc.linker.libraries.Libraries>
|
<avrgcc.linker.libraries.Libraries>
|
||||||
<ListValues>
|
<ListValues>
|
||||||
<Value>m</Value>
|
<Value>m</Value>
|
||||||
</ListValues>
|
</ListValues>
|
||||||
</avrgcc.linker.libraries.Libraries>
|
</avrgcc.linker.libraries.Libraries>
|
||||||
<avrgcc.linker.optimization.GarbageCollectUnusedSections>True</avrgcc.linker.optimization.GarbageCollectUnusedSections>
|
<avrgcc.linker.optimization.GarbageCollectUnusedSections>True</avrgcc.linker.optimization.GarbageCollectUnusedSections>
|
||||||
<avrgcc.linker.optimization.RelaxBranches>True</avrgcc.linker.optimization.RelaxBranches>
|
<avrgcc.linker.optimization.RelaxBranches>True</avrgcc.linker.optimization.RelaxBranches>
|
||||||
</AvrGcc>
|
</AvrGcc>
|
||||||
</ToolchainSettings>
|
</ToolchainSettings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -103,6 +103,12 @@
|
||||||
<Compile Include="wdc_if_sdcard.h">
|
<Compile Include="wdc_if_sdcard.h">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="wdc_par.c">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="wdc_par.h">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="wdc_ram.c">
|
<Compile Include="wdc_ram.c">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* P8000 WDC Emulator
|
* P8000 WDC Emulator
|
||||||
*
|
*
|
||||||
* $Id: wdc_if_disk.c,v 1.5 2012/06/05 18:21:48 olivleh1 Exp $
|
* $Id: wdc_if_disk.c,v 1.6 2012/06/06 22:05:06 olivleh1 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "mmc.h"
|
#include "mmc.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
extern uint8_t par_table[200];
|
#include "wdc_par.h"
|
||||||
|
|
||||||
|
extern uint8_t par_table[];
|
||||||
|
|
||||||
uint8_t wdc_init_sdcard()
|
uint8_t wdc_init_sdcard()
|
||||||
{
|
{
|
||||||
|
|
@ -17,24 +19,15 @@ uint8_t wdc_init_sdcard()
|
||||||
|
|
||||||
uint32_t wdc_sector2sdblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector )
|
uint32_t wdc_sector2sdblock ( uint16_t req_cylinder, uint8_t req_head, uint8_t req_sector )
|
||||||
{
|
{
|
||||||
/* TODO: no direct access of par_table - use getter functions instead - but only after speed is sufficient */
|
return ( ( req_cylinder * wdc_get_hdd_heads() * wdc_get_hdd_sectors() )
|
||||||
/* +-------------------------------------------------------------- requested cylinder from P8000
|
+ ( req_head * wdc_get_hdd_sectors() )
|
||||||
* | +----------------------------------------------- configured heads form the harddisk
|
+ ( req_sector - 1 ) );
|
||||||
* | | +------------------------------- configured sectors for the harddisk
|
|
||||||
* | | | +-------------- requested head from P8000
|
|
||||||
* | | | | +-- configured sectors for the harddisk
|
|
||||||
* | | | | | +---- requested sector from P8000 - 1 as we start counting with 0
|
|
||||||
* | | | | | | */
|
|
||||||
return ( ( req_cylinder * par_table[25] * par_table[26] ) + ( req_head * par_table[26] ) + ( req_sector - 1 ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t wdc_p8kblock2sdblock ( uint32_t blockno )
|
uint32_t wdc_p8kblock2sdblock ( uint32_t blockno )
|
||||||
{
|
{
|
||||||
/* TODO: no direct access of par_table - use getter functions instead - but only after speed is sufficient */
|
return ( blockno
|
||||||
/* +----------------------------------------------- configured heads form the harddisk
|
+ ( wdc_get_hdd_heads() * wdc_get_hdd_sectors() ) );
|
||||||
* | +------------------------------- configured sectors for the harddisk
|
|
||||||
* | |*/
|
|
||||||
return ( blockno + ( par_table[25] * par_table[26] ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t wdc_write_sector ( uint32_t addr, uint8_t *sector )
|
uint8_t wdc_write_sector ( uint32_t addr, uint8_t *sector )
|
||||||
|
|
@ -82,7 +75,7 @@ uint8_t wdc_read_multiblock ( uint32_t addr, uint8_t *sector, uint8_t numblocks
|
||||||
uart_putc ( '\n' );
|
uart_putc ( '\n' );
|
||||||
return errorcode;
|
return errorcode;
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t wdc_write_multiblock ( uint32_t addr, uint8_t *sector, uint8_t numblocks )
|
uint8_t wdc_write_multiblock ( uint32_t addr, uint8_t *sector, uint8_t numblocks )
|
||||||
|
|
@ -90,7 +83,7 @@ uint8_t wdc_write_multiblock ( uint32_t addr, uint8_t *sector, uint8_t numblocks
|
||||||
uint8_t errorcode;
|
uint8_t errorcode;
|
||||||
|
|
||||||
errorcode = mmc_write_multiblock ( addr, sector, numblocks );
|
errorcode = mmc_write_multiblock ( addr, sector, numblocks );
|
||||||
// errorcode = mmc_write_multiblock_predef ( addr, sector, numblocks );
|
// errorcode = mmc_write_multiblock_predef ( addr, sector, numblocks );
|
||||||
if ( errorcode ) {
|
if ( errorcode ) {
|
||||||
uart_puts_p ( PSTR ( " write error at address: " ) );
|
uart_puts_p ( PSTR ( " write error at address: " ) );
|
||||||
uart_putdw_dec ( addr );
|
uart_putdw_dec ( addr );
|
||||||
|
|
@ -99,5 +92,5 @@ uint8_t wdc_write_multiblock ( uint32_t addr, uint8_t *sector, uint8_t numblocks
|
||||||
uart_putc ( '\n' );
|
uart_putc ( '\n' );
|
||||||
return errorcode;
|
return errorcode;
|
||||||
} else
|
} else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* P8000 WDC Emulator
|
* P8000 WDC Emulator
|
||||||
*
|
*
|
||||||
* $Id: wdc_main.c,v 1.12 2012/06/05 20:30:09 olivleh1 Exp $
|
* $Id: wdc_main.c,v 1.13 2012/06/06 22:05:06 olivleh1 Exp $
|
||||||
*
|
*
|
||||||
* TODO: - Different Errorcodes in the MMC layer (use defines)
|
* TODO: - Different Errorcodes in the MMC layer (use defines)
|
||||||
* - errorchecking in several places
|
* - errorchecking in several places
|
||||||
* - Prio 1: more commandcodes
|
|
||||||
* - Prio 2: check if BTT is really cleaned when sa.format gets called all the time with a real drive
|
* - Prio 2: check if BTT is really cleaned when sa.format gets called all the time with a real drive
|
||||||
* ----------> no the old BTT from the previous formatting is shown
|
* ----------> no the old BTT from the previous formatting is shown
|
||||||
* ----------> check if after formatting, no BTT is written to the disk, the old BTT is still there
|
* ----------> check if after formatting, no BTT is written to the disk, the old BTT is still there
|
||||||
|
|
@ -24,12 +23,17 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "uart.h"
|
#include "uart.h"
|
||||||
#include "wdc_ram.h"
|
#include "wdc_ram.h"
|
||||||
|
#include "wdc_par.h"
|
||||||
#include "wdc_if_pio.h"
|
#include "wdc_if_pio.h"
|
||||||
#include "wdc_if_sdcard.h"
|
#include "wdc_if_sdcard.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#undef MEASURE_SDCARD_TIME
|
#undef MEASURE_SDCARD_TIME
|
||||||
|
|
||||||
|
/* switched from local to global for keeping an eye on memory usage */
|
||||||
|
uint8_t data_buffer[4096];
|
||||||
|
uint8_t cmd_buffer[9];
|
||||||
|
|
||||||
void atmega_setup ( void );
|
void atmega_setup ( void );
|
||||||
|
|
||||||
#ifdef MEASURE_SDCARD_TIME
|
#ifdef MEASURE_SDCARD_TIME
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* P8000 WDC Emulator
|
* P8000 WDC Emulator
|
||||||
*
|
*
|
||||||
* $Id: wdc_main.h,v 1.8 2012/06/03 13:38:03 olivleh1 Exp $
|
* $Id: wdc_main.h,v 1.9 2012/06/06 22:05:06 olivleh1 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -10,12 +10,12 @@
|
||||||
#define MAIN_H_
|
#define MAIN_H_
|
||||||
|
|
||||||
#define CMD_RD_SECTOR 0x01 /* read data beginning at given sector */
|
#define CMD_RD_SECTOR 0x01 /* read data beginning at given sector */
|
||||||
#define _CMD_WR_SECTOR 0x02 /* write sector */
|
#define ___CMD_WR_SECTOR 0x02 /* write sector */
|
||||||
#define _CMD_FMT_TRACK 0x04 /* format a track */
|
#define ___CMD_FMT_TRACK 0x04 /* format a track */
|
||||||
#define CMD_RD_WDC_RAM 0x08 /* read data from WDC RAM */
|
#define CMD_RD_WDC_RAM 0x08 /* read data from WDC RAM */
|
||||||
#define NO_CMD_RDBTT_SECTOR 0x11 /* read sector taking BTT into account */
|
#define ___CMD_RDBTT_SECTOR 0x11 /* read sector taking BTT into account */
|
||||||
#define NO_CMD_WRBTT_SECTOR 0x12 /* write sector taking BTT into account */
|
#define ___CMD_WRBTT_SECTOR 0x12 /* write sector taking BTT into account */
|
||||||
#define NO_CMD_FMTRD_TRACK 0x14 /* format and reread a track */
|
#define ___CMD_FMTRD_TRACK 0x14 /* format and reread a track */
|
||||||
#define CMD_WR_WDC_RAM 0x18 /* write data to WDC RAM */
|
#define CMD_WR_WDC_RAM 0x18 /* write data to WDC RAM */
|
||||||
#define CMD_RD_BLOCK 0x21 /* read data beginning at given block */
|
#define CMD_RD_BLOCK 0x21 /* read data beginning at given block */
|
||||||
#define CMD_WR_BLOCK 0x22 /* write data beginning at given block */
|
#define CMD_WR_BLOCK 0x22 /* write data beginning at given block */
|
||||||
|
|
@ -27,12 +27,12 @@
|
||||||
#define CMD_RD_BTTAB 0x58 /* read Bad Track Table from WDC RAM */
|
#define CMD_RD_BTTAB 0x58 /* read Bad Track Table from WDC RAM */
|
||||||
#define CMD_WR_BTTAB 0x68 /* write Bad Track Table to WDC RAM */
|
#define CMD_WR_BTTAB 0x68 /* write Bad Track Table to WDC RAM */
|
||||||
#define CMD_WR_PARTAB 0x78 /* write Parameter block to WDC RAM */
|
#define CMD_WR_PARTAB 0x78 /* write Parameter block to WDC RAM */
|
||||||
#define NO_CMD_VER_SECTOR 0x81 /* verify sector */
|
#define ___CMD_VER_SECTOR 0x81 /* verify sector */
|
||||||
#define NO_CMD_WRRD_SECTOR 0x82 /* write and reread sector */
|
#define ___CMD_WRRD_SECTOR 0x82 /* write and reread sector */
|
||||||
#define NO_CMD_DL_TRACK 0x84 /* delete a track */
|
#define ___CMD_DL_TRACK 0x84 /* delete a track */
|
||||||
#define NO_CMD_WRRDBTT_SECTOR 0x92 /* write and reread sector taking BTT into account */
|
#define ___CMD_WRRDBTT_SECTOR 0x92 /* write and reread sector taking BTT into account */
|
||||||
#define NO_CMD_CP_BLOCK 0xa1 /* copy block from drive 1 to drive 0 */
|
#define ___CMD_CP_BLOCK 0xa1 /* copy block from drive 1 to drive 0 */
|
||||||
#define NO_CMD_WRRD_BLOCK 0xa2 /* write and reread block */
|
#define ___CMD_WRRD_BLOCK 0xa2 /* write and reread block */
|
||||||
#define CMD_ST_PARBTT 0xc2 /* store PAR and BTT on harddisk */
|
#define CMD_ST_PARBTT 0xc2 /* store PAR and BTT on hard disk */
|
||||||
|
|
||||||
#endif /* MAIN_H_ */
|
#endif /* MAIN_H_ */
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* P8000 WDC Emulator
|
||||||
|
*
|
||||||
|
* $Id: wdc_par.c,v 1.1 2012/06/06 22:05:06 olivleh1 Exp $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "wdc_par.h"
|
||||||
|
|
||||||
|
uint8_t par_table[512] = {'W', 'D', 'C', '_', '4', '.', '2', 0x00, 'R', 'O', 'B', ' ', 'K', '5', '5', '0',
|
||||||
|
'4', '.', '5', '0', 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x12, 0x00, 0x04, 0x01, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x67, 0x01, 0x00, 0x01, 0x01,
|
||||||
|
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void wdc_read_par_table ( uint8_t *buffer, uint16_t count )
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
count--;
|
||||||
|
buffer[count] = par_table[count];
|
||||||
|
} while ( count > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wdc_write_par_table ( uint8_t *buffer, uint16_t count )
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
count--;
|
||||||
|
par_table[count] = buffer[count];
|
||||||
|
} while ( count > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wdc_read_wdc_par ( uint8_t *buffer, uint16_t count )
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
count--;
|
||||||
|
buffer[count] = par_table[count + POS_PAR_WDC_PAR];
|
||||||
|
} while ( count > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wdc_write_wdc_par ( uint8_t *buffer, uint16_t count )
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
count--;
|
||||||
|
par_table[count + POS_PAR_WDC_PAR] = buffer[count];
|
||||||
|
} while ( count > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wdc_del_wdc_btt()
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for ( i = 0; i < 125; i++ )
|
||||||
|
par_table[i + POS_PAR_WDC_BTT] = 0x00;
|
||||||
|
par_table[122 + POS_PAR_WDC_BTT] = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wdc_read_wdc_btt ( uint8_t *buffer, uint16_t count )
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
count--;
|
||||||
|
buffer[count] = par_table[count + POS_PAR_WDC_BTT];
|
||||||
|
} while ( count > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wdc_write_wdc_btt ( uint8_t *buffer, uint16_t count )
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
count--;
|
||||||
|
par_table[count + POS_PAR_WDC_BTT] = buffer[count];
|
||||||
|
} while ( count > 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t wdc_get_btt_count()
|
||||||
|
{
|
||||||
|
return ( ( par_table[0 + POS_PAR_WDC_BTT] | ( par_table[1 + POS_PAR_WDC_BTT] << 8 ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wdc_set_btt_count ( uint16_t btt_count )
|
||||||
|
{
|
||||||
|
par_table[0 + POS_PAR_WDC_BTT] = ( uint8_t ) btt_count;
|
||||||
|
par_table[1 + POS_PAR_WDC_BTT] = ( btt_count >> 8 );
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t wdc_add_btt_entry ( uint16_t cylinder, uint8_t head )
|
||||||
|
{
|
||||||
|
uint16_t btt_count = wdc_get_btt_count();
|
||||||
|
|
||||||
|
if ( btt_count < 120 ) {
|
||||||
|
/* +2 because btt_count is just the amount of bytes for the BTT - but in front of it, there are two bytes */
|
||||||
|
/* storing the amount of bytes for the BTT */
|
||||||
|
par_table[btt_count + 2 + POS_PAR_WDC_BTT] = ( cylinder >> 8 );
|
||||||
|
btt_count++;
|
||||||
|
par_table[btt_count + 2 + POS_PAR_WDC_BTT] = ( uint8_t ) cylinder;
|
||||||
|
btt_count++;
|
||||||
|
par_table[btt_count + 2 + POS_PAR_WDC_BTT] = ( uint8_t ) head;
|
||||||
|
btt_count++;
|
||||||
|
wdc_set_btt_count ( btt_count );
|
||||||
|
return ( 0 );
|
||||||
|
} else {
|
||||||
|
return ( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t wdc_get_hdd_sectors()
|
||||||
|
{
|
||||||
|
return ( par_table[18 + POS_PAR_WDC_PAR] );
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t wdc_get_hdd_heads()
|
||||||
|
{
|
||||||
|
return ( par_table[17 + POS_PAR_WDC_PAR] );
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* P8000 WDC Emulator
|
||||||
|
*
|
||||||
|
* $IdS$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WDC_PAR_H_
|
||||||
|
#define WDC_PAR_H_
|
||||||
|
|
||||||
|
extern void wdc_read_par_table ( uint8_t *buffer, uint16_t count );
|
||||||
|
extern void wdc_write_par_table ( uint8_t *buffer, uint16_t count );
|
||||||
|
|
||||||
|
extern void wdc_read_wdc_par ( uint8_t *buffer, uint16_t count );
|
||||||
|
extern void wdc_write_wdc_par ( uint8_t *buffer, uint16_t count );
|
||||||
|
|
||||||
|
extern void wdc_del_wdc_btt();
|
||||||
|
extern void wdc_read_wdc_btt ( uint8_t *buffer, uint16_t count );
|
||||||
|
extern void wdc_write_wdc_btt ( uint8_t *buffer, uint16_t count );
|
||||||
|
extern uint16_t wdc_get_btt_count();
|
||||||
|
extern uint8_t wdc_add_btt_entry ( uint16_t cylinder, uint8_t head );
|
||||||
|
|
||||||
|
extern uint8_t wdc_get_hdd_sectors();
|
||||||
|
extern uint8_t wdc_get_hdd_heads();
|
||||||
|
|
||||||
|
#define POS_PAR_VERSION 0
|
||||||
|
#define POS_PAR_WDC_PAR 8
|
||||||
|
#define POS_PAR_WDC_BTT 88
|
||||||
|
|
||||||
|
#define SIZE_PAR_VERSION 8
|
||||||
|
#define SIZE_PAR_WDC_PAR 80
|
||||||
|
#define SIZE_PAR_WDC_BTT 125
|
||||||
|
|
||||||
|
#endif /* WDC_PAR_H_ */
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* P8000 WDC Emulator
|
* P8000 WDC Emulator
|
||||||
*
|
*
|
||||||
* $Id: wdc_ram.c,v 1.3 2012/06/02 00:51:55 olivleh1 Exp $
|
* $Id: wdc_ram.c,v 1.4 2012/06/06 22:05:06 olivleh1 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -9,11 +9,6 @@
|
||||||
#include "wdc_ram.h"
|
#include "wdc_ram.h"
|
||||||
|
|
||||||
uint8_t wdc_ram[2048];
|
uint8_t wdc_ram[2048];
|
||||||
uint8_t par_table[512] = {'W', 'D', 'C', '_', '4', '.', '2', 0x00, 'R', 'O', 'B', ' ', 'K', '5', '5', '0',
|
|
||||||
'4', '.', '5', '0', 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x12, 0x00, 0x04, 0x01, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x67, 0x01, 0x00, 0x01, 0x01,
|
|
||||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
void wdc_write_data_to_ram ( uint8_t *buffer, uint16_t address, uint16_t count )
|
void wdc_write_data_to_ram ( uint8_t *buffer, uint16_t address, uint16_t count )
|
||||||
{
|
{
|
||||||
|
|
@ -30,97 +25,3 @@ void wdc_read_data_from_ram ( uint8_t *buffer, uint16_t address, uint16_t count
|
||||||
buffer[count] = wdc_ram[address + count];
|
buffer[count] = wdc_ram[address + count];
|
||||||
} while ( count > 0 );
|
} while ( count > 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wdc_read_par_table ( uint8_t *buffer, uint16_t count )
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
count--;
|
|
||||||
buffer[count] = par_table[count];
|
|
||||||
} while ( count > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wdc_write_par_table ( uint8_t *buffer, uint16_t count )
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
count--;
|
|
||||||
par_table[count] = buffer[count];
|
|
||||||
} while ( count > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void wdc_read_wdc_par ( uint8_t *buffer, uint16_t count )
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
count--;
|
|
||||||
buffer[count] = par_table[count + POS_PAR_WDC_PAR];
|
|
||||||
} while ( count > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wdc_write_wdc_par ( uint8_t *buffer, uint16_t count )
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
count--;
|
|
||||||
par_table[count + POS_PAR_WDC_PAR] = buffer[count];
|
|
||||||
} while ( count > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wdc_del_wdc_btt()
|
|
||||||
{
|
|
||||||
uint8_t i;
|
|
||||||
for ( i = 0; i < 125; i++ )
|
|
||||||
par_table[i + POS_PAR_WDC_BTT] = 0x00;
|
|
||||||
par_table[122 + POS_PAR_WDC_BTT] = 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wdc_read_wdc_btt ( uint8_t *buffer, uint16_t count )
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
count--;
|
|
||||||
buffer[count] = par_table[count + POS_PAR_WDC_BTT];
|
|
||||||
} while ( count > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wdc_write_wdc_btt ( uint8_t *buffer, uint16_t count )
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
count--;
|
|
||||||
par_table[count + POS_PAR_WDC_BTT] = buffer[count];
|
|
||||||
} while ( count > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t wdc_get_btt_count()
|
|
||||||
{
|
|
||||||
return ( ( par_table[0 + POS_PAR_WDC_BTT] | ( par_table[1 + POS_PAR_WDC_BTT] << 8 ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void wdc_set_btt_count ( uint16_t btt_count )
|
|
||||||
{
|
|
||||||
par_table[0 + POS_PAR_WDC_BTT] = ( uint8_t ) btt_count;
|
|
||||||
par_table[1 + POS_PAR_WDC_BTT] = ( btt_count >> 8 );
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t wdc_add_btt_entry ( uint16_t cylinder, uint8_t head )
|
|
||||||
{
|
|
||||||
uint16_t btt_count = wdc_get_btt_count();
|
|
||||||
|
|
||||||
if ( btt_count < 120 ) {
|
|
||||||
/* +2 because btt_count is just the amount of bytes for the BTT - but in front of it, there are two bytes */
|
|
||||||
/* storing the amount of bytes for the BTT */
|
|
||||||
par_table[btt_count + 2 + POS_PAR_WDC_BTT] = ( cylinder >> 8 );
|
|
||||||
btt_count++;
|
|
||||||
par_table[btt_count + 2 + POS_PAR_WDC_BTT] = ( uint8_t ) cylinder;
|
|
||||||
btt_count++;
|
|
||||||
par_table[btt_count + 2 + POS_PAR_WDC_BTT] = ( uint8_t ) head;
|
|
||||||
btt_count++;
|
|
||||||
wdc_set_btt_count ( btt_count );
|
|
||||||
return ( 0 );
|
|
||||||
} else {
|
|
||||||
return ( 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t wdc_get_hdd_sectors()
|
|
||||||
{
|
|
||||||
return ( par_table[18 + POS_PAR_WDC_PAR] );
|
|
||||||
}
|
|
||||||
|
|
@ -1,42 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* P8000 WDC Emulator
|
* P8000 WDC Emulator
|
||||||
*
|
*
|
||||||
* $Id: wdc_ram.h,v 1.3 2012/06/05 20:30:09 olivleh1 Exp $
|
* $Id: wdc_ram.h,v 1.4 2012/06/06 22:05:06 olivleh1 Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WDC_RAM_H_
|
#ifndef WDC_RAM_H_
|
||||||
#define WDC_RAM_H_
|
#define WDC_RAM_H_
|
||||||
|
|
||||||
void wdc_write_data_to_ram ( uint8_t *buffer, uint16_t address, uint16_t count );
|
extern void wdc_write_data_to_ram ( uint8_t *buffer, uint16_t address, uint16_t count );
|
||||||
void wdc_read_data_from_ram ( uint8_t *buffer, uint16_t address, uint16_t count );
|
extern void wdc_read_data_from_ram ( uint8_t *buffer, uint16_t address, uint16_t count );
|
||||||
|
|
||||||
void wdc_read_par_table ( uint8_t *buffer, uint16_t count );
|
|
||||||
void wdc_write_par_table ( uint8_t *buffer, uint16_t count );
|
|
||||||
|
|
||||||
void wdc_read_wdc_par ( uint8_t *buffer, uint16_t count );
|
|
||||||
void wdc_write_wdc_par ( uint8_t *buffer, uint16_t count );
|
|
||||||
|
|
||||||
void wdc_del_wdc_btt();
|
|
||||||
void wdc_read_wdc_btt ( uint8_t *buffer, uint16_t count );
|
|
||||||
void wdc_write_wdc_btt ( uint8_t *buffer, uint16_t count );
|
|
||||||
uint16_t wdc_get_btt_count();
|
|
||||||
uint8_t wdc_add_btt_entry ( uint16_t cylinder, uint8_t head );
|
|
||||||
|
|
||||||
uint8_t wdc_get_hdd_sectors();
|
|
||||||
|
|
||||||
#define convert_ram_address(x) ((x) - 0x2000) /* The S-RAM of the original WDC hardware starts at 0x2000. We use an array as RAM here and no direct RAM access */
|
#define convert_ram_address(x) ((x) - 0x2000) /* The S-RAM of the original WDC hardware starts at 0x2000. We use an array as RAM here and no direct RAM access */
|
||||||
|
|
||||||
#define POS_PAR_VERSION 0
|
|
||||||
#define POS_PAR_WDC_PAR 8
|
|
||||||
#define POS_PAR_WDC_BTT 88
|
|
||||||
|
|
||||||
#define SIZE_PAR_VERSION 8
|
|
||||||
#define SIZE_PAR_WDC_PAR 80
|
|
||||||
#define SIZE_PAR_WDC_BTT 125
|
|
||||||
|
|
||||||
/* switched from local to global for keeping an eye on memory usage */
|
|
||||||
uint8_t data_buffer[4096];
|
|
||||||
uint8_t cmd_buffer[9];
|
|
||||||
|
|
||||||
#endif /* WDC_RAM_H_ */
|
#endif /* WDC_RAM_H_ */
|
||||||
Loading…
Reference in New Issue