Use the GETMAIN macro to request one or more areas of virtual storage.
Before obtaining storage, be sure to read the topic about selecting the right subpool for virtual storage requests in z/OS MVS Programming: Authorized Assembler Services Guide.
You can also use the STORAGE macro to obtain storage. Compared to GETMAIN, STORAGE provides an easier-to-use interface and has fewer restrictions and locking requirements. See the virtual storage management chapter in z/OS MVS Programming: Authorized Assembler Services Guide for a comparison of GETMAIN and STORAGE.
The GETMAIN macro is also described in z/OS MVS Programming: Assembler Services Reference ABE-HSP, with the exception of the BRANCH and OWNER parameters.
In all other cases you must not assume that the storage is cleared to zeros.
The caller can specify CHECKZERO=YES to detect these and other cases where the system clears the requested storage to zeros.
The GETMAIN macro provides two types of entry linkage: SVC entry and branch entry. If you do not specify the BRANCH parameter, the GETMAIN service receives control through SVC entry. If you specify the BRANCH parameter, the GETMAIN service receives control through branch entry.
If you use GETMAIN to request real storage backing above 2 gigabytes, but your system does not support 64-bit storage, your request will be treated as a request for backing above 16 megabytes, even on earlier releases of z/OS that do not support backing above 2 gigabytes. However, boundary requirements indicated by the CONTBDY and STARTBDY parameters will be ignored by earlier releases of z/OS.
The requirements for the caller are:
Environmental factor | Requirement |
---|---|
Minimum authorization: | For subpools 0-127: problem state and PSW key
8-15. For subpools 131 and 132, one
or more of the following:
For other subpools: one or
more of the following:
For branch entry: supervisor state and PSW key 0. |
Dispatchable unit mode: | For SVC entry: task. For branch entry: task or SRB. |
Cross memory mode: | For SVC entry: PASN=HASN=SASN. For branch entry: any PASN, any HASN, any SASN. |
AMODE: | For SVC entry: 24- or 31- or 64-bit. For branch entry: 24- or 31-bit.
|
ASC mode: | For BRANCH=(YES,GLOBAL): primary or access register
(AR). For all other requests: primary. Callers in AR mode must use BRANCH=(YES,GLOBAL) and can obtain only global (common) storage. |
Interrupt status: | For BRANCH=(YES,GLOBAL): disabled for I/O and
external interrupts. For all other requests: enabled for I/O and external interrupts. |
Locks: |
|
Control parameters: | For LC, LU, VC, VU, EC, EU requests: control parameters
must be in the primary address space. For other requests: control parameters are in registers. |
Before issuing the GETMAIN macro in AR mode, issue SYSSTATE ASCENV=AR.
Before issuing the GETMAIN macro without the BRANCH parameter (SVC entry) the caller does not have to place any information into any register unless using it in register notation for a particular parameter, or using it as a base register.
Set GPR 4 to 0 or the address of a TCB in the currently addressable address space. Setting the GPR 4 to 0 identifies the input TCB as the TCB that owns the cross-memory resources for the currently addressable address space (task whose TCB address is in ASCBXTCB).
For an explanation of the term input TCB, and to determine system-assigned defaults for private storage ownership, see the topic about selecting the right subpool for virtual storage requests in z/OS MVS Programming: Authorized Assembler Services Guide.
For RC, RU, VRC, and VRU requests (the only valid requests with BRANCH=(YES,GLOBAL)): the caller does not have to place any information into any register unless using it in register notation for a particular parameter, or using it as a base register.
Some callers depend on register contents remaining the same before and after issuing a service. If the system changes the contents of registers on which the caller depends, the caller must save them before issuing the service, and restore them after the service returns control.
Repeatedly issuing the GETMAIN macro can slow down performance. If your program requires many identically sized storage areas, use the CPOOL macro or callable cell pool services for better performance.
The standard form of the GETMAIN macro is written as follows:
Syntax | Description |
---|---|
name | name: symbol. Begin name in column 1. |
␢ | One or more blanks must precede GETMAIN. |
GETMAIN | |
␢ | One or more blanks must follow GETMAIN. |
LC,LA=length addr,A=addr | length addr: A-type address, or register (2) - (12). |
LU,LA=length addr,A=addr | length value: symbol, decimal number, or register (2) - (12). |
VC,LA=length addr,A=addr | If RC or RU is specified, register (0) |
VU,LA=length addr,A=addr | may also be specified. |
EC,LV=length value,A=addr | addr: A-type address or register (2) - (12). |
EU,LV=length value,A=addr | Note: RC, RU, VRC, or VRU must be used for address
greater than 16 megabytes.
|
RC,LV=length value | |
RU,LV=length value | |
R,LV=length value | |
VRC,LV=(maximum length value, minimum length value) | maximum length value: symbol, decimal number, or register (2) - (12). |
VRU,LV=(maximum length value, minimum length value) | minimum length value: symbol, decimal number, or register (2) - (12). |
,SP=subpool nmbr | subpool nmbr: symbol or decimal number 0-255; or register (2) - (12). |
Default: SP=0 Note: Specify the subpool
as follows:
|
|
,BNDRY=DBLWD | Default: BNDRY=DBLWD |
,BNDRY=PAGE | Note: This parameter may not be specified with
R above.
|
,CONTBDY=containing_bdy | containing_bdy: Decimal number
3-31 or register (2) - (12). Note: CONTBDY may be specified only with
RC or RU.
|
,STARTBDY=starting_bdy | starting_bdy: Decimal number
3-31 or register (2) - (12). Note: STARTBDY may be specified only with
RC or RU.
|
,BRANCH=YES | Note: BRANCH=(YES,GLOBAL) may be specified only
with RC, RU, VRC, or VRU.
|
,BRANCH=(YES,GLOBAL) | |
,KEY=key number | key number: decimal numbers 0-15, or register (2) - (12). |
Note: KEY may be specified only with RC, RU, VRC,
or VRU.
|
|
,LOC=24 | Note: This parameter can only be used with RC,
RU, VRC, or VRU. On all other forms, LOC=24 is used.
|
,LOC=(24,31) | |
,LOC=(24,64) | |
,LOC=31 | |
,LOC=(31,31) | |
,LOC=(31,64) | |
,LOC=RES | Default: LOC=RES |
,LOC=(RES,31) | |
,LOC=(RES,64) | |
,LOC=EXPLICIT | Note: You must specify the INADDR parameter with |
,LOC=(EXPLICIT,24) | EXPLICIT. |
,LOC=(EXPLICIT,31) | |
,LOC=(EXPLICIT,64) | |
,INADDR=stor addr | stor addr: RX-type address
or register (1)-(12). Note: This parameter can only be specified with
LOC=EXPLICIT.
|
,OWNER=HOME | Default: OWNER=HOME |
,OWNER=PRIMARY | |
,OWNER=SECONDARY | |
,OWNER=SYSTEM | |
,CHECKZERO=YES | Default: CHECKZERO=NO |
,CHECKZERO=NO | Note: CHECKZERO may be specified only with RC,
RU, VRC, or VRU.
|
,RELATED=value | value: Any valid assembler character string |
The parameters are explained as follows.
The first parameter of the GETMAIN macro is positional and is required. This parameter describes the type or mode of the GETMAIN request. The first parameter can be one of the following values:
LC and LU indicate conditional (LC) and unconditional (LU) list requests, and specify requests for one or more areas of virtual storage. The length of each virtual storage area is indicated by the values in a list beginning at the address specified in the LA parameter. The address of each of the virtual storage areas is returned in a list beginning at the address specified in the A parameter. No virtual storage is allocated unless all of the requests in the list can be satisfied.
VC and VU indicate conditional (VC) and unconditional (VU) variable requests, and specify requests for single areas of virtual storage. The length of the single virtual storage area is between the two values at the address specified in the LA parameter. The address and actual length of the allocated virtual storage area are returned by the system at the address indicated in the A parameter.
EC and EU indicate conditional (EC) and unconditional (EU) element requests, and specify requests for single areas of virtual storage. The length of the single virtual storage area is indicated by the parameter, LV=length value. The address of the allocated virtual storage area is returned at the address indicated in the A parameter.
RU and R indicate unconditional register requests; RC indicates a conditional register request. RC, RU, and R specify requests for single areas of virtual storage. The length of the single virtual area is indicated by the parameter, LV=length value. The address of the allocated virtual storage area is returned in register 1.
LA specifies the virtual storage address of consecutive fullwords starting on a fullword boundary. Each fullword must contain the required length in the low-order three bytes, with the high-order byte set to 0. The lengths should be multiples of 8; if they are not, the system uses the next higher multiple of 8. If VC or VU was coded, two words are required. The first word contains the minimum length required, the second word contains the maximum length. If LC or LU was coded, one word is required for each virtual storage area requested; the high-order bit of the last word must be set to 1 to indicate the end of the list. The list must not overlap the virtual storage area specified in the A parameter.
LV=length value specifies the length, in bytes, of the requested virtual storage. The number should be a multiple of 8; if it is not, the system uses the next higher multiple of 8. If R is specified, LV=(0) may be coded; the low-order three bytes of register 0 must contain the length, and the high-order byte must contain the subpool number. LV=(maximum length value, minimum length value) specifies the maximum and minimum values of the length of the storage request.
The A parameter specifies the virtual storage address of consecutive fullwords, starting on a fullword boundary. The system places the address of the virtual storage area allocated in one or more words. If E was coded, one word is required. If LC or LU was coded, one word is required for each entry in the LA list. If VC or VU was coded, two words are required. The first word contains the address of the virtual storage area, and the second word contains the length actually allocated. The list must not overlap the virtual storage area specified in the LA parameter.
If the request specifies one of the LSQA or SQA subpools, the system ignores the BNDRY=PAGE keyword. Requests for storage from these subpools are then fulfilled from a single page, unless the request is greater than a page. See the virtual storage management chapter in z/OS MVS Programming: Authorized Assembler Services Guide for a list of LSQA and SQA subpools.
If a register is specified, the value must be in bits 24 - 31 of the register. CONTBDY is valid only with RC or RU.
CONTBDY is not valid with LOC=EXPLICIT or BNDRY=PAGE.
CONTBDY applies to all subpools.
Generally, if you omit this parameter, there is no containing boundary. However, if the GETMAIN is for SQA or LSQA, and is for less than 4 KB, and STARTBDY is specified, the default of CONTBDY is 12, ensuring that the GETMAIN stays within a 4 KB page boundary.
For GETMAIN macros that specify a CONTBDY parameter value that is larger than 12, it is possible that the allocated area spans across a 4 KB page boundary, even when the area is less than or equal to 4 KB and in an SQA or LSQA subpool.
If a register is specified, the value must be in bits 24-31 of the register. STARTBDY is valid only with RC or RU.
STARTBDY is not valid with LOC=EXPLICIT or BNDRY=PAGE.
STARTBDY applies to all subpools.
If you omit this parameter, the start boundary is 8 bytes (equivalent to specifying STARTBDY=3).
BRANCH=YES allows both local (private) and global (common) storage to be allocated. See Input register information for BRANCH=YES for specific information on input register requirements.
BRANCH=(YES,GLOBAL) allows only global storage to be allocated. With BRANCH=(YES,GLOBAL), the SP parameter may designate only subpools 226-228, 231, 239, 241, 245, 247, or 248. BRANCH=(YES,GLOBAL) is valid only with RC, RU, VRC, or VRU.
LOC=(24,64) indicates that virtual storage is to be located below 16 megabytes and central storage can be located anywhere in 64-bit storage.
LOC=(31,64) indicates that virtual storage is to be located below 2 gigabytes and central storage can be located anywhere in 64-bit storage.
All other subpools are supported both above and below 16 megabytes. For these subpools, specifying LOC=31 causes GETMAIN to try to allocate virtual storage above 16 megabytes. If the attempt fails, GETMAIN tries to allocate virtual storage below 16 megabytes. If this attempt also fails, GETMAIN does not allocate any storage.
All other subpools are supported both above and below 16 megabytes. For these subpools, specifying LOC=31 causes GETMAIN to try to allocate virtual storage above 16 megabytes. If the attempt fails, GETMAIN tries to allocate virtual storage below 16 megabytes. If this attempt also fails, GETMAIN does not allocate any storage.
When you use LOC=RES to allocate storage that can reside either above or below 16 megabytes, LOC=RES indicates that the location of virtual and central storage depends on the location of the caller. If the caller resides below 16 megabytes, virtual and central storage are to be located below 16 megabytes. If the caller resides above 16 megabytes, virtual and central storage are to be located either above or below 16 megabytes.
LOC=(RES,64) indicates that the location of virtual storage depends upon the location of the caller. If the caller resides below 16 megabytes, virtual storage is to be located below 16 megabytes; if the caller resides above 16 megabytes, virtual storage can be located anywhere in 31-bit storage. In either case, central storage can be located anywhere in 64-bit storage.
LOC=(EXPLICIT,31) indicates that virtual storage is to be located at the address specified on the INADDR parameter, and central storage can be located anywhere below 2 gigabytes.
LOC=(EXPLICIT,24) indicates that virtual storage is to be located at the address specified on the INADDR parameter, and central storage is to be located below 16 megabytes. The virtual storage address specified on the INADDR parameter must be below 16 megabytes.
LOC=EXPLICIT and LOC=(EXPLICIT,64) indicate that virtual storage is to be located at the address specified on the INADDR parameter, and central storage can be located anywhere in 64-bit storage.
When you specify EXPLICIT on a request for storage from the same virtual page as previously requested storage, you must request it in the same key, subpool, and central storage area as on the previous storage request. For example, if you request virtual storage backed with central storage below 16 megabytes, any subsequent requests for storage from that virtual page must be specified as LOC=(EXPLICIT,24).
The default value is OWNER=HOME. The system ignores the OWNER parameter unless you specify a CSA, SQA, ECSA, or ESQA subpool on the SP parameter. The OWNER parameter is valid only on the VC, VU, RC, RU, VRC, and VRU types of GETMAIN requests.
Programs that issue the GETMAIN macro with the OWNER parameter can run on any z/OS system.
There is no performance cost to specifying CHECKZERO=YES.
Programs that issue the GETMAIN macro with the CHECKZERO parameter can run on any z/OS system. On a down-level system, CHECKZERO will be ignored, and the return code for a successful completion (conditional or unconditional) will be 0.
Abend codes the GETMAIN macro might issue are listed below in hexadecimal. For detailed abend code information, see z/OS MVS System Codes.
When the GETMAIN macro returns control to your program and you specified a conditional request, GPR 15 contains one of the following hexadecimal return codes:
Return Code | Meaning and Action |
---|---|
0 | Meaning: Successful completion. CHECKZERO=YES
was not specified, or the system has not cleared the requested storage
to zeroes. Action: None. |
4 | If you did not specify EXPLICIT on the LOC
parameter:
If you specified EXPLICIT on the LOC parameter:
|
8 | Meaning: System error. Virtual storage
was not obtained because the system has insufficient central storage
to back the request. Action: Report the problem to the system programmer so the cause of the problem can be determined and corrected. |
C | Meaning: System error. Virtual storage
was not obtained because the system cannot page in the page table
associated with the storage to be allocated. Action: Report the problem to the system programmer so the cause of the problem can be determined and corrected. |
10 | Meaning: Program error. Virtual storage
was not obtained for one of the following reasons: This reason code
applies only to GETMAIN requests with LOC=EXPLICIT specified.
Action: Determine why your program is attempting to obtain allocated storage or why your program is attempting to obtain virtual storage with different attributes from the same page of storage. Correct the coding error. |
14 | Meaning: Successful completion. The system
has cleared the requested storage to zeroes. This return code occurs
only when CHECKZERO=YES is specified. Action: None. |
GETMAIN RC,LV=400,SP=10
GETMAIN EU,LV=48,A=AREAADDR
.
.
.
AREAADDR DS F
GETMAIN VRU,LV=(4096,1024),LOC=ANY
GETMAIN EU,LV=248,A=AREAADDR,BRANCH=YES,SP=250.
GETMAIN RC,LV=4096,SP=231,BRANCH=(YES,GLOBAL),BNDRY=PAGE,KEY=2,OWNER=PRIMARY