/ src / libnml / buffer / physmem.hh
physmem.hh
 1  /********************************************************************
 2  * Description: physmem.hh
 3  *   Provides the member functions for the PHYSMEM_HANDLE class. This
 4  *   is a C++ interface for portable access to physical memory.
 5  *
 6  *   Derived from a work by Fred Proctor & Will Shackleford
 7  *
 8  * Author:
 9  * License: LGPL Version 2
10  * System: Linux
11  *    
12  * Copyright (c) 2004 All rights reserved.
13  *
14  * Last change: 
15  ********************************************************************/
16  
17  #ifndef PHYSMEM_HH
18  #define PHYSMEM_HH
19  
20  
21  #ifdef  __cplusplus
22  extern "C" {
23  #endif
24  #include <stddef.h>		/* size_t */
25  
26  #ifdef __cplusplus
27  }
28  #endif
29  typedef char *LOCAL_ADDRESS_TYPE;
30  
31  class PHYSMEM_HANDLE {
32    public:
33      PHYSMEM_HANDLE();		/* Constructor for blank handle. */
34  
35      /* Constructor to access memory starting at _physical_address, for _size
36         bytes. Some platform implementations distinguish between various types 
37         of addresses using the address code. */
38      PHYSMEM_HANDLE(unsigned long _physical_address,
39  	long _address_code, long _size);
40  
41        virtual ~ PHYSMEM_HANDLE();	/* Destructor */
42  
43      long offset;		/* Operations read and write work use offset */
44      long size;
45      int read(void *_to, long _read_size);	/* Read _read_size bytes and
46  						   store */
47      /* at _to */
48      int write(void *_from, long _write_size);	/* Write _write_size bytes */
49      /* using data at _from */
50  
51      void set_to_ptr(void *_ptr, long size);	/* Use the physical memory at 
52  						   _ptr. */
53  
54      long address_code;		/* Platform specific address type code. */
55      /* (See vme.h for VXWORKS) */
56  
57      void memsetf(long offset, char _byte, long _memset_size);
58      int clear_memory();
59      int valid();
60      int isvalid;
61      char *temp_buf;
62      unsigned long physical_address;
63      LOCAL_ADDRESS_TYPE local_address;
64    protected:
65  
66    public:
67  
68      int using_bit3;
69      double total_bytes_moved;
70      int enable_byte_counting;
71  };
72  
73  #endif