| 1 | /*************************************************************************** |
| 2 | cpage.cxx - class for handling pages of embedded |
| 3 | device memory. |
| 4 | ------------------- |
| 5 | begin : Wed Sep 25 18:58:35 BST 2002 |
| 6 | copyright : (C) 2002 by Greg Reynolds, Jim Hawkridge |
| 7 | email : [email protected] |
| 8 | ***************************************************************************/ |
| 9 | |
| 10 | /*************************************************************************** |
| 11 | * * |
| 12 | * This program is free software; you can redistribute it and/or modify * |
| 13 | * it under the terms of the GNU General Public License as published by * |
| 14 | * the Free Software Foundation; either version 2 of the License, or * |
| 15 | * (at your option) any later version. * |
| 16 | * * |
| 17 | ***************************************************************************/ |
| 18 | |
| 19 | #include <stdio.h> |
| 20 | |
| 21 | #include "cpage.h" |
| 22 | |
| 23 | /* give me the size of this page */ |
| 24 | CPage::CPage(int nSize) |
| 25 | { |
| 26 | assert( nSize > 0 ); |
| 27 | m_nSize = nSize; |
| 28 | |
| 29 | /* allocate some space for this page */ |
| 30 | m_pData = new unsigned char[m_nSize]; |
| 31 | memset(m_pData, 0xff, m_nSize); |
| 32 | |
| 33 | m_lAddress = 0x00; |
| 34 | m_pNext = NULL; |
| 35 | } |
| 36 | |
| 37 | CPage::~CPage() |
| 38 | { |
| 39 | assert( m_pData ); |
| 40 | delete m_pData; |
| 41 | |
| 42 | if( m_pNext != NULL ) { |
| 43 | delete m_pNext; |
| 44 | m_pNext = NULL; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /* display this page's contents */ |
| 49 | void CPage::display() |
| 50 | { |
| 51 | int n; |
| 52 | |
| 53 | printf("\n\nAddress %6lX = ", m_lAddress); |
| 54 | printf("\n"); |
| 55 | |
| 56 | for( n = 0; n < m_nSize; n++ ) |
| 57 | printf("%2X ", m_pData[n]); |
| 58 | |
| 59 | printf("\n\n----END OF PAGE----"); |
| 60 | |
| 61 | fflush(stdout); |
| 62 | } |