Subversion Repositories Filer-Free

Rev

Blame | Last modification | View Log | RSS feed

; This file is part of the free Filer module for RISC OS.
; Copyright © 2007 Graham Shaw.
; Redistribution and modification are permitted under the terms of the
; GNU General Public License (version 2 or any later version).

        GET     _pathname_table.s

        AREA    |C$$Code|,CODE,READONLY,REL

        IMPORT  |pathname_hash|
        IMPORT  |pathname_find|

; Find filer window associated with given pathname and filing system
; number, add to list of windows awaiting update.
;
; The given pathname is that of an object within the directory,
; therefore its leafname is removed before searching.
;
; On entry:
;  R0=pathname (null terminated)
;  R1=filing system number
;  R2=filing system special field (null terminated) (or 0 if none)
;  R12=pathname table
; On exit:
;  R0-R3 corrupted (but R12 preserved)

        EXPORT  |upcall_refresh|
|upcall_refresh|
        STMFD   R13!,{R4,R12,R14}       ; Preserve registers

        MOV     R4,R12                  ; R4=pathname table
        MOV     R3,R2                   ; R3=fs special field (or 0)
        MOV     R2,R1                   ; R2=fs number

                                        ; Remove final component of pathname.
        MOV     R12,R0                  ; R12=pointer into pathname
        MOV     R1,#0                   ; R1=pointer to last path separator
                                        ; (initially zero)
|upcall_refresh_0|
        LDRB    R14,[R12],#1            ; R14=char from pathname
        TEQ     R14,#'.'                ;
        SUBEQ   R1,R12,#1               ; Update R1 if path separator found
        TEQ     R14,#0                  ;
        BNE     |upcall_refresh_0|      ; Repeat until end of pathname

        TEQ     R1,#0                   ;
        SUBNE   R1,R1,R0                ; R1=length of directory pathname
        BL      |pathname_hash|         ; R0=hash

        MOV     R1,R0                   ; R1=hash
        MOV     R0,R4                   ; R0=pathname table
        BL      |pathname_find|         ; R0=lower bound, R1=upper bound

        TEQ     R0,R1                   ;
        BEQ     |upcall_refresh_3|      ; Skip loop if range empty
        LDR     R12,[R4,#table_nodes]   ; R12=nodes array
|upcall_refresh_1|
        LDR     R2,[R12,R0,LSL#2]       ; R2=pointer to node
        LDR     R3,[R2,#node_refresh]   ; R3=1 if refresh pending, otherwise 0
        TEQ     R3,#0                   ;
        BNE     |upcall_refresh_2|      ; Jump if refresh already pending

        LDR     R3,[R4,#table_tail]     ; R3=pointer to tail node
        STR     R2,[R4,#table_tail]     ; Make node at R2 the tail node
        STR     R2,[R3,#node_next]      ; Link node at R2 into the chain
        MOV     R3,#1                   ;
        STR     R3,[R2,#node_refresh]   ; Mark node at R2 as refresh pending
        LDR     R2,[R4,#table_pollword] ;
        STR     R3,[R2]                 ; Set pollword

|upcall_refresh_2|
        ADD     R0,R0,#1                ; Increment pointer into index
        TEQ     R0,R1                   ;
        BNE     |upcall_refresh_1|      ; Repeat until upper bound reached

|upcall_refresh_3|
        LDMFD   R13!,{R4,R12,PC}        ; Restore registers and return

        END

Generated by GNU Enscript 1.6.5.2.