| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: header.H |
| 5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
| 7 | * |
| 8 | * The above named program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public |
| 10 | * License version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * The above named program is distributed in the hope that it will be |
| 13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public |
| 18 | * License along with this work; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | * ========== Copyright Header End ============================================ |
| 22 | */ |
| 23 | // ========== Copyright Header Begin ========================================== |
| 24 | // |
| 25 | // OpenSPARC T2 Processor File: header.H |
| 26 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 27 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
| 28 | // |
| 29 | // The above named program is free software; you can redistribute it and/or |
| 30 | // modify it under the terms of the GNU General Public |
| 31 | // License version 2 as published by the Free Software Foundation. |
| 32 | // |
| 33 | // The above named program is distributed in the hope that it will be |
| 34 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 35 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 36 | // General Public License for more details. |
| 37 | // |
| 38 | // You should have received a copy of the GNU General Public |
| 39 | // License along with this work; if not, write to the Free Software |
| 40 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 41 | // |
| 42 | // ========== Copyright Header End ============================================ |
| 43 | #ifndef _HEADER_H |
| 44 | #define _HEADER_H |
| 45 | |
| 46 | #include <string.h> |
| 47 | #include <stdlib.h> |
| 48 | |
| 49 | #define RSTZIP_HEADER_NUMCPU_STRING "Numcpus=" |
| 50 | |
| 51 | class RstzipHeader { |
| 52 | public: |
| 53 | RstzipHeader() { |
| 54 | memset(header, 0, RSTZIP_HEADERSIZE); |
| 55 | strcpy(header, "RZ2 -- Rstzip2 compressed RST file.\n"); |
| 56 | } |
| 57 | |
| 58 | char* getHeader() { |
| 59 | return header; |
| 60 | } |
| 61 | |
| 62 | void setNumcpus(int numcpus) { |
| 63 | char text[80]; |
| 64 | |
| 65 | sprintf(text, "%s%d.\n", RSTZIP_HEADER_NUMCPU_STRING, numcpus); |
| 66 | strcat(header, text); |
| 67 | } |
| 68 | |
| 69 | int getNumcpus() { |
| 70 | char* pnumcpu = strstr(header, RSTZIP_HEADER_NUMCPU_STRING); |
| 71 | |
| 72 | if (pnumcpu != NULL) { |
| 73 | return atoi(pnumcpu + sizeof(RSTZIP_HEADER_NUMCPU_STRING) - 1); |
| 74 | } |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | int getHeaderSize() { |
| 80 | return strlen(header); |
| 81 | } |
| 82 | |
| 83 | int getMaxHeaderSize() { |
| 84 | return RSTZIP_HEADERSIZE; |
| 85 | } |
| 86 | |
| 87 | int isValid() { |
| 88 | return (strncmp(header, "RZ2", 3) == 0); |
| 89 | } |
| 90 | |
| 91 | protected: |
| 92 | enum { |
| 93 | RSTZIP_HEADERSIZE = 512 |
| 94 | }; |
| 95 | |
| 96 | char header[RSTZIP_HEADERSIZE]; |
| 97 | }; // RstzipHeader |
| 98 | |
| 99 | #endif // _HEADER_H |