1/* 2 * Copyright © 2007 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: 24 * Eric Anholt <eric@anholt.net> 25 * 26 */ 27 28#include <stdio.h> 29#include <stdlib.h> 30#include <string.h> 31#include <stdarg.h> 32#include <sys/types.h> 33#include <sys/mman.h> 34#include <pciaccess.h> 35#include <err.h> 36#include <unistd.h> 37#include <fcntl.h> 38 39#include "reg_dumper.h" 40#include "../i810_reg.h" 41 42int main(int argc, char **argv) 43{ 44 I830Rec i830; 45 I830Ptr pI830 = &i830; 46 int devmem; 47 uint32_t hws_offset; 48 volatile uint32_t *hws; 49 50 intel_i830rec_init(pI830); 51 52 if (HWS_NEED_GFX(pI830)) 53 errx(1, "status page in graphics virtual unsupported.\n"); 54 55 hws_offset = INREG(HWS_PGA); 56 57 devmem = open("/dev/mem", O_RDWR, 0); 58 if (devmem == -1) 59 err(1, "Couldn't open /dev/mem"); 60 61 hws = mmap(NULL, 4096, PROT_READ, MAP_SHARED, devmem, hws_offset); 62 if (hws == MAP_FAILED) 63 err(1, "Couldn't map /dev/mem at 0x%08x", hws_offset); 64 65 close(devmem); 66 67 for (;;) { 68 int i; 69 70 printf("\n"); 71 72 for (i = 0; i < 64; i += 4) { 73 printf("0x%04x: 0x%08x 0x%08x 0x%08x 0x%08x\n", i * 4, 74 hws[i], hws[i + 1], hws[i + 2], hws[i + 3]); 75 } 76 77 sleep(1); 78 } 79 80 return 0; 81} 82