Provides privileged virtual memory read and write access.
The /dev/mem and /dev/kmem character special files provide access to a pseudo device driver that allows read and write access to system memory or I/O address space. Typically, these special files are used by operating system utilities and commands (such as sar, iostat, and vmstat) to obtain status and statistical information about the system.
Usage Considerations
kmem Special File Access
The kmem special file provides access to the virtual memory address space for the current process, as it is seen by the kernel. The seek offset, set by the lseek subroutine, is used to specify the virtual address targeted for the read or write. The kmem pseudo-device driver only supports the open, close, read, readx, writex, and write subroutines.
The knlist system subroutine is typically used to obtain the addresses of kernel symbols to read or write through access provided by the kmem special file.
Before issuing a read or write operation, the lseek subroutine must be used to designate the relevant starting address in virtual memory. If this address is within the first two gigabytes of address space, then the read or write subroutine calls can be used. However, if the upper two gigabytes of address space are to be accessed, the readx and writex form of the subroutine calls must be used. In this case, the ext (extension) parameter must be set to a value of True. This causes the lseek offset to be interpreted relative to the upper 2 gigabytes of address space.
mem Special File Access
The mem special file access is specific to the system on which the operating system is running.
Please refer to the Implementation of mem Special File Access section for details on the function provided by this special file.
Item | Description |
---|---|
Lower 2 gigabytes of address space: Use read or write subrourines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Upper 2 gigabytes of address space: Use readx or writex subroutines with ext parameter = TRUE. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The mem special file has traditionally provided direct access to physical memory. This capability and its interface requirements are machine-specific. However, for this operating system this function is indirectly provided by using the ext (extension) parameter on the readx and writex subroutine calls. When a readx or writex subroutine call associated with the /dev/mem special file is issued, the ext parameter must contain a valid segment register value as defined in the POWERstation and POWERserver Hardware Technical Reference - General Information documentation for the platform types(s) on which the program will be run. This allows the program to access all physical memory mapped by the page table as well as the platform-specific I/O (T=1) segments.
The seek offset set by the lseek subroutine call is used to specify the address offset within the segment described by the ext parameter. The upper four bits of the offset are not used. The pseudo-device driver only supports the open, close, read, readx, write, and writex subroutine calls. The lseek subroutine call must also be used before the readx or writex subroutine calls are issued, in order to specify the address offset.
If a read or write subroutine call is used with this special file, the access to memory is identical to that provided by the /dev/kmem special file.
The mem special file is part of Base Operating System (BOS) Runtime.
Item | Description |
---|---|
/dev/mem | Provides privileged virtual memory read and write access. |
/dev/kmem | Provides privileged virtual memory read and write access. |