Update of /cvsroot/arcem/arcem/support_modules/hostfs
In directory vz-cvs-4.sog:/tmp/cvs-serv17456/arcem/support_modules/hostfs

Modified Files:
        Makefile hostfs,ffa hostfs.s hostfsfiler,ffa hostfsfiler.s 
Log Message:
Merge arcem-fast to trunk



Index: hostfs,ffa
===================================================================
RCS file: /cvsroot/arcem/arcem/support_modules/hostfs/hostfs,ffa,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
Binary files /tmp/cvsngtmZ8 and /tmp/cvsIp271C differ

Index: hostfsfiler.s
===================================================================
RCS file: /cvsroot/arcem/arcem/support_modules/hostfs/hostfsfiler.s,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- hostfsfiler.s       24 Mar 2006 17:02:30 -0000      1.2
+++ hostfsfiler.s       12 May 2012 17:34:51 -0000      1.3
@@ -1,94 +1,106 @@
-       @
-       @ $Id$
-       @
-       @ HostFS Filer
-       @
+        @
+        @ $Id$
+        @
+        @ HostFS Filer
+        @
 
-       @ ARM constants
-       VBIT = 1 << 28
+        @ Register naming
+        wp .req r12
 
-       @ RISC OS constants
-       XOS_CLI               = 0x20005
-       XOS_Exit              = 0x20011
-       XOS_Module            = 0x2001e
-       XOS_ReadModeVariable  = 0x20035
-       XOS_ReadMonotonicTime = 0x20042
-       XWimp_Initialise = 0x600c0
-       XWimp_CreateIcon = 0x600c2
-       XWimp_CloseDown  = 0x600dd
-       XWimp_PollIdle   = 0x600e1
-       XWimp_SpriteOp   = 0x600e9
+        @ ARM constants
+        VBIT = 1 << 28
+        CBIT = 1 << 29
+        ZBIT = 1 << 30
+        NBIT = 1 << 31
 
-       Module_Enter = 2
-       Module_Claim = 6
-       Module_Free  = 7
+        @ RISC OS constants
+        XOS_CLI               = 0x20005
+        XOS_Exit              = 0x20011
+        XOS_Module            = 0x2001e
+        XOS_ReadModeVariable  = 0x20035
+        XOS_ReadMonotonicTime = 0x20042
+        XWimp_Initialise = 0x600c0
+        XWimp_CreateIcon = 0x600c2
+        XWimp_CloseDown  = 0x600dd
+        XWimp_PollIdle   = 0x600e1
+        XWimp_SpriteOp   = 0x600e9
 
-       Message_Quit = 0
+        Module_Enter = 2
+        Module_Claim = 6
+        Module_Free  = 7
 
-       Service_Reset             = 0x27
-       Service_StartFiler        = 0x4b
-       Service_StartedFiler      = 0x4c
-       Service_FilerDying        = 0x4f
+        Message_Quit = 0
 
-       SpriteOp_ReadSpriteInfo = 40
+        Service_Reset             = 0x27
+        Service_StartFiler        = 0x4b
+        Service_StartedFiler      = 0x4c
+        Service_FilerDying        = 0x4f
 
-       ModeVariable_YEig = 5
+        SpriteOp_ReadSpriteInfo = 40
 
-       WIMP_VERSION = 300
+        ModeVariable_YEig = 5
 
-       WIMP_POLL_MASK = 0x00000031     @ no Null, Pointer Entering or Pointer 
Leaving events
+        WIMP_VERSION = 300
 
-       WORKSPACE_SIZE = 512
+        WIMP_POLL_MASK = 0x00000031     @ no Null, Pointer Entering or Pointer 
Leaving events
 
-       WS_MY_TASK_HANDLE      = 0
-       WS_FILER_TASK_HANDLE   = 4
-       WS_WIMP_VERSION        = 8
-       WS_ICON_BAR_BLOCK      = 12
-       WS_WIMP_BLOCK          = 48 @ must be last
+        WORKSPACE_SIZE = 512
+
+        WS_MY_TASK_HANDLE      = 0
+        WS_FILER_TASK_HANDLE   = 4
+        WS_WIMP_VERSION        = 8
+        WS_ICON_BAR_BLOCK      = 12
+        WS_WIMP_BLOCK          = 48 @ must be last
 
 
 
-       .global _start
+        .global _start
 
 _start:
 
-       .int    start           @ Start
-       .int    init            @ Initialisation
-       .int    final           @ Finalisation
-       .int    service         @ Service Call
-       .int    title           @ Title String
-       .int    help            @ Help String
-       .int    table           @ Help and Command keyword table
-       .int    0               @ SWI Chunk base
-       .int    0               @ SWI handler code
-       .int    0               @ SWI decoding table
-       .int    0               @ SWI decoding code
+module_start:
 
+        .int   start           @ Start
+        .int   init            @ Initialisation
+        .int   final           @ Finalisation
+        .int    service_pre     @ Service Call
+        .int   modtitle        @ Title String
+        .int   help            @ Help String
+        .int   table           @ Help and Command keyword table
+        .int   0               @ SWI Chunk base
+        .int   0               @ SWI handler code
+        .int   0               @ SWI decoding table
+        .int   0               @ SWI decoding code
+        .int    0               @ Message File
+        .int    modflags        @ Module Flags
 
-title:
-       .string "ArcEmHostFSFiler"
+modflags:
+        .int    1               @ 32 bit compatible
+
+modtitle:
+        .string        "RPCEmuHostFSFiler"
 
 help:
-       .string "HostFSFiler\t0.02 (24 Mar 2006)"
-       .align
+        .string        "HostFSFiler\t0.03 (08 Dec 2006)"
+        .align
 
 
-       @ Help and Command keyword table
+        @ Help and Command keyword table
 table:
 desktop_hostfsfiler:
-       .string "Desktop_HostFSFiler"
-       .align
-       .int    command_desktop_hostfsfiler
-       .int    0x00070000
-       .int    0
-       .int    command_desktop_hostfsfiler_help
+        .string "Desktop_HostFSFiler"
+        .align
+        .int    command_desktop_hostfsfiler
+        .int    0x00070000
+        .int    0
+        .int    command_desktop_hostfsfiler_help
 
-       .byte   0       @ Table terminator
+        .byte   0       @ Table terminator
 
 command_desktop_hostfsfiler_help:
-       .string "The HostFSFiler provides the HostFS icons on the icon bar, and 
uses the Filer to display HostFS directories.\rDo not use *Desktop_HostFSFiler, 
use *Desktop instead."
+        .string        "The HostFSFiler provides the HostFS icons on the icon 
bar, and uses the Filer to display HostFS directories.\rDo not use 
*Desktop_HostFSFiler, use *Desktop instead."
 
-       .align
+        .align
 
 
 
@@ -104,16 +116,15 @@
        mov     r0, #Module_Claim
        mov     r3, #WORKSPACE_SIZE
        swi     XOS_Module
-       ldmvsfd sp!, {lr}
-       orrvss  pc, lr, #VBIT
-
+       ldmvsfd sp!, {pc}       @ no memory claimed then refuse to initialise
+       
        str     r2, [r12]
 1:
-       ldr     r12, [r12]
+       ldr     wp, [r12]
 
        @ Initialise the workspace
        mov     r0, #0
-       str     r0, [r12, #WS_MY_TASK_HANDLE]
+       str     r0, [wp, #WS_MY_TASK_HANDLE]
 
        ldmfd   sp!, {pc}
 
@@ -122,10 +133,10 @@
 final:
        stmfd   sp!, {lr}
 
-       ldr     r12, [r12]
+       ldr     wp, [r12]
 
        @ Close Wimp task if active
-       ldr     r0, [r12, #WS_MY_TASK_HANDLE]
+       ldr     r0, [wp, #WS_MY_TASK_HANDLE]
        cmp     r0, #0
        ldrgt   r1, TASK
        swigt   XWimp_CloseDown
@@ -135,90 +146,104 @@
        mov     r2, r12
        swi     XOS_Module
 
-       ldmfd   sp!, {pc}^
+        @ Clear V flag (26/32 bit safe) so our module will die
+        cmp     pc, #0          @ Clears V (also clears N, Z, and sets C)
+       ldmfd   sp!, {pc}
 
 
 
-service:
-       teq     r1, #Service_Reset
-       teqne   r1, #Service_StartFiler
-       teqne   r1, #Service_StartedFiler
-       teqne   r1, #Service_FilerDying
-       movnes  pc, lr
+         @ RISC OS 4 Service codetable
+service_codetable:
+        .int    0               @ no special flags enabled
+        .int    service_main
+        .int    Service_Reset
+        .int    Service_StartFiler
+        .int    Service_StartedFiler
+        .int    Service_FilerDying
+        .int    0               @ table terminator
+        .int    service_codetable
+service_pre:
+        mov     r0, r0          @ magic instruction, pointer to service table 
at service_pre-4
+        teq     r1, #Service_Reset
+        teqne   r1, #Service_StartFiler
+        teqne   r1, #Service_StartedFiler
+        teqne   r1, #Service_FilerDying
+        movne   pc, lr
 
-       stmfd   sp!, {lr}
+service_main:
+        stmfd   sp!, {lr}
 
-       ldr     r12, [r12]
+        ldr     wp, [r12]
 
-       teq     r1, #Service_Reset
-       beq     service_reset
-       teq     r1, #Service_StartFiler
-       beq     service_startfiler
-       teq     r1, #Service_StartedFiler
-       beq     service_startedfiler
-       teq     r1, #Service_FilerDying
-       beq     service_filerdying
+        teq     r1, #Service_Reset
+        beq     service_reset
+        teq     r1, #Service_StartFiler
+        beq     service_startfiler
+        teq     r1, #Service_StartedFiler
+        beq     service_startedfiler
+        teq     r1, #Service_FilerDying
+        beq     service_filerdying
 
-       @ Should never reach here
-       ldmfd   sp!, {pc}^
+        @ Should never reach here
+        ldmfd   sp!, {pc}
 
 
 
 service_reset:
        @ Zero the Task Handle
-       mov     lr, #0
-       str     lr, [r12, #WS_MY_TASK_HANDLE]
-       ldmfd   sp!, {pc}^
+       mov     r14, #0
+       str     r14, [wp, #WS_MY_TASK_HANDLE]
+       ldmfd   sp!, {pc}
 
 
 
 service_startfiler:
-       ldr     lr, [r12, #WS_MY_TASK_HANDLE]
-       teq     lr, #0                  @ Am I already active?
-       moveq   lr, #-1                 @ No, so set handle to -1
-       streq   lr, [r12, #WS_MY_TASK_HANDLE]
-       streq   r1, [r12, #WS_FILER_TASK_HANDLE]        @ store Filer's task 
handle
-       adreq   r0, desktop_hostfsfiler @ r0 points to command to start task
-       moveq   r1, #0                  @ claim the service
-       ldmfd   sp!, {pc}^
+       ldr     r14, [wp, #WS_MY_TASK_HANDLE]
+       teq     r14, #0                                 @ Am I already active?
+       moveq   r14, #-1                                @ No, so set handle to 
-1
+       streq   r14, [wp, #WS_MY_TASK_HANDLE]
+       streq   r1,  [wp, #WS_FILER_TASK_HANDLE]        @ store Filer's task 
handle
+       adreq   r0,  desktop_hostfsfiler                @ r0 points to command 
to start task
+       moveq   r1,  #0                                 @ claim the service
+       ldmfd   sp!, {pc}
 
 
 
 service_startedfiler:
        @ Zero the Task Handle if it is -1
-       ldr     lr, [r12, #WS_MY_TASK_HANDLE]
-       cmp     lr, #-1
-       moveq   lr, #0
-       streq   lr, [r12, #WS_MY_TASK_HANDLE]
-       ldmfd   sp!, {pc}^
+       ldr     r14, [wp, #WS_MY_TASK_HANDLE]
+       cmp     r14, #-1
+       moveq   r14, #0
+       streq   r14, [wp, #WS_MY_TASK_HANDLE]
+       ldmfd   sp!, {pc}
 
 
 
 service_filerdying:
-       @ Shut down task if active
+        @ Shut down task if active
 
-       stmfd   sp!, {r0-r1}
+        stmfd  sp!, {r0-r1}
 
-       ldr     r0, [r12, #WS_MY_TASK_HANDLE]
-       cmp     r0, #0
+        ldr    r0, [wp, #WS_MY_TASK_HANDLE]
+        cmp    r0, #0
 
-       @ Zero the Task Handle if non-zero
-       movne   lr, #0
-       strne   lr, [r12, #WS_MY_TASK_HANDLE]
+        @ Zero the Task Handle if non-zero
+        movne  r14, #0
+        strne  r14, [wp, #WS_MY_TASK_HANDLE]
 
-       @ Shut down task if Task Handle was positive
-       ldrgt   r1, TASK
-       swigt   XWimp_CloseDown
+        @ Shut down task if Task Handle was positive
+        ldrgt  r1, TASK
+        swigt  XWimp_CloseDown
 
-       ldmfd   sp!, {r0-r1}
-       ldmfd   sp!, {pc}^
+        ldmfd  sp!, {r0-r1}
+        ldmfd  sp!, {pc}
 
 
 
 command_desktop_hostfsfiler:
        stmfd   sp!, {lr}
        mov     r2, r0
-       adr     r1, title
+       adr     r1, modtitle
        mov     r0, #Module_Enter
        swi     XOS_Module
        ldmfd   sp!, {pc}
@@ -228,7 +253,7 @@
 TASK:
        .ascii  "TASK"
 
-task_title:
+task_modtitle:
        .string "HostFS Filer"
        .align
 
@@ -259,27 +284,29 @@
        @ Entered in User Mode
        @ Therefore no need to preserve link register before calling SWIs
 start:
-       ldr     r12, [r12]              @ Get workspace pointer
-       ldr     r0, [r12, #WS_MY_TASK_HANDLE]
-       cmp     r0, #0                  @ Am I already active?
-       ldrgt   r1, TASK                @ Yes, so close down first
-       swigt   XWimp_CloseDown
-       movgt   r0, #0                  @ Mark as inactive
-       strgt   r0, [r12, #WS_MY_TASK_HANDLE]
+        ldr     wp, [r12]               @ Get workspace pointer
+        ldr     r0, [wp, #WS_MY_TASK_HANDLE]
+        cmp     r0, #0                  @ Am I already active?
+        ble     start_skipclosedown     @ No then skip following instructions
+        ldr     r1, TASK                @ Yes, so close down first
+        swi     XWimp_CloseDown
+        mov     r0, #0                  @ Mark as inactive
+        str     r0, [wp, #WS_MY_TASK_HANDLE]
 
+start_skipclosedown:
        ldr     r0, = WIMP_VERSION      @ (re)start the task
        ldr     r1, TASK
-       adr     r2, task_title
+       adr     r2, task_modtitle
        swi     XWimp_Initialise
        swivs   XOS_Exit                @ Exit if error
 
-       str     r0, [r12, #WS_WIMP_VERSION]     @ store Wimp version
-       str     r1, [r12, #WS_MY_TASK_HANDLE]   @ store Task handle
+       str     r0, [wp, #WS_WIMP_VERSION]      @ store Wimp version
+       str     r1, [wp, #WS_MY_TASK_HANDLE]    @ store Task handle
 
 
        @ Prepare block for Icon Bar icon
        adr     r0, icon_bar_block
-       add     r1, r12, #WS_ICON_BAR_BLOCK
+       add     r1, wp, #WS_ICON_BAR_BLOCK
 
        ldmia   r0, {r2-r10}
        adr     r8, icon_bar_text               @ Fill in pointers
@@ -301,8 +328,8 @@
        str     r0, [r12, #WS_ICON_BAR_BLOCK + 16]
 
        @ Create Icon on Icon Bar
-       mov     r0, #0x78000000         @ Priority higher than ADFS Hard Disc
-       add     r1, r12, #WS_ICON_BAR_BLOCK
+       mov     r0, #0x71000000         @ Priority higher than ADFS Hard Disc 
but lower than CD-ROM discs
+       add     r1, wp, #WS_ICON_BAR_BLOCK
        swi     XWimp_CreateIcon
        bvs     close_down
 
@@ -312,7 +339,7 @@
        swi     XOS_ReadMonotonicTime   @ returns time in r0
        add     r2, r0, #100            @ poll no sooner than 1 sec unless event
        ldr     r0, = WIMP_POLL_MASK
-       add     r1, r12, #WS_WIMP_BLOCK @ point to Wimp block within workspace
+       add     r1, wp, #WS_WIMP_BLOCK  @ point to Wimp block within workspace
        swi     XWimp_PollIdle
        bvs     close_down
 
@@ -351,12 +378,12 @@
                                        @ otherwise continue to...
 close_down:
        @ Close down Wimp task
-       ldr     r0, [r12, #WS_MY_TASK_HANDLE]
+       ldr     r0, [wp, #WS_MY_TASK_HANDLE]
        ldr     r1, TASK
        swi     XWimp_CloseDown
 
        @ Zero the Task Handle
        mov     r0, #0
-       str     r0, [r12, #WS_MY_TASK_HANDLE]
+       str     r0, [wp, #WS_MY_TASK_HANDLE]
 
        swi     XOS_Exit

Index: hostfs.s
===================================================================
RCS file: /cvsroot/arcem/arcem/support_modules/hostfs/hostfs.s,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- hostfs.s    13 Feb 2006 18:56:02 -0000      1.5
+++ hostfs.s    12 May 2012 17:34:51 -0000      1.6
@@ -1,9 +1,8 @@
-       @
-       @ $Id$
-       @
-
        @ ARM constants
        VBIT = 1 << 28
+       CBIT = 1 << 29
+       ZBIT = 1 << 30
+       NBIT = 1 << 31
 
        @ RISC OS constants
        XOS_Write0          = 0x20002
@@ -18,21 +17,22 @@
 
        Service_FSRedeclare = 0x40
 
-       @ Constants for ArcEm memory-mapped IO
-       AIO_BASE   = 0x03000000
-       AIO_HOSTFS = AIO_BASE | (0x001 << 12)
+       @ ArcEm SWI chunk
+       ARCEM_SWI_CHUNK  = 0x56ac0
+       ARCEM_SWI_CHUNKX = ARCEM_SWI_CHUNK | 0x20000
+       ArcEm_HostFS    = ARCEM_SWI_CHUNKX + 1
 
-       AIO_HOSTFS_OPEN     = 0x000
-       AIO_HOSTFS_GETBYTES = 0x001
-       AIO_HOSTFS_PUTBYTES = 0x002
-       AIO_HOSTFS_ARGS     = 0x003
-       AIO_HOSTFS_CLOSE    = 0x004
-       AIO_HOSTFS_FILE     = 0x005
-       AIO_HOSTFS_FUNC     = 0x006
-       AIO_HOSTFS_GBPB     = 0x007
+       HOSTFS_PROTOCOL_VERSION = 1
 
        @ Filing system error codes
-       FILECORE_ERROR_DISCFULL = 0xc6
+       FILECORE_ERROR_DIRNOTEMPTY      = 0xb4
+       FILECORE_ERROR_ACCESS           = 0xbd           
+       FILECORE_ERROR_ALREADYOPEN      = 0xc2
+       FILECORE_ERROR_DISCFULL         = 0xc6
+       FILECORE_ERROR_BADDISC          = 0xc8
+       FILECORE_ERROR_DISCPROT         = 0xc9
+       FILECORE_ERROR_NOTFOUND         = 0xd6
+       HOSTFS_ERROR_UNKNOWN            = 0x100
 
        @ Filing system properties
        FILING_SYSTEM_NUMBER = 0x99     @ TODO choose unique value
@@ -58,13 +58,17 @@
        .int    0               @ SWI handler code
        .int    0               @ SWI decoding table
        .int    0               @ SWI decoding code
+       .int    0               @ Message File
+       .int    modflags        @ Module Flags
 
+modflags:
+       .int    1               @ 32 bit compatible
 
 title:
-       .string "ArcEmHostFS"
+       .string "RPCEmuHostFS"
 
 help:
-       .string "ArcEm HostFS\t0.03 (01 Feb 2006)"
+       .string "RPCEmu HostFS\t0.08 (05 Nov 2011)"
 
        .align
 
@@ -105,7 +109,7 @@
        .string "HostFS"
 
 fs_text:
-       .string "ArcEm Host Filing System"
+       .string "RPCEmu Host Filing System"
        .align
 
 
@@ -119,18 +123,47 @@
         *   other may be corrupted
         */
 init:
-       @ Declare filing system
-       stmfd   sp!, {lr}
+       stmfd   sp!, {r9, lr}
 
+       @ Register with emulator
+       mov     r0, #HOSTFS_PROTOCOL_VERSION
+       mov     r9, #0xffffffff         @ HostFS operation for Register
+       swi     ArcEm_HostFS
+       cmp     r0, #0xffffffff         @ Look for acknowledge response
+       bne     init_failed_registration
+
+       @ Declare filing system
        mov     r0, #FSControl_AddFS
        adr     r1, module_start
        mov     r2, #(fs_info_block - module_start)
        mov     r3, r12
        swi     XOS_FSControl
 
-       ldmfd   sp!, {pc}^
+       ldmfd   sp!, {r9, pc}
 
+init_failed_registration:
+       adr     r0, err_failed_registration
+       cmp     r0, #NBIT       @ compare r0 with most negative number 
(r0-1<<31)
+       cmnvc   r0, #NBIT       @ no overflow then compare R0 with most non 
existent positive number (r0+1<<31)
+       ldmfd   sp!, {r9, pc}   @ exit init with V set
 
+err_failed_registration:
+       .int    0
+       .string "Failed registration with emulator"
+       .align
+
+
+
+       /* Entry:
+        *   r10 = fatality indication: 0 is non-fatal, 1 is fatal
+        *   r11 = instantiation number
+        *   r12 = pointer to private word for this instantiation of the module.
+        *   r13 = supervisor stack pointer
+        * Exit:
+        *   preserve processor mode and interrupt state
+        *   r7-r11, r13 preserved
+        *   other and flags may be corrupted
+        */
 final:
        @ Remove filing system
        stmfd   sp!, {lr}
@@ -153,14 +186,24 @@
         *   registers must be preserved if not returning a result
         *   r12 may be corrupted
         */
+
+       @ RISC OS 4 Service codetable
+service_codetable:
+       .int    0               @ no special flags enabled
+       .int    service_main
+       .int    Service_FSRedeclare
+       .int    0               @ table terminator
+
+       .int    service_codetable
 service:
+       mov     r0, r0          @ magic instruction, pointer to service table 
at (current - 4)
        teq     r1, #Service_FSRedeclare
-       movnes  pc, lr
-
+       movne   pc, lr
+service_main:
        teq     r1, #Service_FSRedeclare
        beq     service_fsredeclare
 
-       movs    pc, lr          @ should never reach here
+       mov     pc, lr          @ should never reach here
 
        @ Filing system reinitialise
 service_fsredeclare:
@@ -173,7 +216,7 @@
        mov     r3, r12
        swi     XOS_FSControl
 
-       ldmfd   sp!, {r0-r3, pc}^
+       ldmfd   sp!, {r0-r3, pc}
 
 
        /* Entry (for all *Commands):
@@ -196,87 +239,127 @@
        adr     r1, fs_name
        swi     XOS_FSControl
 
-       ldmfd   sp!, {pc}^
+       ldmfd   sp!, {pc}
 
 
 
        /* FSEntry_Open (Open a file)
         */
 fs_open:
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_OPEN]
+       stmfd   sp!, {lr}
 
-       movs    pc, lr
+       mov     r9, #0
+       swi     ArcEm_HostFS
+
+       cmp     r9, #0xb0
+       bhs     hostfs_error
+
+       ldmfd   sp!, {pc}
 
 
        /* FSEntry_GetBytes (Get bytes from a file)
         */
 fs_getbytes:
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_GETBYTES]
+       stmfd   sp!, {lr}
 
-       movs    pc, lr
+       mov     r9, #1
+       swi     ArcEm_HostFS
+
+       cmp     r9, #0xb0
+       bhs     hostfs_error
+
+       ldmfd   sp!, {pc}
 
 
        /* FSEntry_PutBytes (Put bytes to a file)
         */
 fs_putbytes:
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_PUTBYTES]
+       stmfd   sp!, {lr}
 
-       movs    pc, lr
+       mov     r9, #2
+       swi     ArcEm_HostFS
+
+       cmp     r9, #0xb0
+       bhs     hostfs_error
+
+       ldmfd   sp!, {pc}
 
 
        /* FSEntry_Args (Control open files)
         */
 fs_args:
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_ARGS]
+       stmfd   sp!, {lr}
 
-       movs    pc, lr
+       mov     r9, #3
+       swi     ArcEm_HostFS
+
+       cmp     r9, #0xb0
+       bhs     hostfs_error
+
+       ldmfd   sp!, {pc}
 
 
        /* FSEntry_Close (Close an open file)
         */
 fs_close:
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_CLOSE]
+       stmfd   sp!, {lr}
 
-       movs    pc, lr
+       mov     r9, #4
+       swi     ArcEm_HostFS
+
+       cmp     r9, #0xb0
+       bhs     hostfs_error
+
+       ldmfd   sp!, {pc}
 
 
        /* FSEntry_File (Whole-file operations)
         */
 fs_file:
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_FILE]
+       stmfd   sp!, {lr}
 
-       teq     r9, #FILECORE_ERROR_DISCFULL
-       beq     disc_is_full
+       mov     r9, #5
+       swi     ArcEm_HostFS
 
-       movs    pc, lr
+       cmp     r9, #0xb0
+       bhs     hostfs_error
+
+       ldmfd   sp!, {pc}
 
 
        /* FSEntry_Func (Various operations)
         */
 fs_func:
+       stmfd   sp!, {lr}
+
        @ Test if operation is FSEntry_Func 10 (Boot filing system)...
        teq     r0, #10
        beq     boot
 
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_FUNC]
+       mov     r9, #6
+       swi     ArcEm_HostFS
 
-       teq     r9, #255
-       beq     not_implemented
+       cmp     r9, #0xb0
+       bhs     hostfs_error
 
-       teq     r9, #FILECORE_ERROR_DISCFULL
-       beq     disc_is_full
+       ldmfd   sp!, {pc}
 
-       movs    pc, lr
 
-boot:
+        /* FSEntry_GBPB (Multi-byte operations)
+         */
+fs_gbpb:
        stmfd   sp!, {lr}
+
+       mov     r9, #7
+       swi     ArcEm_HostFS
+
+       cmp     r9, #0xb0
+       bhs     hostfs_error
+
+       ldmfd   sp!, {pc}
+
+
+boot:
        adr     r0, 1f
        swi     XOS_CLI
        ldmfd   sp!, {pc}       @ Don't preserve flags - return XOS_CLI's error 
(if any)
@@ -286,34 +369,96 @@
        .align
 
 not_implemented:
-       stmfd   sp!, {lr}
        adr     r0, err_badfsop
        mov     r1, #0
        mov     r2, #0
        adr     r4, title
-       swi     XMessageTrans_ErrorLookup
-       ldmfd   sp!, {lr}
-       orrs    pc, lr, #VBIT
+       swi     XMessageTrans_ErrorLookup       @ V always set when SWI returns
+       ldmfd   sp!, {pc}
 
-disc_is_full:
-       adr     r0, err_discfull
-       orrs    pc, lr, #VBIT
+
+       /* Entry: 
+        * R9 = error number
+        * Exit:
+        * Return function with error
+        */
+hostfs_error:
+       teq     r9, #FILECORE_ERROR_DIRNOTEMPTY
+       adreq   r0, err_dirnotempty
+       beq     hostfs_return_error
+
+       teq     r9, #FILECORE_ERROR_ACCESS
+       adreq   r0, err_access
+       beq     hostfs_return_error
+
+       teq     r9, #FILECORE_ERROR_ALREADYOPEN
+       adreq   r0, err_alreadyopen
+       beq     hostfs_return_error
+
+       teq     r9, #FILECORE_ERROR_DISCFULL
+       adreq   r0, err_discfull
+       beq     hostfs_return_error
+
+       teq     r9, #FILECORE_ERROR_BADDISC
+       adreq   r0, err_baddisc
+       beq     hostfs_return_error
+
+       teq     r9, #FILECORE_ERROR_DISCPROT
+       adreq   r0, err_discprot
+       beq     hostfs_return_error
+
+       teq     r9, #FILECORE_ERROR_NOTFOUND
+       adreq   r0, err_notfound
+       beq     hostfs_return_error
+
+       adr     r0, err_unknown
+
+hostfs_return_error:
+       cmp     r0, #NBIT       @ compare r0 with most negative number 
(r0-1<<31)
+       cmnvc   r0, #NBIT       @ no overflow then compare R0 with most non 
existent positive number (r0+1<<31)
+       ldmfd   sp!, {pc}       @ exit error function with V set
 
 err_badfsop:
        .int    0x100a0 | (FILING_SYSTEM_NUMBER << 8)
        .string "BadFSOp"
        .align
 
+err_dirnotempty:
+       .int    0x10000 | (FILING_SYSTEM_NUMBER << 8) | 
FILECORE_ERROR_DIRNOTEMPTY
+       .string "Directory not empty"
+       .align
+
+err_access:
+       .int    0x10000 | (FILING_SYSTEM_NUMBER << 8) | FILECORE_ERROR_ACCESS
+       .string "The access details set for this item do not allow this"
+       .align
+
+err_alreadyopen:
+       .int    0x10000 | (FILING_SYSTEM_NUMBER << 8) | 
FILECORE_ERROR_ALREADYOPEN
+       .string "This file is already open"
+       .align
+
 err_discfull:
        .int    0x10000 | (FILING_SYSTEM_NUMBER << 8) | FILECORE_ERROR_DISCFULL
-       .string "Disc full"
+       .string "Disc is full"
        .align
 
+err_baddisc:
+       .int    0x10000 | (FILING_SYSTEM_NUMBER << 8) | FILECORE_ERROR_BADDISC
+       .string "Disc not found"
+       .align
 
-       /* FSEntry_GBPB (Multi-byte operations)
-        */
-fs_gbpb:
-       ldr     r9, = AIO_HOSTFS
-       str     r9, [r9, #AIO_HOSTFS_GBPB]
+err_discprot:
+       .int    0x10000 | (FILING_SYSTEM_NUMBER << 8) | FILECORE_ERROR_DISCPROT
+       .string "Disc is protected for changes"
+       .align
 
-       movs    pc, lr
+err_notfound:
+       .int    0x10000 | (FILING_SYSTEM_NUMBER << 8) | FILECORE_ERROR_NOTFOUND
+       .string "Not found"
+       .align
+
+err_unknown:
+       .int    0x10000 | (FILING_SYSTEM_NUMBER << 8)
+       .string "An unknown error occured"
+       .align

Index: hostfsfiler,ffa
===================================================================
RCS file: /cvsroot/arcem/arcem/support_modules/hostfs/hostfsfiler,ffa,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
Binary files /tmp/cvs9W0agd and /tmp/cvs5y8pmH differ

Index: Makefile
===================================================================
RCS file: /cvsroot/arcem/arcem/support_modules/hostfs/Makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile    7 Mar 2006 15:17:10 -0000       1.2
+++ Makefile    12 May 2012 17:34:51 -0000      1.3
@@ -9,7 +9,7 @@
 
 
 
-all: hostfs,ffa hostfsfiler,ffa
+all: hostfs,ffa
 
 %,ffa: %.elf
        $(OBJCOPY) -O binary $< $@


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-- 
arcem-cvs mailing list
arcem-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/arcem-cvs

Reply via email to