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