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 <inttypes.h>
29#include <string.h>
30#include <stdlib.h>
31#include <stdio.h>
32#include <pciaccess.h>
33#include "common.h"
34
35/** @file
36 * This file defines the typedefs and stub structures necessary for us to
37 * use i830_debug.c mostly unmodified.
38 */
39
40typedef char Bool;
41
42#define FALSE 0
43#define TRUE 1
44
45#define X_INFO 0
46#define X_WARNING 1
47#define X_ERROR 2
48
49typedef struct _i830 {
50    /* Fields in common with the real pI830 */
51    struct pci_device *PciInfo;
52    Bool use_drm_mode;
53
54    /* Fields used for setting up reg_dumper */
55    volatile unsigned char *mmio;
56} I830Rec, *I830Ptr;
57
58typedef struct _scrn {
59    /* Fields in common with the real pScrn */
60    int scrnIndex;
61
62    /* Fields used for setting up reg_dumper */
63    I830Ptr pI830;
64} ScrnInfoRec, *ScrnInfoPtr;
65
66#define I830PTR(pScrn) (pScrn->pI830)
67
68#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
69
70#define INREG8(reg) (*(volatile uint8_t *)((pI830)->mmio + (reg)))
71#define INREG16(reg) (*(volatile uint16_t *)((pI830)->mmio + (reg)))
72#define INREG(reg) (*(volatile uint32_t *)((pI830)->mmio + (reg)))
73#define OUTREG8(reg, val) \
74	*(volatile uint8_t *)((pI830)->mmio + (reg)) = (val)
75#define OUTREG16(reg, val) \
76	*(volatile uint16_t *)((pI830)->mmio + (reg)) = (val)
77#define OUTREG(reg, val) \
78	*(volatile uint32_t *)((pI830)->mmio + (reg)) = (val)
79
80#define xalloc malloc
81#define xfree free
82#define ErrorF printf
83
84char *XNFprintf(const char *format, ...);
85void xf86DrvMsg(int scrnIndex, int severity, const char *format, ...);
86void i830DumpRegs(ScrnInfoPtr pScrn);
87void intel_i830rec_init(I830Ptr pI830);
88