•  Back 
  •  Mxalloc 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : TOS - The Operating System
Author      : 
Version     : tos.hyp (December 19, 2008)
Subject     : Programmieren/Atari
Nodes       : 3010
Index Size  : 93790
HCP-Version : 5
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Title
@help       : 
@options    : +g -i -s +x +zz -t4
@width      : 70
View Ref-File5.13.5.2  Mxmask                                                   TOS

/*
   Mxmask returns a bit-mask with which one should mask the mode
   WORD of a Mxalloc call if one wants to use protection bits.
   This is necessary as Mxalloc unfortunately returns erroneous
   results in some GEMDOS implementations when protection bits are
   specified, which can result in a system crash.
   (© 1994 Martin Osieka)

   Application example:
   mxMask = Mxmask();
   p = mxMask ? Mxalloc( size, 0x43 & mxMask) : Malloc( size); */

SHORT Mxmask (void)
{
    void *svStack;         /* Supervisor-Stack */
    int32_t sRAM, sRAMg;   /* ST-RAM           */
    int32_t aRAM, aRAMg;   /* Alternate RAM    */

    /*
    // Sample table of possible values:
    //           | newfashion  | oldfashion
    // sRAM aRAM | sRAMg aRAMg | sRAMg aRAMg
    //   1    0  |   1     0   |   1     1
    //   0    2  |   0     2   |   2     2
    //   1    2  |   1     2   |   3     3
    */

    svStack = (void *) Super( 0);  /* Disallow task-switching */

    sRAM  = (int32_t) Mxalloc( -1, 0);
    sRAMg = (int32_t) Mxalloc( -1, 0x40); /* In error case Mxalloc( -1, 3) */
    aRAM  = (int32_t) Mxalloc( -1, 1);
    aRAMg = (int32_t) Mxalloc( -1, 0x41); /* In error case Mxalloc( -1, 3) */

    Super( svStack);  /* Permit task-switching */

    if (sRAM == -32)
        return 0x0000;  /* Mxalloc is not implemented */

    else if ( ((sRAM + aRAM) == sRAMg) && ((sRAM + aRAM) == aRAMg) )
        return 0x0003;  /* oldfashion Mxalloc() */

    else
        return 0xFFFF;

} /* Mxmask */

See also: GEMDOS   Memory management