librtas_src/syscall_rmo.c File Reference

#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include "common.h"
#include "syscall.h"
#include "librtas.h"

Data Structures

struct  workarea_config

Defines

#define MAX_PAGES   64

Functions

static int read_kregion_bounds (struct region *kregion)
 Read the kernel region bounds for RMO memory.
static uint64_t get_bits (short lobit, short hibit, uint64_t mask)
static void set_bits (short lobit, short hibit, uint64_t value, uint64_t *mask)
static int acquire_file_lock (off_t start, size_t size)
static int release_file_lock (off_t start, size_t size)
static int get_phys_region (size_t size, uint32_t *phys_addr)
static int release_phys_region (uint32_t phys_addr, size_t size)
static int init_workarea_config ()
static int mmap_dev_mem (uint32_t phys_addr, size_t size, void **buf)
static int munmap_dev_mem (void *buf, size_t size)
int sc_interface_exists ()
int sc_free_rmo_buffer (void *buf, uint32_t phys_addr, size_t size)
int sc_get_rmo_buffer (size_t size, void **buf, uint32_t *phys_addr)

Variables

static const char * rmo_filename = "rmo_buffer"
static const char * devmem_path = "/dev/mem"
static const char * lockfile_path = "/var/lock/LCK..librtas"
static struct workarea_config wa_config

Detailed Description

Copyright (C) 2005 IBM Corporation Common Public License Version 1.0 (see COPYRIGHT)

Author:
John Rose <johnrose@us.ibm.com>

Define Documentation

#define MAX_PAGES   64


Function Documentation

static int acquire_file_lock ( off_t  start,
size_t  size 
) [static]

acquire_file_lock

Parameters:
start 
size 
Returns:
0 on success, !0 otherwise

References dbg1, workarea_config::lockfile_fd, lockfile_path, and RTAS_IO_ASSERT.

Referenced by get_phys_region().

static uint64_t get_bits ( short  lobit,
short  hibit,
uint64_t  mask 
) [inline, static]

get_bits

Parameters:
lobit 
hibit 
mask 
Returns:
0 on success, !0 otherwise

Referenced by get_phys_region(), and release_phys_region().

static int get_phys_region ( size_t  size,
uint32_t *  phys_addr 
) [static]

get_phys_region

Parameters:
size 
phys_addr 
Returns:
0 on success, !0 otherwise

References acquire_file_lock(), region::addr, dbg1, get_bits(), workarea_config::kern_region, MAX_PAGES, PAGE_SIZE, workarea_config::pages_map, RTAS_IO_ASSERT, set_bits(), and region::size.

Referenced by sc_get_rmo_buffer().

static int init_workarea_config (  )  [static]

init_workarea_config

Returns:
0 on success, !0 otherwise

References workarea_config::init_done, workarea_config::kern_region, and read_kregion_bounds().

Referenced by sc_get_rmo_buffer().

static int mmap_dev_mem ( uint32_t  phys_addr,
size_t  size,
void **  buf 
) [static]

mmap_dev_mem

Parameters:
phys_addr 
size 
buf 
Returns:
0 on success, !0 otherwise

References dbg1, devmem_path, and RTAS_IO_ASSERT.

Referenced by sc_get_rmo_buffer().

static int munmap_dev_mem ( void *  buf,
size_t  size 
) [static]

munmap_dev_mem

Parameters:
buf 
size 
Returns:
0 on success, !0 otherwise

References dbg1, devmem_path, and RTAS_IO_ASSERT.

Referenced by sc_free_rmo_buffer().

static int read_kregion_bounds ( struct region kregion  )  [static]

read_kregion_bounds

Parameters:
kregion 
Returns:
0 on success, !0 otherwise

References region::addr, dbg1, MAX_PAGES, open_proc_rtas_file(), PAGE_SIZE, read_entire_file(), rmo_filename, RTAS_IO_ASSERT, and region::size.

Referenced by init_workarea_config().

static int release_file_lock ( off_t  start,
size_t  size 
) [static]

release_file_lock

Parameters:
start 
size 
Returns:
0 on success, !0 otherwise

References dbg1, workarea_config::lockfile_fd, and RTAS_IO_ASSERT.

Referenced by release_phys_region().

static int release_phys_region ( uint32_t  phys_addr,
size_t  size 
) [static]

release_phys_region

Parameters:
phys_addr 
size 
Returns:
0 on success, !0 otherwise

References region::addr, dbg1, get_bits(), workarea_config::kern_region, PAGE_SIZE, workarea_config::pages_map, release_file_lock(), RTAS_IO_ASSERT, set_bits(), and region::size.

Referenced by sc_free_rmo_buffer().

int sc_free_rmo_buffer ( void *  buf,
uint32_t  phys_addr,
size_t  size 
)

sc_free_rmo_buffer

Parameters:
buf virtual address of mmap()'ed buffer
phys_addr physical address of low mem buffer
size size of buffer
Returns:
0 on success, !0 otherwise RTAS_FREE_ERR - Free called before get RTAS_IO_ASSERT - Unexpected I/O Error

References dbg1, workarea_config::init_done, munmap_dev_mem(), PAGE_SIZE, release_phys_region(), and RTAS_FREE_ERR.

Referenced by sc_cfg_connector(), sc_display_msg(), sc_errinjct(), sc_get_dynamic_sensor(), sc_get_indices(), sc_get_sysparm(), sc_get_vpd(), sc_lpar_perftools(), sc_platform_dump(), sc_scan_log_dump(), sc_set_dynamic_indicator(), sc_set_sysparm(), sc_update_nodes(), and sc_update_properties().

int sc_get_rmo_buffer ( size_t  size,
void **  buf,
uint32_t *  phys_addr 
)

sc_get_rmo_buffer

Parameters:
size Size of requested region. Must be a multiple of 4096.
buf Assigned to mmap'ed buffer of acquired region
phys_addr Assigned to physical address of acquired region
Returns:
0 on success, !0 otherwise RTAS_NO_MEM - Out of heap memory RTAS_NO_LOWMEM - Out of rmo memory RTAS_IO_ASSERT - Unexpected I/O Error

References region::addr, dbg1, get_phys_region(), workarea_config::init_done, init_workarea_config(), mmap_dev_mem(), and PAGE_SIZE.

Referenced by sc_cfg_connector(), sc_display_msg(), sc_errinjct(), sc_get_dynamic_sensor(), sc_get_indices(), sc_get_sysparm(), sc_get_vpd(), sc_lpar_perftools(), sc_platform_dump(), sc_scan_log_dump(), sc_set_dynamic_indicator(), sc_set_sysparm(), sc_update_nodes(), and sc_update_properties().

int sc_interface_exists (  ) 

sc_interface_exists

Returns:
0 on success, !0 otherwise

References open_proc_rtas_file(), and rmo_filename.

static void set_bits ( short  lobit,
short  hibit,
uint64_t  value,
uint64_t *  mask 
) [inline, static]

set_bits

Parameters:
lobit 
hibit 
value 
mask 
Returns:
0 on success, !0 otherwise

Referenced by get_phys_region(), and release_phys_region().


Variable Documentation

const char* devmem_path = "/dev/mem" [static]

Referenced by mmap_dev_mem(), and munmap_dev_mem().

const char* lockfile_path = "/var/lock/LCK..librtas" [static]

Referenced by acquire_file_lock().

const char* rmo_filename = "rmo_buffer" [static]

struct workarea_config wa_config [static]

Initial value:

 {
        .lockfile_fd = -1,
        .init_done = 0,
        .pages_map = 0ll,
}


Generated on Sat Jun 7 04:46:31 2008 for librtas by  doxygen 1.5.5