osmemory_read_size

Tony van der Hoff OSLib at mk-net.demon.co.uk
Sun Sep 24 15:14:05 BST 2000


Hi Chris,

On Sun, 24 Sep 2000, at 14:08:49, Chris Rutter <chris at willow.armlinux.org> wrote on
the subject "osmemory_read_size":

>This doesn't seem to work; I would try and look at the AOF, but the
>library members are named in some way which wasn't obvious within thirty
>seconds of glancing so I couldn't extract it.  Anyway, this program:
>
>    int tbsz, pgsz;
>    osmemory_read_size(6, &tbsz, &pgsz);
>
>produces `bad reason code', and this one:
>
>    int tbsz, pgsz;
>    osmemory_read_size(0, &tbsz, &pgsz);
>
>produces `Parameters not recognised'.
>
>Crudely scanning through OSLib.o in Zap, I seem to have found the stub:
>
>    stmdb   r13!, {r1, r2}
>    orr     r0, r0, #8
>    swi     OS_Memory
>    ldr     r12, [r13, #0]
>    teq     r12, #0
>    strne   r1, [r12, #0]
>    ...
>
>Well, that #8 looks overwhelmingly wrong to me.
>
Unless I'm completely misunderstanding your intentions, it looks to me as if you're
trying to call the wrong function. Which reason code are you trying to call?

If it's 6, as I imagine, then you need 

/* ------------------------------------------------------------------------
 * Function:      osmemory_read_arrangement_table_size()
 *
 * Description:   Reads the size of the physical memory arrangement table -
 *                RISC O S 3.5+
 *
 * Output:        table_size - value of R1 on exit (X version only)
 *                page_size - value of R2 on exit
 *
 * Returns:       R1 (non-X version only)
 *
 * Other notes:   Calls SWI 0x68 with R0 = 0x6.
 */

extern os_error *xosmemory_read_arrangement_table_size (int *table_size,
      int *page_size);
extern int osmemory_read_arrangement_table_size (int *page_size);


osmemory_read_arrangement_table_size ROUT
        STMFD   SP!, {A1}
        MOV     R0, #&6
        SWI     &68
        LDR     IP, [SP, #0]
        TEQ     IP, #0
        STRNE   R2, [IP]
        MOV     R, R1
        ADD     SP, SP, #4
        MOVS    PC, LR


or, if it's 8, you need:

extern os_error *xosmemory_read_size (osmemory_type_flags type,
      int *page_count,
      int *page_size);
extern void osmemory_read_size (osmemory_type_flags type,
      int *page_count,
      int *page_size);


osmemory_read_size ROUT
        STMFD   SP!, {A2, A3}
        ORR     R0, R0, #&8
        SWI     &68
        LDR     IP, [SP, #0]
        TEQ     IP, #0
        STRNE   R1, [IP]
        LDR     IP, [SP, #4]
        TEQ     IP, #0
        STRNE   R2, [IP]
        ADD     SP, SP, #8
        MOVS    PC, LR


not forgetting to set bits 8-11 of R0 as per the PRM.

Perhaps reading the headers would have been more fruitful than disassembling 
the ALF ;-)

Hope this helps, Tony
-- 
Tony van der Hoff         |  mailto:OSLib at mk-net.demon.co.uk
Buckinghamshire, England  |  http://www.mk-net.demon.co.uk/oslib/
----------------------------------------------------------------



More information about the oslib-user mailing list