Volatile qualifiers added
This commit is contained in:
parent
9a12bb90ed
commit
af78b0fd44
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
make clean
|
||||||
|
make
|
||||||
|
java -jar AppleCommander-ac-1.5.0.jar -d flasher.dsk flasher
|
||||||
|
java -jar AppleCommander-ac-1.5.0.jar -as flasher.dsk flasher < flasher.bin
|
|
@ -6,16 +6,20 @@ typedef unsigned short uint16;
|
||||||
typedef unsigned long uint32;
|
typedef unsigned long uint32;
|
||||||
typedef unsigned char boolean;
|
typedef unsigned char boolean;
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
#ifndef FALSE
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SLOT_IO_START (uint8*)0xC080
|
#define SLOT_IO_START (volatile uint8*)0xC080
|
||||||
#define SLOT_ROM_START (uint8*)0xC000
|
#define SLOT_ROM_START (volatile uint8*)0xC000
|
||||||
#define EXT_ROM_START (uint8*)0xC800
|
#define EXT_ROM_START (volatile uint8*)0xC800
|
||||||
|
|
||||||
#define CFFF (uint8*)0xCFFF
|
#define CFFF (volatile uint8*)0xCFFF
|
||||||
|
|
||||||
typedef struct
|
typedef volatile struct
|
||||||
{
|
{
|
||||||
// data register
|
// data register
|
||||||
// +0
|
// +0
|
||||||
|
@ -40,12 +44,9 @@ typedef struct
|
||||||
uint8 status;
|
uint8 status;
|
||||||
} status;
|
} status;
|
||||||
|
|
||||||
// clock divisor register
|
// clock divisor register, unused
|
||||||
// +2
|
// +2
|
||||||
union
|
uint8 clkDiv;
|
||||||
{
|
|
||||||
unsigned clkDiv : 2;
|
|
||||||
};
|
|
||||||
|
|
||||||
// slave select and card state register
|
// slave select and card state register
|
||||||
// +3
|
// +3
|
||||||
|
@ -56,8 +57,8 @@ typedef struct
|
||||||
unsigned slaveSel : 1;
|
unsigned slaveSel : 1;
|
||||||
unsigned : 3;
|
unsigned : 3;
|
||||||
unsigned sdhc : 1;
|
unsigned sdhc : 1;
|
||||||
unsigned wp : 1;
|
const unsigned wp : 1;
|
||||||
unsigned card : 1;
|
const unsigned card : 1;
|
||||||
unsigned inited : 1;
|
unsigned inited : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <apple2enh.h>
|
#include <apple2enh.h>
|
||||||
|
|
||||||
|
// Binary can't be larger than 2k
|
||||||
|
#define BUFFER_SIZE 2048
|
||||||
#define BIN_FILE_NAME "AppleIISd.bin"
|
#define BIN_FILE_NAME "AppleIISd.bin"
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -14,17 +16,16 @@ typedef enum
|
||||||
STATE_2, // hyphen
|
STATE_2, // hyphen
|
||||||
STATE_3, // backslash
|
STATE_3, // backslash
|
||||||
|
|
||||||
STATE_LAST // don't use
|
STATE_LAST // don't use
|
||||||
} STATE_CURSOR_T;
|
} STATE_CURSOR_T;
|
||||||
|
|
||||||
const char state_char[STATE_LAST] = { '|', '/', '-', '\\' };
|
const char state_char[STATE_LAST] = { '|', '/', '-', '\\' };
|
||||||
|
uint8 buffer[BUFFER_SIZE] = { 0 };
|
||||||
|
|
||||||
|
|
||||||
boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length);
|
boolean writeChip(const uint8* pSource, volatile uint8* pDest, uint16 length);
|
||||||
void printStatus(uint8 percentage);
|
void printStatus(uint8 percentage);
|
||||||
|
|
||||||
// Binary can't be larger than 2k
|
|
||||||
uint8 buffer[2048] = { 0 };
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -35,8 +36,7 @@ int main()
|
||||||
uint16 fileSize = 0;
|
uint16 fileSize = 0;
|
||||||
|
|
||||||
APPLE_II_SD_T* pAIISD = (APPLE_II_SD_T*)SLOT_IO_START;
|
APPLE_II_SD_T* pAIISD = (APPLE_II_SD_T*)SLOT_IO_START;
|
||||||
uint8* pSlotRom = SLOT_ROM_START;
|
volatile uint8* pSlotRom = SLOT_ROM_START;
|
||||||
uint8* pExtRom = EXT_ROM_START;
|
|
||||||
|
|
||||||
videomode(VIDEOMODE_40COL);
|
videomode(VIDEOMODE_40COL);
|
||||||
clrscr();
|
clrscr();
|
||||||
|
@ -76,7 +76,7 @@ int main()
|
||||||
if(erase)
|
if(erase)
|
||||||
{
|
{
|
||||||
// buffer is already filled with 0
|
// buffer is already filled with 0
|
||||||
fileSize = 2048;
|
fileSize = BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,7 @@ int main()
|
||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
pFile = NULL;
|
pFile = NULL;
|
||||||
|
|
||||||
if(fileSize != 2048)
|
if(fileSize != BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
cprintf("\r\nWrong file size: %d\r\n", fileSize);
|
cprintf("\r\nWrong file size: %d\r\n", fileSize);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileSize == 2048)
|
if(fileSize == BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
// enable write
|
// enable write
|
||||||
pAIISD->status.pgmen = 1;
|
pAIISD->status.pgmen = 1;
|
||||||
|
@ -115,7 +115,7 @@ int main()
|
||||||
{
|
{
|
||||||
// write to EXTROM
|
// write to EXTROM
|
||||||
cprintf("\r\nFlashing EXTROM: ");
|
cprintf("\r\nFlashing EXTROM: ");
|
||||||
if(writeChip(buffer + 256, pExtRom, fileSize - 256))
|
if(writeChip(buffer + 256, EXT_ROM_START, fileSize - 256))
|
||||||
{
|
{
|
||||||
cprintf("\r\n\r\nFlashing finished!\n");
|
cprintf("\r\n\r\nFlashing finished!\n");
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
@ -130,12 +130,11 @@ int main()
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length)
|
boolean writeChip(const uint8* pSource, volatile uint8* pDest, uint16 length)
|
||||||
{
|
{
|
||||||
uint32 i;
|
uint32 i;
|
||||||
uint8 data = 0;
|
volatile uint8 data = 0;
|
||||||
uint8 readData;
|
volatile uint8 readData;
|
||||||
volatile uint8* pDestination = pDest;
|
|
||||||
|
|
||||||
for(i=0; i<length; i++)
|
for(i=0; i<length; i++)
|
||||||
{
|
{
|
||||||
|
@ -145,25 +144,25 @@ boolean writeChip(const uint8* pSource, uint8* pDest, uint16 length)
|
||||||
data = pSource[i];
|
data = pSource[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
*pDestination = data;
|
*pDest = data;
|
||||||
printStatus((i * 100u / length) + 1);
|
printStatus((i * 100u / length) + 1);
|
||||||
|
|
||||||
// wait for write cycle
|
// wait for write cycle
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
readData = *pDestination;
|
readData = *pDest;
|
||||||
}
|
}
|
||||||
while((readData & 0x80) != (data & 0x80));
|
while((readData & 0x80) != (data & 0x80));
|
||||||
|
|
||||||
if(readData != data)
|
if(readData != data)
|
||||||
{
|
{
|
||||||
// verification not successful
|
// verification not successful
|
||||||
cprintf("\r\n\r\n!!! Flashing failed at %p !!!\r\n", pDestination);
|
cprintf("\r\n\r\n!!! Flashing failed at %p !!!\r\n", pDest);
|
||||||
cprintf("Was 0x%02hhX, should be 0x%02hhX\r\n", readData, data);
|
cprintf("Was 0x%02hhX, should be 0x%02hhX\r\n", readData, data);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pDestination++;
|
pDest++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
Loading…
Reference in New Issue