mirror of
https://github.com/LIV2/lide.device.git
synced 2025-12-06 00:32:45 +00:00
Compare commits
4 Commits
4935a81034
...
8b144018e5
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b144018e5 | |||
| a2b9192bea | |||
| 34a8d23773 | |||
| 17bf6b0e60 |
@ -1,5 +1,5 @@
|
||||
; reloc.S
|
||||
; Modified from Open Source A4091.device by Stefan Reinauer and Chris Hooper - https://github.com/A4091/a4091-software
|
||||
; Modified from Open Source A4091.device by Stefan Reinauer and Chris Hooper - https://github.com/A4091/a3091-software
|
||||
INCLUDE "exec/memory.i"
|
||||
INCLUDE "lvo/exec_lib.i"
|
||||
|
||||
@ -9,6 +9,12 @@
|
||||
|
||||
NUM_ENTRIES EQU 5
|
||||
|
||||
; Frame pointer offsets
|
||||
PHUNKS EQU -4
|
||||
READHANDLE_TYPE EQU -8
|
||||
READHANDLE_CURRENT EQU -12
|
||||
FP_SIZE EQU READHANDLE_CURRENT
|
||||
|
||||
; API:
|
||||
; Zorro ROM access:
|
||||
; a0: rombase
|
||||
@ -19,6 +25,7 @@ NUM_ENTRIES EQU 5
|
||||
public _relocate
|
||||
_relocate
|
||||
movem.l d1-d7/a0-a6,-(sp)
|
||||
link a4,#FP_SIZE
|
||||
|
||||
bsr InitHandle
|
||||
|
||||
@ -39,7 +46,7 @@ _relocate
|
||||
; Go through hunk header and allocate all segments
|
||||
move.l 4,a6 ; execbase
|
||||
|
||||
move.l pHunks(pc),a2 ; segment pointers
|
||||
move.l PHUNKS(a4),a2 ; segment pointers
|
||||
lea.l 4*NUM_ENTRIES(a2),a3 ; segment lengths
|
||||
.AllocateLoop
|
||||
moveq.l #MEMF_PUBLIC,d1
|
||||
@ -54,7 +61,7 @@ _relocate
|
||||
move.l d0,(a2)+ ; segment pointer
|
||||
dbra d7,.AllocateLoop
|
||||
|
||||
move.l pHunks(pc),a5
|
||||
move.l PHUNKS(a4),a5
|
||||
.HunkLoop
|
||||
move.l (a5),a0 ; current hunk
|
||||
bsr RomFetch32
|
||||
@ -85,6 +92,7 @@ _relocate
|
||||
ENDIF
|
||||
bsr .RelocateCleanup
|
||||
moveq.l #0,d0 ; NULL = Failure
|
||||
unlk a4
|
||||
movem.l (sp)+,d1-d7/a0-a6
|
||||
rts
|
||||
|
||||
@ -129,16 +137,16 @@ _relocate
|
||||
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
|
||||
|
||||
lsl.l #2,d2 ; *4 ; offset from Hunks
|
||||
move.l pHunks(pc),a2
|
||||
move.l PHUNKS(a4),a2
|
||||
add.l d2,a2 ; hunk number num
|
||||
move.l (a2),d3 ; base address of hunk
|
||||
|
||||
.Reloc32Tight
|
||||
bsr RomFetch32
|
||||
; get baseaddr + d0, add d3 to the data there.
|
||||
move.l a0,a4
|
||||
add.l d0,a4
|
||||
add.l d3,(a4)
|
||||
move.l a0,a3
|
||||
add.l d0,a3
|
||||
add.l d3,(a3)
|
||||
dbra d1,.Reloc32Tight
|
||||
|
||||
bra .HunkReloc32
|
||||
@ -158,21 +166,21 @@ _relocate
|
||||
move.l d0,d2 ; num ; number of the hunk the offsets are to point into
|
||||
|
||||
lsl.l #2,d2 ; *4 ; offset from Hunks
|
||||
move.l pHunks(pc),a2
|
||||
move.l PHUNKS(a4),a2
|
||||
add.l d2,a2 ; hunk number num
|
||||
move.l (a2),d3 ; base address of hunk
|
||||
|
||||
.Reloc32ShortTight
|
||||
bsr RomFetch16
|
||||
; get baseaddr + d0, add d3 to the data there.
|
||||
move.l a0,a4
|
||||
add.l d0,a4
|
||||
add.l d3,(a4)
|
||||
move.l a0,a3
|
||||
add.l d0,a3
|
||||
add.l d3,(a3)
|
||||
dbra d1,.Reloc32ShortTight
|
||||
|
||||
bra .HunkReloc32Short
|
||||
.HunkLoopPrep
|
||||
lea ReadHandle(pc),a2
|
||||
lea READHANDLE_CURRENT(a4),a2
|
||||
move.l (a2),d0 ; align pointer to longword
|
||||
addq.l #2,d0 ; in case we had an odd number
|
||||
and.l #$fffffffc,d0 ; of relocations
|
||||
@ -202,17 +210,18 @@ _relocate
|
||||
|
||||
bsr.s CreateSegList
|
||||
|
||||
move.l pHunks(pc),a0
|
||||
move.l PHUNKS(a4),a0
|
||||
move.l (a0),d2
|
||||
subq.l #4,d2
|
||||
|
||||
bsr.s .RelocateCleanup
|
||||
move.l d2,d0
|
||||
unlk a4
|
||||
movem.l (sp)+,d1-d7/a0-a6
|
||||
rts
|
||||
|
||||
.RelocateCleanup
|
||||
move.l pHunks(pc),a1
|
||||
move.l PHUNKS(a4),a1
|
||||
moveq.l #(8*NUM_ENTRIES),d0
|
||||
jsr _LVOFreeMem(a6)
|
||||
rts
|
||||
@ -233,7 +242,7 @@ _relocate
|
||||
; +->| | | | 0| | | | | 0|
|
||||
; +--+--+--+--+ +--+--+--+--+
|
||||
CreateSegList:
|
||||
move.l pHunks(pc),a0
|
||||
move.l PHUNKS(a4),a0
|
||||
|
||||
.NextSeg
|
||||
move.l (a0),a1 ; Hunks[x]
|
||||
@ -269,10 +278,10 @@ RomFetch32
|
||||
|
||||
RomFetch
|
||||
movem.l a0-a1/d1-d3,-(sp)
|
||||
lea ReadHandle(pc),a1
|
||||
lea READHANDLE_CURRENT(a4),a1
|
||||
move.l (a1),a0
|
||||
|
||||
tst.l 4(a1) ; access type Zorro?
|
||||
tst.l READHANDLE_TYPE(a4) ; access type Zorro?
|
||||
bne.s .RomFetchZ
|
||||
|
||||
cmp.b #3,d0
|
||||
@ -310,7 +319,7 @@ RomFetch
|
||||
rts
|
||||
|
||||
InitHandle
|
||||
; initialize readhandle to beginning of device driver
|
||||
; initialize READHANDLE_CURRENT to beginning of device driver
|
||||
; ROM_OFFSET needs to be multiplied by 4 because of the
|
||||
; nibble mapped nature of the AutoConfig ROM.
|
||||
; ROM_ADDRESS is passed in a0
|
||||
@ -320,24 +329,15 @@ InitHandle
|
||||
ENDIF
|
||||
|
||||
add.l d0,a0
|
||||
lea ReadHandle(pc),a1
|
||||
move.l a0,(a1) ; memory location passed in a0
|
||||
move.l d0,4(a1) ; Set access type: 0 = memory, Zorro otherwise
|
||||
move.l a0,READHANDLE_CURRENT(a4) ; memory location passed in a0
|
||||
move.l d0,READHANDLE_TYPE(a4) ; Set access type: 0 = memory, Zorro otherwise
|
||||
|
||||
moveq.l #(8*NUM_ENTRIES),d0
|
||||
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
|
||||
jsr _LVOAllocMem(a6)
|
||||
lea pHunks(pc),a1
|
||||
move.l d0,(a1)
|
||||
move.l d0,PHUNKS(a4)
|
||||
rts
|
||||
|
||||
ReadHandle
|
||||
dc.l 0 ; Current address
|
||||
dc.l 0 ; 0=memory, otherwise Zorro
|
||||
|
||||
pHunks
|
||||
dc.l 0
|
||||
|
||||
IFD HAVE_ERRNO
|
||||
public _rErrno
|
||||
_rErrno
|
||||
|
||||
119
lideflash/main.c
119
lideflash/main.c
@ -304,15 +304,20 @@ static void setup_liv2_board(struct ideBoard *board) {
|
||||
/**
|
||||
* promptUser
|
||||
*
|
||||
* Ask if the user wants to update this board
|
||||
* Ask if the user wants to update/erase this board
|
||||
* @param config pointer to the config struct
|
||||
* @return boolean true / false
|
||||
*/
|
||||
static bool promptUser(struct Config *config) {
|
||||
static bool promptUser(struct Config *config, bool update) {
|
||||
int c;
|
||||
char answer = 'y'; // Default to yes
|
||||
|
||||
printf("Update this device? (Y)es/(n)o/(a)ll: ");
|
||||
if (update) {
|
||||
printf("Update this device?");
|
||||
} else {
|
||||
printf("Erase flash?");
|
||||
}
|
||||
printf(" (Y)es/(n)o/(a)ll: ");
|
||||
|
||||
if (config->assumeYes) {
|
||||
printf("y\n");
|
||||
@ -334,7 +339,7 @@ static bool promptUser(struct Config *config) {
|
||||
/**
|
||||
* assemble_rom
|
||||
*
|
||||
* Given either lide.rom or lide-atbus.rom - adjust the file for the currebt board
|
||||
* Given either lide.rom or lide-atbus.rom - adjust the file for the current board
|
||||
* This is needed because lideflash will update all compatible boards, and can only be supplied with one filename
|
||||
*/
|
||||
static void assemble_rom(char *src_buffer, char *dst_buffer, ULONG bufSize, enum BOOTROM dstRomType) {
|
||||
@ -367,6 +372,90 @@ static void assemble_rom(char *src_buffer, char *dst_buffer, ULONG bufSize, enum
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* find_lide_version
|
||||
*
|
||||
* Search for the id string in the buffer and return the offset if found
|
||||
* @param buffer the buffer to search
|
||||
* @param romSize Size of the ROM
|
||||
* @returns offset. negative if not found
|
||||
*/
|
||||
static int find_lide_version(const unsigned char *buffer, ULONG romSize) {
|
||||
const char *needle = "lide ";
|
||||
size_t needle_len = strlen(needle);
|
||||
|
||||
// We can only search up to (romSize - needle_len)
|
||||
for (size_t i = 0; i <= romSize - needle_len; i++) {
|
||||
if (memcmp(buffer + i, needle, needle_len) == 0) {
|
||||
return (int)i;
|
||||
}
|
||||
}
|
||||
return -1; // Not found
|
||||
}
|
||||
|
||||
/**
|
||||
* printVersion
|
||||
*
|
||||
* Print the version string without the git information
|
||||
*
|
||||
* @param version Pointer to the version string
|
||||
*/
|
||||
static void printVersion(char *version) {
|
||||
char *temp;
|
||||
int len = strcspn(version,")");
|
||||
len++; // Leave space for null terminator
|
||||
if ((temp = AllocMem(len,MEMF_ANY))) {
|
||||
temp[len] = 0;
|
||||
strncpy(temp,version,len);
|
||||
printf("%s\n",temp);
|
||||
FreeMem(temp,len);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* printCurrentVersion
|
||||
*
|
||||
* Print the current version of lide the board is running
|
||||
* It first tries to get this using the cd_Driver pointer in the struct
|
||||
*
|
||||
* Older driver versions didn't set this, in that case:
|
||||
* 1. Traverse the eb_Mountlist looking for a device bound to this configDev
|
||||
* 2. Peek into it's BootNode->DeviceNode->FSSM to get the device name
|
||||
* 3. Find the device in SysBase->DeviceList
|
||||
*
|
||||
* @param cd ConfigDev pointer
|
||||
*/
|
||||
void printCurrentVersion(struct ConfigDev *cd) {
|
||||
struct BootNode *bn;
|
||||
struct DeviceNode *dn;
|
||||
struct FileSysStartupMsg *fssm;
|
||||
struct Device *device;
|
||||
char *deviceName = NULL;
|
||||
|
||||
if ((device = cd->cd_Driver) == NULL) {
|
||||
// Old version of lide didn't set cd_Driver
|
||||
// Get it the hard way
|
||||
for (bn = (struct BootNode *)ExpansionBase->MountList.lh_Head;
|
||||
bn->bn_Node.ln_Succ;
|
||||
bn = (struct BootNode *)bn->bn_Node.ln_Succ)
|
||||
{
|
||||
if (cd == (struct ConfigDev *)bn->bn_Node.ln_Name) {
|
||||
dn = bn->bn_DeviceNode;
|
||||
fssm = BADDR(dn->dn_Startup);
|
||||
deviceName = (char *)BADDR(fssm->fssm_Device) + 1; // NULL terminated BSTR
|
||||
device = (struct Device *)FindName(&SysBase->DeviceList,deviceName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (device) {
|
||||
printVersion(device->dd_Library.lib_IdString);
|
||||
} else {
|
||||
printf("Unknown\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SysBase = *((struct ExecBase **)4UL);
|
||||
@ -379,6 +468,8 @@ int main(int argc, char *argv[])
|
||||
void *driver_buffer2 = NULL;
|
||||
void *misc_buffer = NULL;
|
||||
|
||||
char *ver = NULL;
|
||||
|
||||
ULONG romSize = 0;
|
||||
ULONG miscSize = 0;
|
||||
|
||||
@ -424,6 +515,11 @@ int main(int argc, char *argv[])
|
||||
rc = 5;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
int ver_offset = find_lide_version(driver_buffer,romSize);
|
||||
if (ver_offset > 0) {
|
||||
ver = (char *)driver_buffer + ver_offset;
|
||||
}
|
||||
}
|
||||
|
||||
if (config->misc_filename) {
|
||||
@ -577,9 +673,22 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf(" at Address 0x%06x\n",(int)cd->cd_BoardAddr);
|
||||
boards_found++;
|
||||
if (config->ide_rom_filename) {
|
||||
printf("Old: ");
|
||||
printCurrentVersion(cd);
|
||||
|
||||
if (ver) {
|
||||
printf("New: ");
|
||||
printVersion(ver);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
bool update = (config->ide_rom_filename != NULL|| config->misc_filename != NULL);
|
||||
|
||||
// Ask the user if they wish to update this board
|
||||
if (!promptUser(config)) continue;
|
||||
if (!promptUser(config, update)) continue;
|
||||
|
||||
suspend_lide(true);
|
||||
|
||||
|
||||
2
mounter
2
mounter
@ -1 +1 @@
|
||||
Subproject commit 8ffa8ef7b3b00c4e9129e576ca304e0523a41707
|
||||
Subproject commit a0d87fe11a2113afa2bc4aec970fd9963f062846
|
||||
Loading…
x
Reference in New Issue
Block a user