Skip to content

Commit

Permalink
Fix #2 - return error code in all fn_io_mount_* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
markjfisher committed Feb 20, 2024
1 parent c1deaf5 commit c4bf630
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 21 deletions.
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

## [2.2.0] - 2024-02-20

- Change signature of fn_io_mount_disk_image, and fn_io_mount_host_slot to return an error code, so all fn_io_mount* functions are consistent (fixes #2).
- [atari] fn_io_mount_disk_image returns error code from BUS
- [atari] fn_io_mount_host_slot returns error code from BUS
- [atari] added test cases for BUS errors for fn_io_mount_disk_image, fn_io_mount_host_slot, fn_io_mount_all

## [2.1.5] - 2024-01-07

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion apple2/src/fn_io/fn_io_mount_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

uint8_t fn_io_mount_all(void)
{

return 0;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_io/fn_io_mount_disk_image.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-io.h"

void fn_io_mount_disk_image(uint8_t ds, uint8_t mode)
uint8_t fn_io_mount_disk_image(uint8_t ds, uint8_t mode)
{

return 0;
}
4 changes: 2 additions & 2 deletions apple2/src/fn_io/fn_io_mount_host_slot.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "fujinet-io.h"

void fn_io_mount_host_slot(uint8_t hs)
uint8_t fn_io_mount_host_slot(uint8_t hs)
{

return 0;
}
8 changes: 6 additions & 2 deletions atari/src/fn_io/fn_io_mount_disk_image.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.include "macros.inc"
.include "device.inc"

; void fn_io_mount_disk_image(uint8_t device_slot, uint8_t mode)
; uint8_t fn_io_mount_disk_image(uint8_t device_slot, uint8_t mode)
.proc _fn_io_mount_disk_image
sta tmp8 ; save mode

Expand All @@ -17,7 +17,11 @@
jsr popa ; slot
sta IO_DCB::daux1
mva #$fe, IO_DCB::dtimlo
jmp _bus
jsr _bus

ldx #$00
lda IO_DCB::dstats
rts
.endproc

.rodata
Expand Down
8 changes: 6 additions & 2 deletions atari/src/fn_io/fn_io_mount_host_slot.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.include "macros.inc"
.include "device.inc"

; void fn_io_mount_host_slot(uint8_t slot_num)
; uint8_t fn_io_mount_host_slot(uint8_t slot_num)
;
.proc _fn_io_mount_host_slot
sta tmp8
Expand All @@ -15,7 +15,11 @@
jsr copy_io_cmd_data

mva tmp8, IO_DCB::daux1
jmp _bus
jsr _bus

ldx #$00
lda IO_DCB::dstats
rts

.endproc

Expand Down
2 changes: 1 addition & 1 deletion commodore/src/fn_io/fn_io_mount_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

uint8_t fn_io_mount_all(void)
{

return 0;
}
4 changes: 2 additions & 2 deletions commodore/src/fn_io/fn_io_mount_disk_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "fujinet-io.h"
#include "fn_data.h"

void fn_io_mount_disk_image(uint8_t ds, uint8_t mode)
uint8_t fn_io_mount_disk_image(uint8_t ds, uint8_t mode)
{

return 0;
}
3 changes: 2 additions & 1 deletion commodore/src/fn_io/fn_io_mount_host_slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "fujinet-io.h"
#include "fn_data.h"

void fn_io_mount_host_slot(uint8_t hs)
uint8_t fn_io_mount_host_slot(uint8_t hs)
{
memset(response, 0, sizeof(response));

Expand All @@ -13,4 +13,5 @@ void fn_io_mount_host_slot(uint8_t hs)

cbm_open(LFN, DEV, SAN, response);
cbm_close(LFN);
return 0; // TODO: is there an error code we can use here?
}
4 changes: 2 additions & 2 deletions fujinet-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ void fn_io_get_ssid(NetConfig *net_config);
bool fn_io_get_wifi_enabled(void);
uint8_t fn_io_get_wifi_status(void);
uint8_t fn_io_mount_all(void);
void fn_io_mount_disk_image(uint8_t ds, uint8_t mode);
void fn_io_mount_host_slot(uint8_t hs);
uint8_t fn_io_mount_disk_image(uint8_t ds, uint8_t mode);
uint8_t fn_io_mount_host_slot(uint8_t hs);
void fn_io_open_directory(uint8_t hs, char *path_filter);
void fn_io_put_device_slots(DeviceSlot *d);
void fn_io_put_host_slots(HostSlot *h);
Expand Down
38 changes: 37 additions & 1 deletion testing/bdd-testing/features/atari/fn_io/fn_io_mount_all.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: IO library test - fn_io_mount_all

This tests FN-IO fn_io_mount_all

Scenario: execute _fn_io_mount_all
Scenario: execute _fn_io_mount_all successfully
Given atari-fn-io application test setup
And I add common atari-io files
And I add atari src file "fn_io/fn_io_mount_all.s"
Expand All @@ -26,5 +26,41 @@ Feature: IO library test - fn_io_mount_all
And I expect to see DBUFLO equal $00
And I expect to see DBUFHI equal $00

# Check return value in A/X
And I expect register A equal $00
And I expect register X equal $00

# check BUS was called
Then I expect to see $80 equal $01

Scenario: execute _fn_io_mount_all with error
Given atari-fn-io application test setup
And I add common atari-io files
And I add atari src file "fn_io/fn_io_mount_all.s"
And I add file for compiling "features/atari/fn_io/test-apps/test_no_args.s"
And I add file for compiling "features/atari/fn_io/stubs/bus-simple-err.s"
And I create and load atari application
And I write memory at $80 with $ff
And I write memory at t_bus_err with $69
And I write word at t_fn with address _fn_io_mount_all
When I execute the procedure at _init for no more than 80 instructions

# check the DCB values were set correctly (with error in DSTATS)
Then I expect to see DDEVIC equal $70
And I expect to see DUNIT equal $01
And I expect to see DTIMLO equal $0f
And I expect to see DCOMND equal $d7
And I expect to see DSTATS equal $69
And I expect to see DBYTLO equal $00
And I expect to see DBYTHI equal $00
And I expect to see DAUX1 equal $00
And I expect to see DAUX2 equal $00
And I expect to see DBUFLO equal $00
And I expect to see DBUFHI equal $00

# Check return value in A/X
And I expect register A equal $69
And I expect register X equal $00

# check BUS was called
Then I expect to see $80 equal $01
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: IO library test - fn_io_mount_disk_image

This tests FN-IO fn_io_mount_disk_image

Scenario: execute _fn_io_mount_disk_image
Scenario: execute _fn_io_mount_disk_image successfully
Given atari-fn-io application test setup
And I add common atari-io files
And I add atari src file "fn_io/fn_io_mount_disk_image.s"
Expand All @@ -28,6 +28,45 @@ Feature: IO library test - fn_io_mount_disk_image
And I expect to see DAUX2 equal $01
And I expect to see DBUFLO equal $00
And I expect to see DBUFHI equal $00

# Check return value in A/X
And I expect register A equal $00
And I expect register X equal $00

# check BUS was called
Then I expect to see $80 equal $01

Scenario: execute _fn_io_mount_disk_image with error
Given atari-fn-io application test setup
And I add common atari-io files
And I add atari src file "fn_io/fn_io_mount_disk_image.s"
And I add file for compiling "features/atari/fn_io/test-apps/test_bb.s"
And I add file for compiling "features/atari/fn_io/stubs/bus-simple-err.s"
And I create and load atari application
And I write memory at $80 with $ff
# slot, mode
And I write memory at t_b1 with $05
And I write memory at t_b2 with $01
And I write memory at t_bus_err with $69
And I write word at t_fn with address _fn_io_mount_disk_image
When I execute the procedure at _init for no more than 95 instructions

# check the DCB values were set correctly
Then I expect to see DDEVIC equal $70
And I expect to see DUNIT equal $01
And I expect to see DTIMLO equal $fe
And I expect to see DCOMND equal $f8
And I expect to see DSTATS equal $69
And I expect to see DBYTLO equal $00
And I expect to see DBYTHI equal $00
And I expect to see DAUX1 equal $05
And I expect to see DAUX2 equal $01
And I expect to see DBUFLO equal $00
And I expect to see DBUFHI equal $00

# Check return value in A/X
And I expect register A equal $69
And I expect register X equal $00

# check BUS was called
Then I expect to see $80 equal $01
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: IO library test - fn_io_mount_host_slot

This tests FN-IO fn_io_mount_host_slot

Scenario Outline: execute _fn_io_mount_host_slot
Scenario Outline: execute _fn_io_mount_host_slot successfully
Given atari-fn-io application test setup
And I add common atari-io files
And I add atari src file "fn_io/fn_io_mount_host_slot.s"
Expand All @@ -12,7 +12,7 @@ Feature: IO library test - fn_io_mount_host_slot
And I write memory at $80 with $00
And I write memory at t_b1 with <slot>
And I write word at t_fn with address _fn_io_mount_host_slot
When I execute the procedure at _init for no more than 70 instructions
When I execute the procedure at _init for no more than 80 instructions

# check the DCB values were set correctly
Then I expect to see DDEVIC equal $70
Expand All @@ -28,11 +28,48 @@ Feature: IO library test - fn_io_mount_host_slot
And I expect to see DBUFLO equal $00
And I expect to see DBUFHI equal $00

# verify BUS was called
# Check return value in A/X
And I expect register A equal $00
And I expect register X equal $00

# verify BUS was called
And I expect to see $80 equal 1

Examples:
| slot |
| 0 |
| 1 |
| 2 |

Scenario: execute _fn_io_mount_host_slot with error
Given atari-fn-io application test setup
And I add common atari-io files
And I add atari src file "fn_io/fn_io_mount_host_slot.s"
And I add file for compiling "features/atari/fn_io/test-apps/test_b.s"
And I add file for compiling "features/atari/fn_io/stubs/bus-simple-err.s"
And I create and load atari application
And I write memory at $80 with $00
And I write memory at t_bus_err with $69
And I write memory at t_b1 with $01
And I write word at t_fn with address _fn_io_mount_host_slot
When I execute the procedure at _init for no more than 80 instructions

# check the DCB values were set correctly
Then I expect to see DDEVIC equal $70
And I expect to see DUNIT equal $01
And I expect to see DTIMLO equal $0f
And I expect to see DCOMND equal $f9
And I expect to see DSTATS equal $69
And I expect to see DBYTLO equal $00
And I expect to see DBYTHI equal $00
And I expect to see DAUX1 equal $01
And I expect to see DAUX2 equal $00
And I expect to see DBUFLO equal $00
And I expect to see DBUFHI equal $00

# Check return value in A/X
And I expect register A equal $69
And I expect register X equal $00

# verify BUS was called
And I expect to see $80 equal 1
20 changes: 20 additions & 0 deletions testing/bdd-testing/features/atari/fn_io/stubs/bus-simple-err.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
; stub BUS
.export t_bus_err

.include "macros.inc"
.include "device.inc"

.segment "BUS"
.org BUS

; marks the bus as having run, but returns the error code indicated in t_bus_err
; to allow test to return an error code from the BUS call

stubbed_bus:
mva #$01, $80
ldx #$00
lda t_bus_err
sta IO_DCB::dstats
rts

t_bus_err: .res 1
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.5
2.2.0

0 comments on commit c4bf630

Please sign in to comment.