(Non) empty description in .swi files

John Tytgat John.Tytgat at aaug.net
Wed Dec 31 15:35:25 GMT 2008


Hi,

One OSLib user notified me that the PCI.Hdr assembler header did not
contain all the SWI definitions as mentioned in the pci.swi file while it
was the case for the generated PCI.h C header.

This is indeed the case and seems to be dependant on the fact whether
that SWI has a description in the .swi file or not.  The DefMon2 Manual
says the following on 'description':

--8<--
A SWI number may be followed with a textual description or with a star
(in which case a description will be made up): the same applies to a reason
code number. This controls the name given to the function.
--8<--

So no explanation what a missing description could actually mean or what
the implications are.  Attached a small test .swi which defines 3 SWIs:

  1) one without any description (TEST_WithoutDescription)
  2) one with a description (TEST_WithDescription)
  3) one with a star instead of a description (TEST_WithStar)

Two extracts from the generated C header:

> /**********************************
>  * SWI names and SWI reason codes *
>  **********************************/
> #undef  TEST_WithDescription
> #define TEST_WithDescription                    0xAAA01
> #undef  XTEST_WithDescription
> #define XTEST_WithDescription                   0xAAA01
> #undef  TEST_WithStar
> #define TEST_WithStar                           0xAAA02
> #undef  XTEST_WithStar
> #define XTEST_WithStar                          0xAAA02

and

> extern os_error *xtest_without_description (int in);
> __swi (0xAAA00) void test_without_description (int in);
> [...]
> extern os_error *xtest_with_description (int in);
> __swi (0xAAA01) void test_with_description (int in);
> [...]
> extern os_error *xtest_with_star (int in);
> __swi (0xAAA02) void test_with_star (int in);

So there is no preprocessor #define for the SWI without description but
there is a function prototype generated (and not shown here, but also
the ARM code wrapping those SWIs are generated).

The generated assembler on the other hand:

> ;Symbols for SWI's and SWI reason codes
> XTEST_WithDescription           *       &AAA01
> TEST_WithDescription            *       &AAA01
>    ;Entry
>    ;  R0 = in (Int)
> 
> XTEST_WithStar                  *       &AAA02
> TEST_WithStar                   *       &AAA02
>    ;Entry
>    ;  R0 = in (Int)

I.e. in line with the generated #defines (without a definition for the
SWI without description) and no way you can use that SWI via assmebler
(but you could via the C header).

Any reason for this inconsistency ? Is there an usecase to limit the
use of SWIs without description (and without a star) ? My proposal is
the make the empty description case the same was the 'star' case, so
an artificial description gets automatically generated.

John.
-- 
John Tytgat, in his comfy chair at home                                 BASS
John.Tytgat at aaug.net                             ARM powered, RISC OS driven
-------------- next part --------------
#ifndef test_H
#define test_H

/* C header file for TEST
 * written by DefMod (Dec 31 2008) on Wed Dec 31 16:23:33 2008
 * Test 
 */

/*OSLib---efficient, type-safe, transparent, extensible,
   register-safe A P I coverage of RISC O S*/
/*Copyright (c) 1994 Jonathan Coxhead*/

/*
      OSLib is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 1, or (at your option)
   any later version.

      OSLib is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
   along with this programme; if not, write to the Free Software
   Foundation, Inc, 675 Mass Ave, Cambridge, MA 02139, U S A.
*/

#ifndef types_H
#include "oslib/types.h"
#endif

#ifndef os_H
#include "oslib/os.h"
#endif

#if defined NAMESPACE_OSLIB
  namespace OSLib {
#endif

/**********************************
 * SWI names and SWI reason codes *
 **********************************/
#undef  TEST_WithDescription
#define TEST_WithDescription                    0xAAA01
#undef  XTEST_WithDescription
#define XTEST_WithDescription                   0xAAA01
#undef  TEST_WithStar
#define TEST_WithStar                           0xAAA02
#undef  XTEST_WithStar
#define XTEST_WithStar                          0xAAA02

/*************************
 * Function declarations *
 *************************/

#ifdef __cplusplus
   extern "C" {
#endif

/* ------------------------------------------------------------------------
 * Function:      test_without_description()
 *
 *
 * Input:         in - value of R0 on entry
 */

extern os_error *xtest_without_description (int in);
__swi (0xAAA00) void test_without_description (int in);

/* ------------------------------------------------------------------------
 * Function:      test_with_description()
 *
 * Description:   This SWI has a description
 *
 * Input:         in - value of R0 on entry
 *
 * Other notes:   Calls SWI 0xAAA01.
 */

extern os_error *xtest_with_description (int in);
__swi (0xAAA01) void test_with_description (int in);

/* ------------------------------------------------------------------------
 * Function:      test_with_star()
 *
 * Description:   Calls SWI 0xAAA02
 *
 * Input:         in - value of R0 on entry
 */

extern os_error *xtest_with_star (int in);
__swi (0xAAA02) void test_with_star (int in);

#ifdef __cplusplus
   }
#endif

#if defined NAMESPACE_OSLIB
  } 
#endif

#endif
-------------- next part --------------
;Assembler header file for TEST
;written by DefMod (Dec 31 2008) on Wed Dec 31 16:23:34 2008
;Test 

        [       :LNOT: :DEF: TEST_Hdr
        GBLS    TEST_Hdr

        [       :LNOT: :DEF: Get_Types
        GBLS    Get_Types
        ]
        [       :LNOT: :DEF: Types_Hdr
Get_Types                       SETS    "GET oslib/Types.Hdr"
        |
Get_Types                       SETS    ""
        ]
        $Get_Types

        [       :LNOT: :DEF: Get_OS
        GBLS    Get_OS
        ]
        [       :LNOT: :DEF: OS_Hdr
Get_OS                          SETS    "GET oslib/OS.Hdr"
        |
Get_OS                          SETS    ""
        ]
        $Get_OS

;Symbols for SWI's and SWI reason codes
XTEST_WithDescription           *       &AAA01
TEST_WithDescription            *       &AAA01
   ;Entry
   ;  R0 = in (Int)

XTEST_WithStar                  *       &AAA02
TEST_WithStar                   *       &AAA02
   ;Entry
   ;  R0 = in (Int)

        ]
        END
-------------- next part --------------
TITLE TEST;

AUTHOR "Test";

NEEDS OS;

SWI
   TEST_WithoutDescription =
   (  NUMBER 0xAAA00,
      ENTRY
      (  R0 = .Int: in
   )  ),

   TEST_WithDescription =
   (  NUMBER 0xAAA01 "This SWI has a description",
      ENTRY
      (  R0 = .Int: in
   )  ),

   TEST_WithStar =
   (  NUMBER 0xAAA02 *,
      ENTRY
      (  R0 = .Int: in
   )  )



More information about the oslib-user mailing list