Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions 3rdparty/odfs-rom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj/**
out/**
31 changes: 31 additions & 0 deletions 3rdparty/odfs-rom/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
INCLUDE=/opt/amiga/m68k-amigaos/ndk-include
AS=vasmm68k_mot
ASFLAGS=-Fhunk -I$(INCLUDE) -quiet
LINKER=vlink
LINKFLAGS=-bamigahunk -s -sc -sd
OBJDIR=obj
ODFS_VERSION=0.4
ODFS_URL="https://github.com/reinauer/ODFileSystem/releases/download/v$(ODFS_VERSION)/ODFileSystem-rom"
SHELL=/bin/bash

.PHONY: all clean

SRCS = resident.S
OBJS = $(SRCS:%.S=$(OBJDIR)/%.o)

all: out/odfs.rom

$(OBJDIR)/%.o: %.S
@mkdir -p $(OBJDIR)
$(AS) $(ASFLAGS) -o $@ $<

$(OBJDIR)/ODFileSystem-rom:
curl -fsSL $(ODFS_URL) -o $@

out/odfs.rom: $(OBJDIR)/resident.o $(OBJDIR)/ODFileSystem-rom
@mkdir -p out
@set -o pipefail ; $(LINKER) $(LINKFLAGS) $^ -o $@ 2>&1 | (grep -v "already an executable file." || true)

clean:
@rm -f $(OBJDIR)/*
@rm -rf out/*
11 changes: 11 additions & 0 deletions 3rdparty/odfs-rom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# odfs-rom

This will download the version of ODFS from [github](https://github.com/reinauer/ODFileSystem) and glue a romtag to it to make it loadable by the LIDE bootrom

## Description
This romtag code does the following
* If FileSystem.resource doesn't already exist, create it
* Check if there's already a filesystem with dostype CD01 in FSR
* If not, add it to filesystem.resource

[ODFileSystem](https://github.com/reinauer/ODFileSystem) by Stefan Reinauer is licensed under the BSD 2-Clause license
99 changes: 99 additions & 0 deletions 3rdparty/odfs-rom/resident.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
include "lvo/exec_lib.i"
include "exec/lists.i"
include "exec/types.i"
include "exec/memory.i"
include "exec/resident.i"
include "resources/filesysres.i"

CDFS_DOSTYPE EQU $43443031 ; CD01

;; Entrypoint jump here allows us to give the real seglist address in the FSE
entrypoint: bra.w odfs

romtag: dc.w RTC_MATCHWORD ; rt_MatchWord
dc.l romtag ; rt_MatchTag
dc.l endskip ; rt_EndSkip
dc.b RTF_COLDSTART ; rt_Flags
dc.b 1 ; rt_Version
dc.b NT_UNKNOWN ; rt_Type
dc.b 0 ; rt_Pri
dc.l name ; rt_Name
dc.l name ; rt_IdString
dc.l init ; rt_Init

init: movem.l d2/a2/a6,-(sp)
move.l 4,a6

;; Open FileSystem.resource
lea.l fileSysResName(pc),a1
jsr _LVOOpenResource(a6)
move.l d0,a2
tst.l d0
bne.s .fsr

;; No FileSysRes found so we create it
move.l #FileSysResource_SIZEOF,d0
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
jsr _LVOAllocMem(a6)
tst.l d0
beq.w .done

move.l d0,a1
lea.l fsr_FileSysEntries(a1),a0
NEWLIST a0
lea.l name(pc),a0
move.l a0,fsr_Creator(a1)
move.l a0,LN_NAME(a1)
move.b #NT_RESOURCE,LN_TYPE(a1)
move.l a1,a2
jsr _LVOAddResource(a6)

.fsr: ; Check if there's a CDFS there already
moveq.l #0,d2 ; Clear found flag
jsr _LVOForbid(a6)
lea.l fsr_FileSysEntries(a2),a0
.nxtfe: move.l LN_SUCC(a0),a0
tst.l (a0)
beq.s .fsend
cmp.l #CDFS_DOSTYPE,fse_DosType(a0)
bne.s .nxtfe
moveq #1,d2 ; found

.fsend: jsr _LVOPermit(a6)
tst.l d2
bne.s .done

move.l #(fse_GlobalVec+4),d0 ; fileSysEntry_SIZEOF
move.l #MEMF_PUBLIC|MEMF_CLEAR,d1
jsr _LVOAllocMem(a6)
tst.l d0
beq.s .done
move.l d0,a1
lea.l name(pc),a0
move.l a0,LN_NAME(a1)
move.l #CDFS_DOSTYPE,fse_DosType(a1)
move.l #1<<16,fse_Version(a1)
move.l #$190,fse_PatchFlags(a1) ; SegList+StackSize+GlobalVec
move.l #8192,fse_StackSize(a1)
move.l #10,fse_Priority(a1)
move.l #-1,fse_GlobalVec(a1)
lea.l entrypoint(pc),a0
sub.l #4,a0 ; Seglist at -4
move.l a0,d0
lsr.l #2,d0 ; to BPTR
move.l d0,fse_SegList(a1)
lea.l fsr_FileSysEntries(a2),a0
jsr _LVOForbid(a6)
jsr _LVOAddHead(a6)
jsr _LVOPermit(a6)

.done: moveq #0,d0
movem.l (sp)+,d2/a2/a6
rts

fileSysResName: FSRNAME
name: dc.b "cdfs",0

CNOP 0,4
endskip:
odfs: ; After linking, ODFS will be here
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ else
DISK=lide-update.adf
endif

.PHONY: clean all lideflash disk lha rename/renamelide lidetool/lidetool
.PHONY: clean all lideflash disk lha lidetool/lidetool

all: $(PROJECT) \
AIDE-$(PROJECT) \
Expand All @@ -46,11 +46,12 @@ all: $(PROJECT) \
lide-N2630-low.rom \
rename/renamelide \
lideflash \
odfs.rom \
$(ROM)

OBJDIR = obj/$(TARGET)

SRCS = device.c ata.c atapi.c scsi.c iotask.c lide_alib.c mounter/mounter.c debug.c
SRCS = device.c ata.c atapi.c scsi.c iotask.c lide_alib.c 3rdparty/mounter/mounter.c debug.c

OBJ = $(addprefix $(OBJDIR)/,$(notdir $(SRCS:%c=%o)))

Expand Down Expand Up @@ -93,7 +94,7 @@ $(OBJDIR)/%.o: %.c
@printf "${GREEN}$@${NC}\n"
@${CC} -o $@ -c $< ${CFLAGS}

$(OBJDIR)/%.o: mounter/%.c
$(OBJDIR)/%.o: 3rdparty/mounter/%.c
@mkdir -p $(OBJDIR)
@printf "${GREEN}$@${NC}\n"
@${CC} -o $@ -c $< ${CFLAGS}
Expand Down Expand Up @@ -124,6 +125,14 @@ rename/renamelide:
@${MAKE} -C rename
@printf "Done.\n"

3rdparty/odfs-rom/out/odfs.rom:
@printf "${WHITE}#### Building $@ ####${NC}\n"
@${MAKE} -C 3rdparty/odfs-rom
@printf "Done.\n"

odfs.rom: 3rdparty/odfs-rom/out/odfs.rom
@cp $^ $@

$(BUILDDIR)/AIDE-boot-$(VERSION).adf: AIDE-$(PROJECT)
@printf "${WHITE}#### Building $@ ####${NC}\n"
@${MAKE} -C aide-boot
Expand All @@ -132,10 +141,11 @@ $(BUILDDIR)/AIDE-boot-$(VERSION).adf: AIDE-$(PROJECT)

disk: $(BUILDDIR)/$(DISK) $(BUILDDIR)/AIDE-boot-$(VERSION).adf

$(BUILDDIR)/$(DISK): $(ROM) AIDE-lide.device lideflash/lideflash rename/renamelide lidetool/lidetool
$(BUILDDIR)/$(DISK): $(ROM) AIDE-lide.device lideflash/lideflash rename/renamelide lidetool/lidetool odfs.rom
@printf "${WHITE}#### Building $@ ####${NC}\n"
@mkdir -p $(BUILDDIR)
@cp $(ROM) build
@cp odfs.rom build
@echo 'lideflash -I $(ROM)' > $(BUILDDIR)/startup-sequence
@xdftool $(BUILDDIR)/$(DISK) format lide-update + \
boot install + \
Expand All @@ -149,10 +159,11 @@ $(BUILDDIR)/$(DISK): $(ROM) AIDE-lide.device lideflash/lideflash rename/renameli
write info/Expansion.info Expansion.info + \
write info/lide.device.info Expansion/lide.device.info + \
write lide.device Expansion/lide.device + \
write AIDE-lide.device AIDE-lide.device
write AIDE-lide.device AIDE-lide.device + \
write odfs.rom odfs.rom
@printf "Done.\n"

$(BUILDDIR)/lide-update.lha: lideflash/lideflash $(ROM) rename/renamelide lidetool/lidetool lide.device info/lide.device.info AIDE-lide.device
$(BUILDDIR)/lide-update.lha: lideflash/lideflash $(ROM) lide-atbus.rom lide-N2630-high.rom lide-N2630-low.rom rename/renamelide lidetool/lidetool lide.device info/lide.device.info AIDE-lide.device odfs.rom
@mkdir -p $(BUILDDIR)
cp $^ $(BUILDDIR)
cd $(BUILDDIR) && lha -c ../$@ $(notdir $^)
Expand Down Expand Up @@ -184,5 +195,6 @@ clean:
@${MAKE} -C lideflash clean
@${MAKE} -C lidetool clean
@${MAKE} -C rename clean
@${MAKE} -C 3rdparty/odfs-rom clean
@-rm -rf $(BUILDDIR)
@${MAKE} -C aide-boot clean
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,27 @@ Releases contain the following builds
lide.device supports booting from CD-ROM but requires a CD Filesystem to be loaded for this to work.

There are a few options:
1. `CDFileSystem` from AmigaOS 3.2.2 loaded with LoadModule
2. `BootCDFileSystem` from OS 4 either:
1. [`ODFileSystem`](https://github.com/reinauer/ODFileSystem) (recommended) added to the IDE/Accelerator ROM (subject to board support)
2. `CDFileSystem` from AmigaOS 3.2.2 loaded with LoadModule
3. `BootCDFileSystem` from OS 4 either:
* Added to a custom Kickstart ROM **OR**
* Added to the IDE/Accelerator ROM (subject to board support)

### Loading BootCDFileSystem from Board ROM
The following boards support loading BootCDFileSystem from ROM:
### Loading ODFileSystem from Board ROM
The following boards are known to support loading ODFileSystem from ROM:
* RIPPLE
* RIDE
* 68EC020-TK
* 68030-TK2

`BootCDFileSystem` must be flashed to the second bank of the ROM.
This can be achieved on RIPPLE and 68EC020-TK boards using `lideflash` i.e
`lideflash -C BootCDFileSystem`
`ODFileSystem` must be flashed to the second bank of the ROM.
The ROM image to flash is the `odfs.rom` file, which can be obtained from either:

* The [latest release](https://github.com/LIV2/lide.device/releases/latest), or
* The `odfs.rom` file included on the `lide-update` ADF

For RIPPLE and 68EC020-TK boards you can install it using `lideflash` i.e
`lideflash -C odfs.rom`

## Large drive (>4GB) support
For drives larger than 4GB it is required to use a Filesystem that supports TD64, NSD or SCSI-Direct
Expand Down Expand Up @@ -146,6 +152,7 @@ Thanks to [MHeinrichs](https://gitlab.com/MHeinrichs) for contributing improveme
reloc.S is adapted from the [A4091](https://github.com/A4091/a4091-software) open-source driver and is Copyright Stefan Reinauer
mounter.c adapted from the [A4091](https://github.com/A4091/a4091-software) open-source driver and is Copyright 2021-2022 Toni Wilen
The fast read/write routines for ATA devices are adapted from [Frédéric REQUIN](https://github.com/fredrequin)'s [at_apollo_device](https://github.com/fredrequin/at_apollo_device)
[ODFileSystem](https://github.com/reinauer/ODFileSystem) by Stefan Reinauer is licensed under the BSD 2-Clause license

## License
All software contained that is not provided by a third-party is covered by a GPL 2.0 Only license
Expand Down
17 changes: 12 additions & 5 deletions ata.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,13 @@ bool ata_identify(struct IDEUnit *unit, UWORD *buffer)
*
* Sets the transfer routine for the unit
*
* @param unit Pointer to an IDEUnit strict
* @param unit Pointer to an IDEUnit struct
* @param method Transfer routine
*/
void ata_set_xfer(struct IDEUnit *unit, enum xfer method) {
switch (method) {
default:
#if NEXT_REG >= 512
case longword_movem:
unit->read_fast = ata_read_long_movem;
unit->read_unaligned = ata_read_unaligned_long;
Expand All @@ -246,6 +247,7 @@ void ata_set_xfer(struct IDEUnit *unit, enum xfer method) {

unit->xferMethod = longword_movem;
break;
#endif
case longword_move:
unit->read_fast = ata_read_long_move;
unit->read_unaligned = ata_read_unaligned_long;
Expand Down Expand Up @@ -419,7 +421,7 @@ bool ata_init_unit(struct IDEUnit *unit, void *base) {
* @param multiple DRQ Block size
* @return non-zero on error
*/
bool ata_set_multiple(struct IDEUnit *unit, BYTE multiple) {
BYTE ata_set_multiple(struct IDEUnit *unit, BYTE multiple) {
UBYTE drvSel = (unit->flags.primary) ? 0xE0 : 0xF0; // Select drive

ata_select(unit,drvSel,true);
Expand Down Expand Up @@ -764,8 +766,8 @@ BYTE ata_set_pio(struct IDEUnit *unit, UBYTE pio) {
if ((error = write_taskfile_lba(unit,ATA_CMD_SET_FEATURES,0,pio,0x03)) != 0)
return error;

if ((error = ata_wait_ready(unit,ATA_RDY_WAIT_COUNT)))
return error;
if (!ata_wait_ready(unit,ATA_RDY_WAIT_COUNT))
return IOERR_UNITBUSY;

if (ata_check_error(unit)) return IOERR_BADLENGTH;

Expand All @@ -777,11 +779,14 @@ BYTE ata_set_pio(struct IDEUnit *unit, UBYTE pio) {
*
* Handle SCSI ATA PASSTHROUGH (12) command to send ATA commands to the drive
*
* Requires that the cmd->scsi_Data buffer is word aligned
*
* @param unit Pointer to an IDEUnit struct
* @param cmd Pointer to a SCSICmd struct
* @return non-zero on error
*/
BYTE scsi_ata_passthrough(struct IDEUnit *unit, struct SCSICmd *cmd) {

struct SCSI_CDB_ATA *cdb = (struct SCSI_CDB_ATA *)cmd->scsi_Command;

bool byt_blok = (cdb->length & ATA_BYT_BLOK) ? true : false;
Expand Down Expand Up @@ -824,12 +829,14 @@ BYTE scsi_ata_passthrough(struct IDEUnit *unit, struct SCSICmd *cmd) {

case ATA_PIO_IN: // Data to Host
if (count < 2) return IOERR_BADLENGTH;
if ((ULONG)cmd->scsi_Data & 1) return IOERR_BADADDRESS;
src = (UWORD *)unit->drive.data;
dest = cmd->scsi_Data;
break;

case ATA_PIO_OUT: // Data to Drive
if (count < 2) return IOERR_BADLENGTH;
if ((ULONG)cmd->scsi_Data & 1) return IOERR_BADADDRESS;
src = cmd->scsi_Data;
dest = (UWORD *)unit->drive.data;
break;
Expand Down Expand Up @@ -857,7 +864,7 @@ BYTE scsi_ata_passthrough(struct IDEUnit *unit, struct SCSICmd *cmd) {

if (protocol == ATA_PIO_IN || protocol == ATA_PIO_OUT) {
for (int i = 0; i < count/2; i++) {
if (i % 512 == 0) {
if (i % 256 == 0) {
if (!ata_wait_drq(unit,ATA_DRQ_WAIT_COUNT,true)) {
ata_save_error(unit);
return IOERR_UNITBUSY;
Expand Down
2 changes: 1 addition & 1 deletion ata.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ enum xfer_dir {
bool ata_init_unit(struct IDEUnit *unit, void *base);
bool ata_select(struct IDEUnit *unit, UBYTE select, bool wait);
bool ata_identify(struct IDEUnit *, UWORD *);
bool ata_set_multiple(struct IDEUnit *unit, BYTE multiple);
BYTE ata_set_multiple(struct IDEUnit *unit, BYTE multiple);
void ata_set_xfer(struct IDEUnit *unit, enum xfer method);

BYTE ata_read(void *buffer, uint64_t lba, ULONG count, struct IDEUnit *unit);
Expand Down
Loading