* The kms id of the created framebuffer.
*/
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
- unsigned int tiling, struct igt_fb *fb)
+ unsigned tiling, struct igt_fb *fb)
{
return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb, 0);
}
#include "i915_drm.h"
#include "intel_chipset.h"
+#include "igt_core.h"
/**
* SECTION:intel_chipset
int error;
error = pci_system_init();
- if (error != 0) {
- fprintf(stderr, "Couldn't initialize PCI system: %s\n",
- strerror(error));
- exit(1);
- }
+ igt_fail_on_f(error != 0,
+ "Couldn't initialize PCI system\n");
/* Grab the graphics card. Try the canonical slot first, then
* walk the entire PCI bus for a matching device. */
errx(1, "Couldn't find graphics card");
error = pci_device_probe(pci_dev);
- if (error != 0) {
- fprintf(stderr, "Couldn't probe graphics card: %s\n",
- strerror(error));
- exit(1);
- }
+ igt_fail_on_f(error != 0,
+ "Couldn't probe graphics card\n");
if (pci_dev->vendor_id != 0x8086)
errx(1, "Graphics card is non-intel");
gp.value = (int *)&devid;
ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
- assert(ret == 0);
+ igt_assert(ret == 0);
errno = 0;
}
#include <stdio.h>
#include <err.h>
#include <errno.h>
+
#include "intel_io.h"
#include "intel_reg.h"
+#include "igt_core.h"
#define TIMEOUT_US 500000
(bar << IOSF_BAR_SHIFT);
if (intel_register_read(VLV_IOSF_DOORBELL_REQ) & IOSF_SB_BUSY) {
- fprintf(stderr, "warning: pcode (%s) mailbox access failed\n",
- is_read ? "read" : "write");
+ igt_warn("warning: pcode (%s) mailbox access failed\n", is_read ? "read" : "write");
return -EAGAIN;
}
timeout < TIMEOUT_US);
if (timeout >= TIMEOUT_US) {
- fprintf(stderr, "timeout waiting for pcode %s (%d) to finish\n",
- is_read ? "read" : "write", addr);
+ igt_warn("timeout waiting for pcode %s (%d) to finish\n", is_read ? "read" : "write", addr);
return -ETIMEDOUT;
}
#include <sys/mman.h>
#include "intel_io.h"
+#include "igt_core.h"
#include "igt_debugfs.h"
#include "intel_chipset.h"
struct stat st;
fd = open(file, O_RDWR);
- if (fd == -1) {
- fprintf(stderr, "Couldn't open %s: %s\n", file,
- strerror(errno));
- exit(1);
- }
+ igt_fail_on_f(fd == -1,
+ "Couldn't open %s\n", file);
+
fstat(fd, &st);
mmio = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
- if (mmio == MAP_FAILED) {
- fprintf(stderr, "Couldn't mmap %s: %s\n", file,
- strerror(errno));
- exit(1);
- }
+ igt_fail_on_f(mmio == MAP_FAILED,
+ "Couldn't mmap %s\n", file);
close(fd);
}
PCI_DEV_MAP_FLAG_WRITABLE,
&mmio);
- if (error != 0) {
- fprintf(stderr, "Couldn't map MMIO region: %s\n",
- strerror(error));
- exit(1);
- }
+ igt_fail_on_f(error != 0,
+ "Couldn't map MMIO region\n");
}
static void
if (mmio == NULL)
intel_mmio_use_pci_bar(pci_dev);
- assert(mmio != NULL);
+ igt_assert(mmio != NULL);
if (mmio_data.inited)
return -1;
struct intel_register_range *range;
uint32_t ret;
- assert(mmio_data.inited);
+ igt_assert(mmio_data.inited);
if (intel_gen(mmio_data.i915_devid) >= 6)
- assert(mmio_data.key != -1);
+ igt_assert(mmio_data.key != -1);
if (!mmio_data.safe)
goto read_out;
INTEL_RANGE_READ);
if(!range) {
- fprintf(stderr, "Register read blocked for safety "
- "(*0x%08x)\n", reg);
+ igt_warn("Register read blocked for safety ""(*0x%08x)\n", reg);
ret = 0xffffffff;
goto out;
}
{
struct intel_register_range *range;
- assert(mmio_data.inited);
+ igt_assert(mmio_data.inited);
if (intel_gen(mmio_data.i915_devid) >= 6)
- assert(mmio_data.key != -1);
+ igt_assert(mmio_data.key != -1);
if (!mmio_data.safe)
goto write_out;
reg,
INTEL_RANGE_WRITE);
- if (!range) {
- fprintf(stderr, "Register write blocked for safety "
- "(*0x%08x = 0x%x)\n", reg, val);
- }
+ igt_warn_on_f(!range,
+ "Register write blocked for safety ""(*0x%08x = 0x%x)\n", reg, val);
write_out:
*(volatile uint32_t *)((volatile char *)mmio + reg) = val;
int ret;
ret = sysinfo(&sysinf);
- assert(ret == 0);
+ igt_assert(ret == 0);
retval = sysinf.totalram;
retval *= sysinf.mem_unit;
}
ret = sysinfo(&sysinf);
- assert(ret == 0);
+ igt_assert(ret == 0);
retval = sysinf.freeram;
retval *= sysinf.mem_unit;
int ret;
ret = sysinfo(&sysinf);
- assert(ret == 0);
+ igt_assert(ret == 0);
retval = sysinf.freeswap;
retval *= sysinf.mem_unit;
int n, i;
if ((n = swapctl(SC_GETNSWP, NULL)) == -1) {
- perror("swapctl: GETNSWP");
+ igt_warn("swapctl: GETNSWP");
return 0;
}
if (n == 0) {
swt = malloc(sizeof(struct swaptable) + (n * sizeof(swapent_t)));
buf = malloc(n * MAXPATHLEN);
if (!swt || !buf) {
- perror("malloc");
+ igt_warn("malloc");
} else {
swt->swt_n = n;
for (i = 0 ; i < n; i++) {
}
if ((n = swapctl(SC_LIST, swt)) == -1) {
- perror("swapctl: LIST");
+ igt_warn("swapctl: LIST");
} else {
for (i = 0; i < swt->swt_n; i++) {
totalpages += swt->swt_ent[i].ste_pages;
int main(int argc, char **argv)
{
- printf("Total RAM: %" PRIu64 " Mb\n", intel_get_total_ram_mb());
- printf("Total Swap: %" PRIu64 " Mb\n", intel_get_total_swap_mb());
+ igt_info("Total RAM: %"PRIu64" Mb\n", intel_get_total_ram_mb());
+ igt_info("Total Swap: %"PRIu64" Mb\n", intel_get_total_swap_mb());
return 0;
}
#include <stdarg.h>
#include <stdlib.h>
#include <sys/types.h>
+
#include "intel_io.h"
#include "intel_chipset.h"
+#include "igt_core.h"
static struct intel_register_range gen_bwcl_register_map[] = {
{0x00000000, 0x00000fff, INTEL_RANGE_RW},
map.map = gen4_register_map;
map.top = 0x80000;
} else {
- fprintf(stderr, "Gen2/3 Ranges are not supported. Please use "
- "unsafe access.");
- abort();
+ igt_fail_on("Gen2/3 Ranges are not supported. Please use ""unsafe access.");
}
map.alignment_mask = 0x3;