Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

memctl(2)

NAME

memctl − control write/execute attributes of memory

SYNOPSIS

#include <sys/m88kbcs.h>
 
int memctl (base, length, state)
char ∗base;
int length;
int state;

DESCRIPTION

The memctl() service is used to set the state of a region of memory.  At any one time, a region of memory that is valid for the application may be in one of three states:
 

State Readable Writable Executable
MCT_TEXT yes no yes
MCT_DATA yes yes no
MCT_RDONLY yes no no

 
A process is allowed to perform the accesses designated in the table as "yes" for each state.  A process should not attempt to write to memory that is not writable (state MCT_TEXT and MCT_RDONLY). A process should not attempt to execute memory that is not executable (states MCT_DATA and MCT_RDONLY).  The .text section is initially in state MCT_TEXT.  The stack is initially in state MCT_DATA.  The .data and .bss sections are initially in state MCT_DATA.  If a process attempts improper access to a region of memory valid for the process, the results are undefined. 
 
After the last reference (read or write) and before the first execution of any region of a shared memory segment (obtained via shmat(2)), all processes that have referenced or will execute the region must issue a memctl() to set the state of the given region to MCT_TEXT.  Similarly, after the last execution and before the first reference of any region of a shared memory segment, all processes that have executed or will reference the region must issue a memctl() to set the state of the given region to MCT_DATA or MCT_RONLY; thus, when changing from MCT_TEXT the process may set to either of the non-executable modes, depending on whether it will write the shared memory segment. 
 
The region of memory is defined by the base and length arguments.  The base argument is the byte address of the first byte of the region.  The length argument is the length of the region in bytes.  The state argument is one of MCT_TEXT, MCT_DATA, MCT_RONLY. 
 
The base and length must be an integer multiple of the memory control unit.  The sysconf(2) system call can be used to determine the size of the memory control unit on the system. 
 

RETURN VALUE

Upon successful completion the value zero is returned.  If the system call failed, the value -1 is returned and errno is set to indicate the error. 
 

ERRORS

The memctl() system call shall fail without making any change to the state of a region of memory if one or more of the following are true:
 

[EINVAL] The state argument is invalid. 
 
The base argument is not an integral multiple of the memory control unit for the system. 
 
The length argument is not an integral multiple of the memory control unit for the system. 

[EFAULT] The region of memory is not valid for the application. 

CX/UX Programmer’s Reference Manual

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026