17020010 Screen turned to BLUE after running VTS graphicstest on Xorg(ast driver)
17258284 unable to interrupt vts ast graphicstest
--- a/open-src/app/gfx-utils/sun-src/vts/ast/ast.h Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/ast.h Mon Sep 16 15:54:13 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,284 +22,177 @@
*/
#ifndef AST_H
-#define AST_H
+#define AST_H
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/mman.h>
+#define AST_REG_SIZE_LOG2 18
-#include "gfx_common.h" /* GFX Common definitions */
-#include "graphicstest.h"
-#include "libvtsSUNWast.h" /* Common VTS library definitions */
+#define PCI_MAP_MEMORY 0x00000000
+#define PCI_MAP_IO 0x00000001
-#include "X11/Xlib.h"
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
+#define PCI_MAP_MEMORY_TYPE 0x00000007
+#define PCI_MAP_IO_TYPE 0x00000003
-#define AST_REG_SIZE_LOG2 18
+#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000
+#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002
+#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004
+#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006
+#define PCI_MAP_MEMORY_CACHABLE 0x00000008
+#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e
+#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0
-struct pci_info {
- unsigned long memBase[6];
- unsigned long ioBase[6];
- unsigned int type [6];
- unsigned int size [6];
-};
+#define PCI_MAP_IO_ATTR_MASK 0x00000003
+#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO)
+#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc
-
-#define PKT_NULL_CMD 0x00009561
-
-#define PKT_SINGLE_LENGTH 8
-#define PKT_SINGLE_CMD_HEADER 0x00009562
+#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK)
-typedef struct _PKT_SC
-{
- unsigned int header;
- unsigned int data[1];
-} PKT_SC, *PPKT_SC;
+#define PCI_MAP_IS64BITMEM(b) \
+ (((b) & PCI_MAP_MEMORY_TYPE) == PCI_MAP_MEMORY_TYPE_64BIT)
+#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
-#define CMD_QUEUE_GUARD_BAND 0x20
-
-typedef struct {
+#define PCI_REGION_BASE(_pcidev, _b, _type) \
+ (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] : \
+ (_pcidev)->ioBase[(_b)])
- unsigned long ulCMDQSize;
- unsigned long ulCMDQType;
-
- unsigned long ulCMDQOffset;
- unsigned char *pjCMDQvaddr;
-
- unsigned char *pjCmdQBasePort;
- unsigned char *pjWritePort;
- unsigned char *pjReadPort;
- unsigned char *pjEngStatePort;
+#define AR_PORT_WRITE 0x40
+#define MISC_PORT_WRITE 0x42
+#define SEQ_PORT 0x44
+#define DAC_INDEX_READ 0x47
+#define DAC_INDEX_WRITE 0x48
+#define DAC_DATA 0x49
+#define GR_PORT 0x4E
+#define CRTC_PORT 0x54
+#define INPUT_STATUS1_READ 0x5A
+#define MISC_PORT_READ 0x4C
- unsigned long ulCMDQMask;
- unsigned long ulCMDQueueLen;
-
- unsigned long ulWritePointer;
- unsigned long ulReadPointer;
- unsigned long ulReadPointer_OK; /* for Eng_DBGChk */
-
-} CMDQINFO, *PCMDQINFO;
+#define AST_MMIO_SIZE 0x00020000
+#define AST_VRAM_SIZE_08M 0x00800000
+#define AST_VRAM_SIZE_16M 0x01000000
+#define AST_VRAM_SIZE_32M 0x02000000
+#define AST_VRAM_SIZE_64M 0x04000000
+#define AST_VRAM_SIZE_128M 0x08000000
-typedef unsigned int (*PFNRead32) (unsigned char *);
-typedef void (*PFNWrite32) (unsigned char *, unsigned int);
-
-struct ast_info {
- int fd;
-
- int screenWidth;
- int screenHeight;
- int screenPitch;
- int bytesPerPixel;
-
- int MMIO2D;
-
- unsigned long FBPhysAddr;
- unsigned long MMIOPhysAddr;
- unsigned long RelocateIO;
-
- int FBMapSize;
- int MMIOMapSize;
-
- unsigned char *FBvaddr;
- unsigned char *MMIOvaddr;
-
- CMDQINFO CMDQInfo;
- unsigned long cmdreg;
-
- unsigned int save_dst_base;
- unsigned int save_line_xy;
- unsigned int save_line_err;
- unsigned int save_line_width;
- unsigned int save_line_k1;
- unsigned int save_line_k2;
- unsigned int save_mono_pat1;
- unsigned int save_mono_pat2;
-
- PFNRead32 read32;
- PFNWrite32 write32;
-};
-
-#define PCI_MAP_MEMORY 0x00000000
-#define PCI_MAP_IO 0x00000001
-
-#define PCI_MAP_MEMORY_TYPE 0x00000007
-#define PCI_MAP_IO_TYPE 0x00000003
-
-#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000
-#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002
-#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004
-#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006
-#define PCI_MAP_MEMORY_CACHABLE 0x00000008
-#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e
-#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0
+#define MASK_SRC_PITCH 0x1FFF
+#define MASK_DST_PITCH 0x1FFF
+#define MASK_DST_HEIGHT 0x7FF
+#define MASK_SRC_X 0xFFF
+#define MASK_SRC_Y 0xFFF
+#define MASK_DST_X 0xFFF
+#define MASK_DST_Y 0xFFF
+#define MASK_RECT_WIDTH 0x7FF
+#define MASK_RECT_HEIGHT 0x7FF
+#define MASK_CLIP 0xFFF
-#define PCI_MAP_IO_ATTR_MASK 0x00000003
-#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO)
-#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc
-
-#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK)
-
-#define PCI_MAP_IS64BITMEM(b) \
- (((b) & PCI_MAP_MEMORY_TYPE) == PCI_MAP_MEMORY_TYPE_64BIT)
-
-#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
-
-#define PCI_REGION_BASE(_pcidev, _b, _type) \
- (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] \
- : (_pcidev)->ioBase[(_b)])
-
-#define AR_PORT_WRITE 0x40
-#define MISC_PORT_WRITE 0x42
-#define SEQ_PORT 0x44
-#define DAC_INDEX_READ 0x47
-#define DAC_INDEX_WRITE 0x48
-#define DAC_DATA 0x49
-#define GR_PORT 0x4E
-#define CRTC_PORT 0x54
-#define INPUT_STATUS1_READ 0x5A
-#define MISC_PORT_READ 0x4C
-
-#define AST_MMIO_SIZE 0x00020000
-#define AST_VRAM_SIZE_08M 0x00800000
-#define AST_VRAM_SIZE_16M 0x01000000
-#define AST_VRAM_SIZE_32M 0x02000000
-#define AST_VRAM_SIZE_64M 0x04000000
-#define AST_VRAM_SIZE_128M 0x08000000
-
-
-#define MASK_SRC_PITCH 0x1FFF
-#define MASK_DST_PITCH 0x1FFF
-#define MASK_DST_HEIGHT 0x7FF
-#define MASK_SRC_X 0xFFF
-#define MASK_SRC_Y 0xFFF
-#define MASK_DST_X 0xFFF
-#define MASK_DST_Y 0xFFF
-#define MASK_RECT_WIDTH 0x7FF
-#define MASK_RECT_HEIGHT 0x7FF
-#define MASK_CLIP 0xFFF
-
-#define MASK_LINE_X 0xFFF
-#define MASK_LINE_Y 0xFFF
-#define MASK_LINE_ERR 0x3FFFFF
-#define MASK_LINE_WIDTH 0x7FF
-#define MASK_LINE_K1 0x3FFFFF
-#define MASK_LINE_K2 0x3FFFFF
-#define MASK_AIPLINE_X 0xFFF
-#define MASK_AIPLINE_Y 0xFFF
+#define MASK_LINE_X 0xFFF
+#define MASK_LINE_Y 0xFFF
+#define MASK_LINE_ERR 0x3FFFFF
+#define MASK_LINE_WIDTH 0x7FF
+#define MASK_LINE_K1 0x3FFFFF
+#define MASK_LINE_K2 0x3FFFFF
+#define MASK_AIPLINE_X 0xFFF
+#define MASK_AIPLINE_Y 0xFFF
/* CMDQ Reg */
-#define CMDQREG_SRC_BASE (0x00 << 24)
-#define CMDQREG_SRC_PITCH (0x01 << 24)
-#define CMDQREG_DST_BASE (0x02 << 24)
-#define CMDQREG_DST_PITCH (0x03 << 24)
-#define CMDQREG_DST_XY (0x04 << 24)
-#define CMDQREG_SRC_XY (0x05 << 24)
-#define CMDQREG_RECT_XY (0x06 << 24)
-#define CMDQREG_FG (0x07 << 24)
-#define CMDQREG_BG (0x08 << 24)
-#define CMDQREG_FG_SRC (0x09 << 24)
-#define CMDQREG_BG_SRC (0x0A << 24)
-#define CMDQREG_MONO1 (0x0B << 24)
-#define CMDQREG_MONO2 (0x0C << 24)
-#define CMDQREG_CLIP1 (0x0D << 24)
-#define CMDQREG_CLIP2 (0x0E << 24)
-#define CMDQREG_CMD (0x0F << 24)
-#define CMDQREG_PAT (0x40 << 24)
+#define CMDQREG_SRC_BASE (0x00 << 24)
+#define CMDQREG_SRC_PITCH (0x01 << 24)
+#define CMDQREG_DST_BASE (0x02 << 24)
+#define CMDQREG_DST_PITCH (0x03 << 24)
+#define CMDQREG_DST_XY (0x04 << 24)
+#define CMDQREG_SRC_XY (0x05 << 24)
+#define CMDQREG_RECT_XY (0x06 << 24)
+#define CMDQREG_FG (0x07 << 24)
+#define CMDQREG_BG (0x08 << 24)
+#define CMDQREG_FG_SRC (0x09 << 24)
+#define CMDQREG_BG_SRC (0x0A << 24)
+#define CMDQREG_MONO1 (0x0B << 24)
+#define CMDQREG_MONO2 (0x0C << 24)
+#define CMDQREG_CLIP1 (0x0D << 24)
+#define CMDQREG_CLIP2 (0x0E << 24)
+#define CMDQREG_CMD (0x0F << 24)
+#define CMDQREG_PAT (0x40 << 24)
-#define CMDQREG_LINE_XY (0x04 << 24)
-#define CMDQREG_LINE_Err (0x05 << 24)
-#define CMDQREG_LINE_WIDTH (0x06 << 24)
-#define CMDQREG_LINE_K1 (0x09 << 24)
-#define CMDQREG_LINE_K2 (0x0A << 24)
-#define CMDQREG_LINE_STYLE1 (0x0B << 24)
-#define CMDQREG_LINE_STYLE2 (0x0C << 24)
-#define CMDQREG_LINE_XY2 (0x05 << 24)
-#define CMDQREG_LINE_NUMBER (0x06 << 24)
+#define CMDQREG_LINE_XY (0x04 << 24)
+#define CMDQREG_LINE_ERR (0x05 << 24)
+#define CMDQREG_LINE_WIDTH (0x06 << 24)
+#define CMDQREG_LINE_K1 (0x09 << 24)
+#define CMDQREG_LINE_K2 (0x0A << 24)
+#define CMDQREG_LINE_STYLE1 (0x0B << 24)
+#define CMDQREG_LINE_STYLE2 (0x0C << 24)
+#define CMDQREG_LINE_XY2 (0x05 << 24)
+#define CMDQREG_LINE_NUMBER (0x06 << 24)
-#define CMD_BITBLT 0x00000000
-#define CMD_LINEDRAW 0x00000001
-#define CMD_COLOREXP 0x00000002
-#define CMD_ENHCOLOREXP 0x00000003
-#define CMD_TRANSPARENTBLT 0x00000004
-#define CMD_MASK 0x00000007
+#define CMD_BITBLT 0x00000000
+#define CMD_LINEDRAW 0x00000001
+#define CMD_COLOREXP 0x00000002
+#define CMD_ENHCOLOREXP 0x00000003
+#define CMD_TRANSPARENTBLT 0x00000004
+#define CMD_MASK 0x00000007
-#define CMD_DISABLE_CLIP 0x00000000
-#define CMD_ENABLE_CLIP 0x00000008
+#define CMD_DISABLE_CLIP 0x00000000
+#define CMD_ENABLE_CLIP 0x00000008
-#define CMD_COLOR_08 0x00000000
-#define CMD_COLOR_16 0x00000010
-#define CMD_COLOR_32 0x00000020
+#define CMD_COLOR_08 0x00000000
+#define CMD_COLOR_16 0x00000010
+#define CMD_COLOR_32 0x00000020
-#define CMD_SRC_SIQ 0x00000040
+#define CMD_SRC_SIQ 0x00000040
-#define CMD_TRANSPARENT 0x00000080
+#define CMD_TRANSPARENT 0x00000080
-#define CMD_PAT_FGCOLOR 0x00000000
-#define CMD_PAT_MONOMASK 0x00010000
-#define CMD_PAT_PATREG 0x00020000
+#define CMD_PAT_FGCOLOR 0x00000000
+#define CMD_PAT_MONOMASK 0x00010000
+#define CMD_PAT_PATREG 0x00020000
-#define CMD_OPAQUE 0x00000000
-#define CMD_FONT_TRANSPARENT 0x00040000
+#define CMD_OPAQUE 0x00000000
+#define CMD_FONT_TRANSPARENT 0x00040000
-#define CMD_X_INC 0x00000000
-#define CMD_X_DEC 0x00200000
+#define CMD_X_INC 0x00000000
+#define CMD_X_DEC 0x00200000
-#define CMD_Y_INC 0x00000000
-#define CMD_Y_DEC 0x00100000
+#define CMD_Y_INC 0x00000000
+#define CMD_Y_DEC 0x00100000
-#define CMD_NT_LINE 0x00000000
-#define CMD_NORMAL_LINE 0x00400000
+#define CMD_NT_LINE 0x00000000
+#define CMD_NORMAL_LINE 0x00400000
-#define CMD_DRAW_LAST_PIXEL 0x00000000
-#define CMD_NOT_DRAW_LAST_PIXEL 0x00800000
+#define CMD_DRAW_LAST_PIXEL 0x00000000
+#define CMD_NOT_DRAW_LAST_PIXEL 0x00800000
-#define CMD_DISABLE_LINE_STYLE 0x00000000
-#define CMD_ENABLE_LINE_STYLE 0x40000000
+#define CMD_DISABLE_LINE_STYLE 0x00000000
+#define CMD_ENABLE_LINE_STYLE 0x40000000
+
+#define CMD_RESET_STYLE_COUNTER 0x80000000
+#define CMD_NOT_RESET_STYLE_COUNTER 0x00000000
-#define CMD_RESET_STYLE_COUNTER 0x80000000
-#define CMD_NOT_RESET_STYLE_COUNTER 0x00000000
+#define QUEUE_MEMORY_MAP 0x02000000
+#define STAT_BUSY 0x80000000
-#define BURST_FORCE_CMD 0x80000000
+#define BURST_FORCE_CMD 0x80000000
-#define MMIOREG_DST_BASE (pAST->MMIOvaddr + 0x8008)
-#define MMIOREG_DST_PITCH (pAST->MMIOvaddr + 0x800C)
-#define MMIOREG_DST_XY (pAST->MMIOvaddr + 0x8010)
-#define MMIOREG_SRC_XY (pAST->MMIOvaddr + 0x8014)
-#define MMIOREG_RECT_XY (pAST->MMIOvaddr + 0x8018)
-#define MMIOREG_FG (pAST->MMIOvaddr + 0x801C)
-#define MMIOREG_BG (pAST->MMIOvaddr + 0x8020)
-#define MMIOREG_MONO1 (pAST->MMIOvaddr + 0x802C)
-#define MMIOREG_MONO2 (pAST->MMIOvaddr + 0x8030)
-#define MMIOREG_CLIP1 (pAST->MMIOvaddr + 0x8034)
-#define MMIOREG_CLIP2 (pAST->MMIOvaddr + 0x8038)
-#define MMIOREG_CMD (pAST->MMIOvaddr + 0x803C)
-#define MMIOREG_PAT (pAST->MMIOvaddr + 0x8100)
+#define MMIOREG_DST_BASE 0x8008
+#define MMIOREG_DST_PITCH 0x800C
+#define MMIOREG_DST_XY 0x8010
+#define MMIOREG_SRC_XY 0x8014
+#define MMIOREG_RECT_XY 0x8018
+#define MMIOREG_FG 0x801C
+#define MMIOREG_BG 0x8020
+#define MMIOREG_MONO1 0x802C
+#define MMIOREG_MONO2 0x8030
+#define MMIOREG_CLIP1 0x8034
+#define MMIOREG_CLIP2 0x8038
+#define MMIOREG_CMD 0x803C
+#define MMIOREG_QUEUE 0x8044
+#define MMIOREG_STAT 0x804C
+#define MMIOREG_PAT 0x8100
-#define MMIOREG_LINE_XY (pAST->MMIOvaddr + 0x8010)
-#define MMIOREG_LINE_Err (pAST->MMIOvaddr + 0x8014)
-#define MMIOREG_LINE_WIDTH (pAST->MMIOvaddr + 0x8018)
-#define MMIOREG_LINE_K1 (pAST->MMIOvaddr + 0x8024)
-#define MMIOREG_LINE_K2 (pAST->MMIOvaddr + 0x8028)
+#define MMIOREG_LINE_XY 0x8010
+#define MMIOREG_LINE_ERR 0x8014
+#define MMIOREG_LINE_WIDTH 0x8018
+#define MMIOREG_LINE_K1 0x8024
+#define MMIOREG_LINE_K2 0x8028
-int ast_get_pci_info(int fd, struct pci_info *pci_info);
-int ast_get_mem_info(struct pci_info *pci_info, struct ast_info *pAST);
-int ast_map_mem(struct ast_info *pAST, return_packet *rp, int test);
-int ast_unmap_mem(struct ast_info *pAST, return_packet *rp, int test);
-
-void ASTSetReg(int fd, int offset, int value);
-void ASTGetReg(int fd, int offset, int *value);
-void ASTSetIndexReg(int fd, int offset, int index, unsigned char value);
-void ASTGetIndexReg(int fd, int offset, int index, unsigned char *value);
-void ASTSetIndexRegMask(int fd, int offset, int index, int and, unsigned char value);
-void ASTGetIndexRegMask(int fd, int offset, int index, int and, unsigned char *value);
-void ASTOpenKey(int fd);
-unsigned int ASTMMIORead32(unsigned char *addr);
-void ASTMMIOWrite32(unsigned char *addr, unsigned int data);
-
-int ast_init_info(struct ast_info *);
-
#endif /* AST_H */
--- a/open-src/app/gfx-utils/sun-src/vts/ast/astio.h Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/astio.h Mon Sep 16 15:54:13 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -21,36 +21,54 @@
* DEALINGS IN THE SOFTWARE.
*/
+
+#ifndef _ASTIO_H
+#define _ASTIO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <sys/types.h>
#include <sys/fbio.h>
-#define ASTIOC ('Y' << 8)
+#define ASTIOC ('Y' << 8)
-#define AST_SET_IO_REG (ASTIOC | 1)
-#define AST_GET_IO_REG (ASTIOC | 2)
-#define AST_ENABLE_ROM (ASTIOC | 3)
-#define AST_DISABLE_ROM (ASTIOC | 4)
-#define AST_DEBUG_VIS_TEST (ASTIOC | 5)
-#define AST_DEBUG_GET_VIS_BUF (ASTIOC | 6)
-#define AST_DEBUG_GET_VIS_IMAGE (ASTIOC | 7)
-#define AST_DEBUG_TEST (ASTIOC | 8)
-#define AST_GET_STATUS_FLAGS (ASTIOC | 10)
+#define AST_SET_IO_REG (ASTIOC | 1)
+#define AST_GET_IO_REG (ASTIOC | 2)
+#define AST_ENABLE_ROM (ASTIOC | 3)
+#define AST_DISABLE_ROM (ASTIOC | 4)
+#define AST_DEBUG_VIS_TEST (ASTIOC | 5)
+#define AST_DEBUG_GET_VIS_BUF (ASTIOC | 6)
+#define AST_DEBUG_GET_VIS_IMAGE (ASTIOC | 7)
+#define AST_DEBUG_TEST (ASTIOC | 8)
+#define AST_GET_STATUS_FLAGS (ASTIOC | 10)
+#define AST_GET_INDEX (ASTIOC | 14)
+#define AST_SET_INDEX (ASTIOC | 15)
-#define AST_STATUS_HW_INITIALIZED 0x01
+#define AST_STATUS_HW_INITIALIZED 0x01
typedef struct {
uchar_t offset;
uchar_t value;
+ uchar_t offset1;
+ uchar_t value1;
} ast_io_reg;
struct ast_vis_cmd_buf {
- int cmd;
- int row;
- int col;
- int width;
- int height;
+ int cmd;
+ int row;
+ int col;
+ int width;
+ int height;
int pad0;
unsigned long word1;
unsigned long word2;
};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ASTIO_H */
--- a/open-src/app/gfx-utils/sun-src/vts/ast/chip.c Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/chip.c Mon Sep 16 15:54:13 2013 -0700
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,221 +21,241 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <errno.h>
-#include <signal.h> /* signal() */
-#include <stdio.h>
-#include <stropts.h> /* ioctl() */
-#include <unistd.h> /* ioctl(), sleep() */
-#include <sys/mman.h>
+#include "libvtsSUNWast.h" /* VTS library definitions for ast device */
+
+/*
+ * ast_test_chip()
+ *
+ * Test Chip, functional tests.
+ */
+
+return_packet *
+ast_test_chip(
+ register int const fd)
+{
+ static return_packet rp;
-#include "gfx_common.h" /* VTS Graphics Test common routines */
-#include "graphicstest.h"
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-#include "ast.h"
+ memset(&rp, 0, sizeof (return_packet));
+
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF)
+ return (&rp);
+
+ TraceMessage(VTS_DEBUG, "ast_test_chip",
+ "ast_test_chip running\n");
+
+ ast_block_signals();
+
+ ast_lock_display();
+
+ chip_test(&rp, fd);
-void
-box(struct ast_info *pAST, int x1, int y1, int x2, int y2, unsigned int color)
-{
- int tmp;
- int width;
- int height;
+ ast_unlock_display();
+
+ ast_restore_signals();
+
+ TraceMessage(VTS_DEBUG, "ast_test_chip",
+ "ast_test_chip completed\n");
+
+ return (&rp);
+
+} /* ast_test_chip() */
+
- if (x2 < x1) {
- tmp = x2;
- x2 = x1;
- x1 = tmp;
- }
- if (y2 < y1) {
- tmp = y2;
- y2 = y1;
- y1 = tmp;
+int
+chip_test(
+ register return_packet *const rp,
+ register int const fd)
+{
+ register uint_t black;
+ register uint_t white;
+
+ memset(&ast_info, 0, sizeof (ast_info));
+ ast_info.ast_fd = fd;
+
+ if (ast_map_mem(rp, GRAPHICS_ERR_CHIP) != 0)
+ return (-1);
+
+ if (ast_init_info(rp, GRAPHICS_ERR_CHIP) != 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
}
- width = x2 - x1;
- height = y2 - y1;
-
- ASTSetupForSolidFill(pAST, color, 0xf0);
- ASTSolidFillRect(pAST, x1, y1, width, height);
-
-} /* box() */
+ if (ast_init_graphics() < 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (0);
+ }
-void
-line(struct ast_info *pAST,
- int x1,
- int y1,
- int x2,
- int y2,
- unsigned int color
- )
-{
- ASTSetupForSolidLine(pAST, color, 0xf0);
- ASTSolidLine(pAST, x1, y1, x2, y2);
-
-} /* line() */
-
+ if (ast_save_palet() < 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (0);
+ }
-void
-draw_cascaded_box(struct ast_info *pAST, int width, int height)
-{
- unsigned int x1;
- unsigned int y1;
- unsigned int x2;
- unsigned int y2;
- unsigned int w;
- unsigned int h;
- int i;
- unsigned int k = 0;
+ if (ast_set_palet() < 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (0);
+ }
+
+ /* Clear screen black */
- for (i = 0; i < 256; i++) {
-
- x1 = (unsigned int)((width * i) / 512);
- x2 = width - x1;
- w = x2 - x1;
-
- y1 = (unsigned int)((height * i) / 512);
- y2 = height - y1;
-
- k = (i<<24 | i<<16 | i<<8 | i);
-
- box(pAST, x1, y1, x2, y2, k);
+ black = ast_color(0x00, 0x00, 0x00);
+ if (!ast_fill_solid_rect(0, 0,
+ ast_info.ast_width, ast_info.ast_height, black)) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
}
-} /* draw_cascaded_box() */
+ if (!ast_wait_idle()) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
+ /* line test */
-void
-draw_lines(struct ast_info *pAST, int width, int height)
-{
- unsigned int x1;
- unsigned int y1;
- unsigned int x2;
- unsigned int y2;
- int k;
- int i;
- int nlines = 128;
+ if (!draw_lines(ast_info.ast_width, ast_info.ast_height)) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
- k = 0;
- for (i = 0; i < nlines; i++) {
- k = 0x00af0000 | (i << 8) | i;
+ if (!ast_wait_idle()) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
- x1 = (unsigned int)((width * i) / nlines);
- x2 = x1;
- y1 = 0;
- y2 = height;
-
- line(pAST, x1, y1, x2, y2, k);
+ if (ast_sleep(2)) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
}
- for (i = 0; i < nlines; i++) {
- k = 0x00af0000 | (i << 8) | i;
+ /* fill rectangle test */
- x1 = 0;
- x2 = width;
- y1 = (unsigned int)((height * i) / nlines);
- y2 = y1;
-
- line(pAST, x1, y1, x2, y2, k);
+ if (!draw_cascaded_box(ast_info.ast_width, ast_info.ast_height)) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
}
-}
-void
-chip_test(return_packet *rp, int fd)
-{
- struct ast_info ast_info;
- struct ast_info *pAST;
- unsigned int red;
- unsigned char *fbaddr;
- int i;
- int bytepp;
- int fb_offset, fb_pitch, fb_height, fb_width;
+ if (!ast_wait_idle()) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
+
+ if (ast_sleep(2)) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
- pAST = &ast_info;
- pAST->fd = fd;
+ /* Clear screen white */
- /*
- * map the registers & frame buffers memory
- */
- if (ast_map_mem(pAST, rp, GRAPHICS_ERR_CHIP) == -1) {
- return;
- }
+ white = ast_color(0xff, 0xff, 0xff);
+ if (!ast_fill_solid_rect(0, 0,
+ ast_info.ast_width, ast_info.ast_height, white)) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
- /*
- * initialize ast info
- */
- if (ast_init_info(pAST) == -1) {
- return;
- }
+ if (!ast_wait_idle()) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_CHIP);
+ return (-1);
+ }
- /*
- * only support 32 bits depth for now
- */
- if (pAST->bytesPerPixel == 1) {
- goto done;
- }
+ ast_sleep(2);
+
+ ast_restore_palet();
+ ast_finish_graphics();
/*
- * enable 2D, initialize command queue
+ * Unmap the registers & frame buffers memory
*/
- ASTEnable2D(pAST);
+
+ if (ast_unmap_mem(rp, GRAPHICS_ERR_CHIP) != 0)
+ return (-1);
- if (ASTInitCMDQ(pAST) == -1) {
- pAST->MMIO2D = 1;
- } else {;
- ASTEnableCMDQ(pAST);
+ return (0);
+}
+int
+draw_lines(
+ register uint_t const width,
+ register uint_t const height)
+{
+ register uint_t x1;
+ register uint_t y1;
+ register uint_t x2;
+ register uint_t y2;
+ register uint_t color;
+ register uint_t lineon;
+ register uint_t const numlines = 128;
+
+ for (lineon = 0; lineon < numlines; lineon++) {
+ color = ast_color(0xaf, lineon, lineon);
+
+ x1 = (uint_t)((width * lineon) / numlines);
+ x2 = x1;
+ y1 = 0;
+ y2 = height;
+
+ if (!ast_draw_solid_line(x1, y1, x2, y2, color))
+ return (0);
}
- ASTSaveState(pAST);
-
- /*
- * set clipping rectangle
- */
- ASTSetClippingRectangle(pAST, 0, 0, pAST->screenWidth, pAST->screenHeight);
+ for (lineon = 0; lineon < numlines; lineon++) {
+ color = ast_color(0xaf, lineon, lineon);
- /*
- * Clear screen
- */
- box(pAST, 0, 0, pAST->screenWidth, pAST->screenHeight, 0);
- ASTWaitEngIdle(pAST);
+ x1 = 0;
+ x2 = width;
+ y1 = (uint_t)((height * lineon) / numlines);
+ y2 = y1;
- /*
- * line test
- */
- draw_lines(pAST, pAST->screenWidth, pAST->screenHeight);
- ASTWaitEngIdle(pAST);
- sleep(2);
+ if (!ast_draw_solid_line(x1, y1, x2, y2, color))
+ return (0);
+ }
+ return (1);
+}
- /*
- * fill test
- */
- draw_cascaded_box(pAST, pAST->screenWidth, pAST->screenHeight);
- ASTWaitEngIdle(pAST);
- sleep(2);
-
- /*
- * Clear screen
- */
- box(pAST, 0, 0, pAST->screenWidth, pAST->screenHeight, 0xff);
- ASTWaitEngIdle(pAST);
- sleep(2);
+int
+draw_cascaded_box(
+ register uint_t const width,
+ register uint_t const height)
+{
+ register uint_t x1;
+ register uint_t y1;
+ register uint_t x2;
+ register uint_t y2;
+ register uint_t color;
+ register uint_t recton;
+ register uint_t const numrects = 256;
- ASTResetState(pAST);
+ for (recton = 0; recton < numrects; recton++) {
+
+ x1 = (uint_t)((width * recton) / 512);
+ x2 = width - x1;
-done:
- /*
- * Unmap the registers & frame buffers memory
- */
- if (ast_unmap_mem(pAST, rp, GRAPHICS_ERR_CHIP) == -1) {
- return;
- }
+ y1 = (uint_t)((height * recton) / 512);
+ y2 = height - y1;
+ color = ast_color(recton, recton, recton);
- if (close(fd) == -1) {
- gfx_vts_set_message(rp, 1, GRAPHICS_ERR_CHIP, "error closing device\n");
- return;
+ if (!ast_fill_solid_rect(x1, y1, x2, y2, color))
+ return (0);
}
-} /* chip_test() */
-
-
-/* End of chip.c */
+ return (1);
+}
--- a/open-src/app/gfx-utils/sun-src/vts/ast/chip.h Wed Sep 11 11:55:15 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-
-/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-
-#ifndef _CHIP_H
-#define _CHIP_H
-
-
-#include "libvtsSUNWxfb.h" /* Common VTS library definitions */
-
-
-void chip_test_reset(void);
-
-void chip_test(return_packet *rp, int fd);
-
-
-#endif /* _CHIP_H */
-
-
-/* End of chip.h */
--- a/open-src/app/gfx-utils/sun-src/vts/ast/dma.c Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/dma.c Mon Sep 16 15:54:13 2013 -0700
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,97 +21,108 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <errno.h> /* errno */
-#include <stdio.h>
-#include <string.h> /* strerror() */
-#include <stropts.h> /* ioctl() */
-#include <unistd.h> /* ioctl() */
-#include <sys/mman.h>
-#include <stdlib.h>
+#include "libvtsSUNWast.h"
-#include "gfx_common.h"
-#include "graphicstest.h"
-#include "libvtsSUNWxfb.h" /* Common VTS library definitions */
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-#include "ast.h"
+/*
+ * ast_test_dma
+ *
+ * This test will open the device, allocate the dma buffers to
+ * separate memory spaces, and read/write the data, verifying it.
+ */
+
+return_packet *
+ast_test_dma(
+ register int const fd)
+{
+ static return_packet rp;
+
+ memset(&rp, 0, sizeof (return_packet));
-static int
-cmp_value(struct ast_info *pAST, int x, int y)
-{
- unsigned char *addr;
- unsigned int val;
+ TraceMessage(VTS_DEBUG, "ast_test_dma",
+ "ast_test_dma running\n");
+
+ ast_block_signals();
+
+ ast_lock_display();
+
+ dma_test(&rp, fd);
- addr = pAST->FBvaddr + (y-1) * pAST->screenPitch + x * pAST->bytesPerPixel;
- val = read32(addr);
- if ((val != 0x0) && (val != 0x00ffffff)) {
- printf("value at [%d %d] is different...0x%x\n", x, y, val);
- return -1;
- }
+ TraceMessage(VTS_DEBUG, "ast_test_dma",
+ "ast_test_dma completed\n");
- return 0;
+ ast_unlock_display();
+
+ ast_restore_signals();
+
+ return (&rp);
}
-void
-dma_test(return_packet *rp, int fd)
+int
+dma_test(
+ register return_packet *const rp,
+ register int const fd)
{
- struct ast_info ast_info;
- struct ast_info *pAST;
- unsigned int red;
- unsigned char *fbaddr;
- int i;
- int bytepp;
- int fb_offset, fb_pitch, fb_height, fb_width;
-
- pAST = &ast_info;
- pAST->fd = fd;
+ register uint_t fg;
+ register uint_t bg;
- /*
- * map the registers & frame buffers memory
- */
- if (ast_map_mem(pAST, rp, GRAPHICS_ERR_DMA) == -1) {
- return;
- }
-
- /*
- * initialize ast info
- */
- if (ast_init_info(pAST) == -1) {
- return;
- }
+ memset(&ast_info, 0, sizeof (ast_info));
+ ast_info.ast_fd = fd;
/*
- * for now, disable dma test when running on 8 bits
+ * map the registers & frame buffers memory
*/
- if (pAST->bytesPerPixel == 1) {
- goto done;
+ if (ast_map_mem(rp, GRAPHICS_ERR_DMA) != 0)
+ return (-1);
+
+ if (ast_init_info(rp, GRAPHICS_ERR_DMA) != 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ return (-1);
}
-
- ASTEnable2D(pAST);
+ if (ast_init_graphics() < 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ return (-1);
+ }
- if (ASTInitCMDQ(pAST) == -1) {
- pAST->MMIO2D = 1;
- } else {
- ASTEnableCMDQ(pAST);
+ if (ast_save_palet() < 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ return (-1);
+ }
+
+ if (ast_set_palet() < 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ return (-1);
}
- ASTSetupForMonoPatternFill(pAST, 0x77ddbbee, 0x77ddbbee, 0, 0xffffff, 0xf0);
- ASTMonoPatternFill(pAST, 0x77ddbbee, 0x77ddbbee, 0, 0,
- pAST->screenWidth, pAST->screenHeight);
- ASTWaitEngIdle(pAST);
+ fg = ast_color(0xff, 0x00, 0x00);
+ bg = ast_color(0xff, 0xff, 0xff);
+
+ /* Do pattern fill */
- sleep(1);
+ if (!ast_fill_pattern_rect(0, 0,
+ ast_info.ast_width, ast_info.ast_height,
+ fg, bg, 0x77ddbbee77ddbbee)) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ return (-1);
+ }
-done:
- /*
- * Unmap the registers & frame buffers memory
- */
- if (ast_unmap_mem(pAST, rp, GRAPHICS_ERR_DMA) == -1) {
- return;
- }
-} /* dma_test() */
+ if (!ast_wait_idle()) {
+ ast_restore_palet();
+ ast_finish_graphics();
+ ast_unmap_mem(NULL, GRAPHICS_ERR_DMA);
+ return (-1);
+ }
+
+ ast_sleep(2);
+ ast_restore_palet();
+ ast_finish_graphics();
-/* End of dma.c */
+ if (ast_unmap_mem(rp, GRAPHICS_ERR_DMA) != 0)
+ return (-1);
+
+ return (0);
+}
--- a/open-src/app/gfx-utils/sun-src/vts/ast/libvtsSUNWast.c Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/libvtsSUNWast.c Mon Sep 16 15:54:13 2013 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -21,53 +21,24 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <sys/param.h> /* MAXPATHLEN */
-#include <errno.h>
-#include <pwd.h> /* getpwuid() */
-#include <signal.h>
-#include <stdio.h> /* snprintf() */
-#include <stdlib.h> /* exit(), malloc() */
-#include <string.h> /* strcat(), strcpy() */
-#include <unistd.h> /* sleep() */
-#include <sys/fbio.h>
-#include <sys/mman.h>
-#include <sys/systeminfo.h> /* sysinfo() */
-#include <sys/visual_io.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
+#include "libvtsSUNWast.h"
+
+ast_info_t ast_info;
-#include "graphicstest.h"
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-
-#include "libvtsSUNWast.h" /* VTS library definitions for ast device */
-
+ast_xw_t ast_xw;
-#if (0) /* Unused */
-#define NO_DMA 0
-#define USE_DMA 1
-#endif
-
-#define MAX_DISPLAY_LEN 261
-
-
-static int no_window = 1;
-static gfxtest_info *tests_info;
-static int received_control_c = 0;
-static int need_screen_lock = 1;
-static Display *dpy = NULL;
-
+static gfxtest_info *tests_info;
/* Declarations needed for get_tests() */
-static unsigned int ast_mask_list[] = {
+static uint_t ast_mask_list[] = {
GRAPHICS_TEST_OPEN,
GRAPHICS_TEST_DMA,
GRAPHICS_TEST_MEM,
GRAPHICS_TEST_CHIP
};
-static unsigned int ast_mesg_list[] = {
+static uint_t ast_mesg_list[] = {
GRAPHICS_TEST_OPEN_MESG,
GRAPHICS_TEST_DMA_MESG,
GRAPHICS_TEST_MEM_MESG,
@@ -82,219 +53,33 @@
};
-static void
-disable_pm(Display *dpy)
-{
- int dummy;
-
- XSetScreenSaver(dpy, 0, 0, 0, 0);
- if (DPMSQueryExtension(dpy, &dummy, &dummy)) {
- DPMSDisable(dpy);
- }
- if (FBPMQueryExtension(dpy, &dummy, &dummy)) {
- FBPMDisable(dpy);
- }
-
-} /* disable_pm() */
-
-
-int
-lock_display(int fd, Display** current_display)
-{
- char env_buf[5 + MAXPATHLEN]; /* "HOME=<pw_dir>" */
- int i;
- int screen;
- Display *dpy;
- Window win;
- XSetWindowAttributes xswa;
- char hostname[MAX_DISPLAY_LEN];
- char display[MAX_DISPLAY_LEN];
- struct sigaction act;
- int current_screen;
- struct hostent *Host;
- struct passwd *pw_entry;
- int status;
- char no_bits[] = { 0 };
- XColor dumcolor;
- Pixmap lockc;
- Pixmap lockm;
- Cursor cursor;
-
- pw_entry = getpwuid(0);
- if (strlen(pw_entry->pw_dir) >= MAXPATHLEN) {
- TraceMessage(VTS_DEBUG, __func__,
- "HOME= directory path is too long\n");
- return (1);
- }
- strcpy(env_buf, "HOME=");
- strcat(env_buf, pw_entry->pw_dir);
- if (putenv(env_buf) != 0) {
- TraceMessage(VTS_DEBUG, __func__,
- "putenv( HOME= ) failed, errno:%d\n", errno);
- return (1);
- }
-
- dpy = NULL;
-
- if (gfx_vts_debug_mask & GRAPHICS_VTS_SLOCK_OFF) {
- TraceMessage(VTS_DEBUG, __func__, "lock_display() DISABLED\n");
- need_screen_lock = 0;
- *current_display = NULL;
- return (0);
- }
-
- current_screen = 0;
-
- TraceMessage(VTS_DEBUG, __func__, "locking X screen %d\n",
- current_screen);
-
-#if (0)
- /* Get the host machine name */
- if (sysinfo(SI_HOSTNAME, hostname, MAX_DISPLAY_LEN) == -1) {
- TraceMessage(VTS_DEBUG, __func__,
- "sysinfo(2) failed getting hostname\n");
- hostname[0] = '\0';
- }
-#else
- hostname[0] = '\0';
-#endif
-
- snprintf(display, sizeof (display), "%s:0.%d",
- hostname, current_screen);
- dpy = XOpenDisplay(display);
- TraceMessage(VTS_DEBUG, __func__,
- "XOpenDisplay, display = %s, dpy = 0x%p\n", display, dpy);
-
- if (dpy == NULL) {
- TraceMessage(VTS_DEBUG, __func__, "Assuming no window_system\n");
- return (0);
- }
-
- TraceMessage(VTS_DEBUG, __func__,
- "XOpenDisplay successful, display = %s, dpy = 0x%p\n",
- display, dpy);
-
- screen = DefaultScreen(dpy);
-
- /*
- * Flush request buffer and wait for all requests to be processed
- */
- XSync(dpy, False);
-
- /* Tell server to report events as they occur */
- XSynchronize(dpy, True);
-
- disable_pm(dpy);
-
- /* Create a blank cursor */
- lockc = XCreateBitmapFromData(dpy, RootWindow(dpy, 0),
- no_bits, 1, 1);
- lockm = XCreateBitmapFromData(dpy, RootWindow(dpy, 0),
- no_bits, 1, 1);
- cursor = XCreatePixmapCursor(dpy, lockc, lockm, &dumcolor,
- &dumcolor, 0, 0);
-
- XFreePixmap(dpy, lockc);
- XFreePixmap(dpy, lockm);
-
- xswa.cursor = cursor;
- xswa.override_redirect = True;
- xswa.event_mask = (KeyPressMask | KeyReleaseMask | ExposureMask);
- no_window = 0;
- win = XCreateWindow(dpy,
- RootWindow(dpy, screen),
- 0, 0,
- DisplayWidth(dpy, current_screen),
- DisplayHeight(dpy, current_screen),
- 0,
- CopyFromParent,
- InputOutput,
- CopyFromParent,
- CWOverrideRedirect | CWEventMask, &xswa);
-
- TraceMessage(VTS_DEBUG, __func__, " XCreateWindow win=%d\n", win);
-
- XMapWindow(dpy, win);
- XRaiseWindow(dpy, win);
- TraceMessage(VTS_DEBUG, __func__, " no_window=%d\n", no_window);
-
- if (!no_window) {
- /* Disable server from handling any requests */
- XGrabServer(dpy);
- /* Gain control of keyboard */
- status = XGrabKeyboard(dpy, win, False, GrabModeAsync,
- GrabModeAsync, CurrentTime);
-
- if (status != GrabSuccess) {
- TraceMessage(VTS_DEBUG, __func__,
- "Cannot gain control of keyboard\n");
- }
-
- status = XGrabPointer(dpy,
- win,
- False,
- ResizeRedirectMask,
- GrabModeAsync,
- GrabModeAsync,
- None,
- cursor,
- CurrentTime);
- if (status != GrabSuccess) {
- TraceMessage(VTS_DEBUG, __func__,
- "Cannot gain control of pointer\n");
- }
- }
-
- sleep(2);
- *current_display = dpy;
- return (0);
-
-} /* lock_display() */
-
-void
-unlock_display(Display *dpy)
-{
- if (dpy) {
- XUngrabPointer(dpy, CurrentTime);
- XUngrabKeyboard(dpy, CurrentTime);
- XUngrabServer(dpy);
- }
-}
-
-
/* *** PUBLIC *** */
/* These library functions are public and are expected to exist */
int
-get_tests(gfxtest_info *tests)
+get_tests(
+ register gfxtest_info *const tests)
{
- return_packet *ast_test_open(int fd);
-
/*
* Set the gfx_vts_debug_mask bits according to environment variables
*/
gfx_vts_set_debug_mask();
/*
- * Disable screen lock by default
- */
- gfx_vts_debug_mask |= GRAPHICS_VTS_SLOCK_OFF;
-
- /*
* Construct the list of tests to be performed
*/
tests->count = sizeof (ast_test_list) / sizeof (gfxtest_function);
tests->this_test_mask = (int *)malloc(sizeof (ast_mask_list));
tests->this_test_mesg = (int *)malloc(sizeof (ast_mesg_list));
tests->this_test_function =
- (gfxtest_function *)malloc(sizeof (ast_test_list));
+ (gfxtest_function *)malloc(sizeof (ast_test_list));
- if ((tests->this_test_mask == NULL) ||
- (tests->this_test_mesg == NULL) ||
+ if ((tests->this_test_mask == NULL) ||
+ (tests->this_test_mesg == NULL) ||
(tests->this_test_function == NULL)) {
- gfx_vts_free_tests(tests);
- return (GRAPHICS_ERR_MALLOC_FAIL);
+ gfx_vts_free_tests(tests);
+ return (GRAPHICS_ERR_MALLOC_FAIL);
}
tests->connection_test_function = ast_test_open;
@@ -302,7 +87,7 @@
memcpy(tests->this_test_mask, ast_mask_list, sizeof (ast_mask_list));
memcpy(tests->this_test_mesg, ast_mesg_list, sizeof (ast_mesg_list));
memcpy(tests->this_test_function, ast_test_list,
- sizeof (ast_test_list));
+ sizeof (ast_test_list));
tests_info = tests;
return (0);
@@ -311,169 +96,625 @@
int
-cleanup_tests(gfxtest_info *tests)
+cleanup_tests(
+ register gfxtest_info *const tests)
{
- TraceMessage(VTS_DEBUG, __func__, "call cleanup_tests\n");
+ TraceMessage(VTS_DEBUG, "cleanup_tests", "call cleanup_tests\n");
gfx_vts_free_tests(tests);
- if (need_screen_lock) {
- unlock_display(dpy);
- }
-
+ return (0);
} /* cleanup_tests() */
-/*
- * ast_test_open()
- *
- * This test will open the device, read and write some registers
- * after mmaping in the register and frame buffer spaces.
- */
-
-return_packet *
-ast_test_open(int fd)
+void
+ast_block_signals(
+ void)
{
- static return_packet rp;
- int rc = 0;
- struct vis_identifier vis_identifier;
-
- if (need_screen_lock) {
- lock_display(fd, &dpy);
- }
-
- /* setup */
- memset(&rp, 0, sizeof (return_packet));
-
- if (gfx_vts_check_fd(fd, &rp)) {
- return (&rp);
- }
-
- TraceMessage(VTS_TEST_STATUS, __func__, "check_fd passed.\n");
-
- /* vis identifier will do this */
- rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
-
- TraceMessage(VTS_TEST_STATUS, __func__, "rc = %d\n", rc);
-
- if (rc != 0) {
- gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
- return (&rp);
- }
-
- if (strncmp(vis_identifier.name, "SUNWast", 7) != 0) {
- gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
- return (&rp);
- }
-
- map_me(&rp, fd);
-
- TraceMessage(VTS_DEBUG, __func__, "Open completed OK\n");
-
- check4abort(dpy);
- return (&rp);
-
-} /* ast_test_open() */
-
-
-/*
- * ast_test_dma
- *
- * This test will open the device, allocate the dma buffers to
- * separate memory spaces, and read/write the data, verifying it.
- */
-
-return_packet *
-ast_test_dma(int fd)
-{
- static return_packet rp;
- int i;
-
- TraceMessage(VTS_DEBUG, __func__, "ast_test_dma running\n");
-
- if (need_screen_lock) {
- lock_display(fd, &dpy);
- }
+ sigset_t newprocmask;
- dma_test(&rp, fd);
-
- TraceMessage(VTS_DEBUG, __func__, " ast_test_dma completed\n");
-
- check4abort(dpy);
- return (&rp);
-
-} /* ast_test_dma() */
-
-
-/*
- * ast_test_memory()
- *
- * This test will open the device and read and write to all memory
- * addresses.
- */
-
-return_packet *
-ast_test_memory(int fd)
-{
- static return_packet rp;
-
- TraceMessage(VTS_DEBUG, __func__, " ast_test_memory running\n");
-
- if (gfx_vts_debug_mask & GRAPHICS_VTS_MEM_OFF) {
- return (&rp);
- }
-
- if (need_screen_lock) {
- lock_display(fd, &dpy);
- }
-
- memory_test(&rp, fd);
+ sigemptyset(&newprocmask);
+ sigaddset(&newprocmask, SIGHUP);
+ sigaddset(&newprocmask, SIGINT);
+ sigaddset(&newprocmask, SIGTERM);
+ sigaddset(&newprocmask, SIGALRM);
- TraceMessage(VTS_DEBUG, __func__, " ast_test_memory completed\n");
-
- check4abort(dpy);
- return (&rp);
-
-} /* ast_test_memory() */
-
-
-/*
- * ast_test_chip()
- *
- * Test Chip, functional tests.
- */
-
-return_packet *
-ast_test_chip(int fd)
-{
- static return_packet rp;
-
- if (gfx_vts_debug_mask & GRAPHICS_VTS_CHIP_OFF) {
- return (&rp);
- }
- TraceMessage(VTS_DEBUG, __func__, " ast_test_chip running\n");
-
- if (need_screen_lock) {
- lock_display(fd, &dpy);
- }
-
- chip_test(&rp, fd);
-
- TraceMessage(VTS_DEBUG, __func__, " ast_test_chip completed\n");
-
- check4abort(dpy);
- return (&rp);
-
-} /* ast_test_chip() */
+ sigprocmask(SIG_BLOCK, &newprocmask, &ast_xw.xw_procmask);
+}
void
-graphicstest_finish(int flag)
+ast_restore_signals(
+ void)
+{
+ sigprocmask(SIG_SETMASK, &ast_xw.xw_procmask, (sigset_t *)NULL);
+}
+
+
+int
+ast_lock_display(
+ void)
+{
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_SLOCK_OFF) {
+ TraceMessage(VTS_DEBUG, "ast_lock_display",
+ "ast_lock_display() DISABLED\n");
+ return (0);
+ }
+
+ if (!ast_open_display()) {
+ return (0);
+ }
+
+ ast_create_cursor();
+
+ ast_create_window();
+
+ XMapRaised(ast_xw.xw_display, ast_xw.xw_window);
+
+ TraceMessage(VTS_DEBUG, "ast_lock_display",
+ "XMapRaised(display, 0x%lx)\n",
+ (ulong_t)ast_xw.xw_window);
+
+ /* Disable server from handling any requests */
+ ast_grab_server();
+
+ /* Gain control of keyboard */
+ ast_grab_keyboard();
+
+ /* Gain control of pointer */
+ ast_grab_pointer();
+
+ ast_disable_screensaver();
+
+ ast_disable_dpms();
+
+ XSync(ast_xw.xw_display, False);
+
+ return (1);
+
+} /* ast_lock_display() */
+
+
+int
+ast_unlock_display(
+ void)
+{
+ if (ast_xw.xw_display == NULL)
+ return (0);
+
+ XUnmapWindow(ast_xw.xw_display, ast_xw.xw_window);
+
+ TraceMessage(VTS_DEBUG, "ast_unlock_display",
+ "XUnmapWindow(display, 0x%lx)\n",
+ (ulong_t)ast_xw.xw_window);
+
+ ast_restore_dpms();
+
+ ast_restore_screensaver();
+
+ ast_ungrab_pointer();
+
+ ast_ungrab_keyboard();
+
+ ast_ungrab_server();
+
+ XSync(ast_xw.xw_display, False);
+
+ ast_check_for_interrupt();
+
+ return (1);
+}
+
+
+int
+ast_open_display(
+ void)
+{
+ if (ast_xw.xw_dispname == NULL)
+ ast_xw.xw_dispname = ":0.0";
+
+ if (ast_xw.xw_display == NULL) {
+ ast_xw.xw_display = XOpenDisplay(ast_xw.xw_dispname);
+
+ if (ast_xw.xw_display == NULL) {
+ TraceMessage(VTS_DEBUG, "ast_open_display",
+ "XOpenDisplay(\"%s\") = NULL\n"
+ "Assuming no window system.\n",
+ ast_xw.xw_dispname);
+
+ return (0);
+ }
+
+ TraceMessage(VTS_DEBUG, "ast_open_display",
+ "XOpenDisplay(\"%s\") = 0x%p\n"
+ "Assuming a window system.\n",
+ ast_xw.xw_dispname, ast_xw.xw_display);
+ }
+
+ /* Tell server to report events as they occur */
+ XSynchronize(ast_xw.xw_display, True);
+
+ TraceMessage(VTS_DEBUG, "ast_open_display",
+ "XSynchronize(display, True).\n");
+
+ return (1);
+}
+
+
+int
+ast_create_cursor(
+ void)
+{
+ register Window const root = RootWindow(ast_xw.xw_display,
+ ast_xw.xw_screen);
+ register Pixmap emptypixmap;
+ XColor dummy_color = {0, 0, 0, 0, 0, 0};
+
+ if (ast_xw.xw_cursor != 0)
+ return (0);
+
+ emptypixmap = XCreateBitmapFromData(ast_xw.xw_display, root, "", 1, 1);
+
+ ast_xw.xw_cursor = XCreatePixmapCursor(ast_xw.xw_display,
+ emptypixmap, emptypixmap, &dummy_color, &dummy_color, 0, 0);
+
+ TraceMessage(VTS_DEBUG, "ast_create_cursor",
+ "XCreatePixmapCursor(display, 0x%lx, 0x%lx, &dummy_color, "
+ "&dummy_color, 0, 0) = 0x%lx\n",
+ (ulong_t)emptypixmap, (ulong_t)emptypixmap,
+ (ulong_t)ast_xw.xw_cursor);
+
+ XFreePixmap(ast_xw.xw_display, emptypixmap);
+
+ return (1);
+}
+
+
+int
+ast_create_window(
+ void)
+{
+ register Window const root = RootWindow(ast_xw.xw_display,
+ ast_xw.xw_screen);
+ register int const width = DisplayWidth(ast_xw.xw_display,
+ ast_xw.xw_screen);
+ register int const height = DisplayHeight(ast_xw.xw_display,
+ ast_xw.xw_screen);
+ XSetWindowAttributes xswa;
+
+ if (ast_xw.xw_window != NULL)
+ return (0);
+
+ memset(&xswa, 0, sizeof (xswa));
+ xswa.cursor = ast_xw.xw_cursor;
+ xswa.background_pixmap = None;
+ xswa.override_redirect = True;
+ xswa.backing_store = NotUseful;
+ xswa.save_under = False;
+ xswa.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask;
+
+ ast_xw.xw_window = XCreateWindow(ast_xw.xw_display,
+ root, 0, 0, width, height,
+ 0, CopyFromParent, InputOutput, CopyFromParent,
+ CWBackPixmap | CWOverrideRedirect | CWBackingStore |
+ CWSaveUnder | CWEventMask | CWCursor, &xswa);
+
+ TraceMessage(VTS_DEBUG, "ast_create_window",
+ "XCreateWindow(display, 0x%lx, %d, %d, %d, %d, "
+ "%d, %d, %d, %d, 0x%lx, &xswa) = 0x%lx\n",
+ (ulong_t)root, 0, 0, width, height,
+ 0, CopyFromParent, InputOutput, CopyFromParent,
+ (ulong_t)(CWBackPixmap | CWOverrideRedirect |
+ CWBackingStore | CWSaveUnder | CWEventMask | CWCursor),
+ (ulong_t)ast_xw.xw_window);
+
+ XStoreName(ast_xw.xw_display, ast_xw.xw_window, "libvtsSUNWast");
+
+ return (1);
+}
+
+
+int
+ast_grab_server(
+ void)
+{
+ if (ast_xw.xw_grab_server == True)
+ return (0);
+
+ ast_xw.xw_grab_server = XGrabServer(ast_xw.xw_display);
+
+ TraceMessage(VTS_DEBUG, "ast_grab_server",
+ "XGrabServer(display)\n");
+
+ return (1);
+}
+
+
+int
+ast_ungrab_server(
+ void)
+{
+ if (ast_xw.xw_grab_server != True)
+ return (0);
+
+ ast_xw.xw_grab_server = !XUngrabServer(ast_xw.xw_display);
+
+ TraceMessage(VTS_DEBUG, "ast_ungrab_server",
+ "XUngrabServer(display)\n");
+
+ return (1);
+}
+
+
+int
+ast_grab_keyboard(
+ void)
+{
+ register int status;
+
+ if (ast_xw.xw_grab_keyboard == True)
+ return (0);
+
+ status = XGrabKeyboard(ast_xw.xw_display, ast_xw.xw_window,
+ False, GrabModeAsync, GrabModeAsync, CurrentTime);
+ ast_xw.xw_grab_keyboard = status == GrabSuccess;
+
+ TraceMessage(VTS_DEBUG, "ast_grab_keyboard",
+ "XGrabKeyboard(display, 0x%lx, %d, %d, %d, %ld) = %d\n",
+ (ulong_t)ast_xw.xw_window,
+ False, GrabModeAsync, GrabModeAsync, CurrentTime,
+ status);
+
+ if (status != GrabSuccess) {
+ TraceMessage(VTS_DEBUG, "ast_grab_keyboard",
+ "Cannot gain control of keyboard\n");
+ return (-1);
+
+ } else {
+ return (1);
+ }
+}
+
+
+int
+ast_ungrab_keyboard(
+ void)
+{
+ register int status;
+
+ if (ast_xw.xw_grab_keyboard != True)
+ return (0);
+
+ status = XUngrabKeyboard(ast_xw.xw_display, CurrentTime);
+
+ ast_xw.xw_grab_keyboard = False;
+ TraceMessage(VTS_DEBUG, "ast_ungrab_keyboard",
+ "XGrabKeyboard(display, %ld) = %d\n",
+ CurrentTime, status);
+
+ return (1);
+}
+
+
+int
+ast_grab_pointer(
+ void)
+{
+ register int status;
+
+ if (ast_xw.xw_grab_pointer == True)
+ return (0);
+
+ status = XGrabPointer(ast_xw.xw_display, ast_xw.xw_window,
+ False, ResizeRedirectMask, GrabModeAsync, GrabModeAsync,
+ None, ast_xw.xw_cursor, CurrentTime);
+
+ ast_xw.xw_grab_pointer = status == GrabSuccess;
+
+ TraceMessage(VTS_DEBUG, "ast_grab_pointer",
+ "XGrabPointer(display, 0x%lx, %d, 0x%lx, %d, %d, "
+ "%d, %d, %ld) = %d\n",
+ (ulong_t)ast_xw.xw_window,
+ False, ResizeRedirectMask,
+ GrabModeAsync, GrabModeAsync,
+ None, None, CurrentTime,
+ status);
+
+ if (status != GrabSuccess) {
+ TraceMessage(VTS_DEBUG, "ast_grab_pointer",
+ "Cannot gain control of pointer\n");
+ return (-1);
+
+ } else {
+ return (1);
+ }
+}
+
+
+int
+ast_ungrab_pointer(
+ void)
+{
+ register int status;
+
+ if (ast_xw.xw_grab_pointer != True)
+ return (0);
+
+ status = XUngrabPointer(ast_xw.xw_display, CurrentTime);
+
+ ast_xw.xw_grab_pointer = False;
+
+ TraceMessage(VTS_DEBUG, "ast_ungrab_pointer",
+ "XGrabPointer(display, %ld) = %d\n",
+ CurrentTime, status);
+
+ return (1);
+}
+
+
+int
+ast_disable_screensaver(
+ void)
+{
+ XGetScreenSaver(ast_xw.xw_display,
+ &ast_xw.xw_ss_timeout,
+ &ast_xw.xw_ss_interval,
+ &ast_xw.xw_ss_prefer_blanking,
+ &ast_xw.xw_ss_allow_exposures);
+
+ ast_xw.xw_ss_saved = True;
+
+ TraceMessage(VTS_DEBUG, "ast_disable_screensaver",
+ "XGetScreenSaver(display) = %d, %d, %d, %d\n",
+ ast_xw.xw_ss_timeout,
+ ast_xw.xw_ss_interval,
+ ast_xw.xw_ss_prefer_blanking,
+ ast_xw.xw_ss_allow_exposures);
+
+ /* Reset the screen saver to reset its time. */
+
+ XResetScreenSaver(ast_xw.xw_display);
+
+ ast_xw.xw_ss_disabled = True;
+
+ XSetScreenSaver(ast_xw.xw_display,
+ DisableScreenSaver,
+ ast_xw.xw_ss_interval,
+ ast_xw.xw_ss_prefer_blanking,
+ ast_xw.xw_ss_allow_exposures);
+
+ TraceMessage(VTS_DEBUG, "ast_disable_screensaver",
+ "XSetScreenSaver(display, %d, %d, %d, %d)\n",
+ DisableScreenSaver,
+ ast_xw.xw_ss_interval,
+ ast_xw.xw_ss_prefer_blanking,
+ ast_xw.xw_ss_allow_exposures);
+
+ return (1);
+}
+
+
+int
+ast_restore_screensaver(
+ void)
+{
+ if (ast_xw.xw_ss_saved != True ||
+ ast_xw.xw_ss_disabled != True) {
+ ast_xw.xw_ss_disabled = False;
+ ast_xw.xw_ss_saved = False;
+ return (0);
+
+ } else {
+ XSetScreenSaver(ast_xw.xw_display,
+ ast_xw.xw_ss_timeout,
+ ast_xw.xw_ss_interval,
+ ast_xw.xw_ss_prefer_blanking,
+ ast_xw.xw_ss_allow_exposures);
+
+ ast_xw.xw_ss_disabled = False;
+
+ TraceMessage(VTS_DEBUG, "ast_restore_screensaver",
+ "XSetScreenSaver(display, %d, %d, %d, %d)\n",
+ ast_xw.xw_ss_timeout,
+ ast_xw.xw_ss_interval,
+ ast_xw.xw_ss_prefer_blanking,
+ ast_xw.xw_ss_allow_exposures);
+
+ ast_xw.xw_ss_saved = False;
+
+ return (1);
+ }
+}
+
+
+int
+ast_disable_dpms(
+ void)
+{
+ /* Disable the X Display Power Management Signaling. */
+
+ int status;
+ int dpms_error = 0;
+ int dpms_event = 0;
+
+ status = DPMSQueryExtension(ast_xw.xw_display,
+ &dpms_event, &dpms_error);
+
+ TraceMessage(VTS_DEBUG, "ast_disable_dpms",
+ "DPMSQueryExtension(display) = %d, %d, %d\n",
+ status,
+ dpms_event,
+ dpms_error);
+
+ if (status != True)
+ return (-1);
+
+ ast_xw.xw_dpms_saved = DPMSInfo(ast_xw.xw_display,
+ &ast_xw.xw_dpms_power, &ast_xw.xw_dpms_state);
+
+ TraceMessage(VTS_DEBUG, "ast_disable_dpms",
+ "DPMSInfo(display) = %d, %d, %d\n",
+ ast_xw.xw_dpms_saved,
+ ast_xw.xw_dpms_power,
+ ast_xw.xw_dpms_state);
+
+ if (ast_xw.xw_dpms_saved != True ||
+ ast_xw.xw_dpms_state != True)
+ return (0);
+
+ else {
+ ast_xw.xw_dpms_disabled = True;
+
+ DPMSDisable(ast_xw.xw_display);
+
+ TraceMessage(VTS_DEBUG, "ast_disable_dpms",
+ "DPMSDisable(display)\n");
+
+ return (1);
+ }
+}
+
+
+int
+ast_restore_dpms(
+ void)
+{
+ /* Restore the X Display Power Management Signaling. */
+
+ if (ast_xw.xw_dpms_saved != True ||
+ ast_xw.xw_dpms_disabled != True) {
+ ast_xw.xw_dpms_disabled = False;
+ ast_xw.xw_dpms_saved = False;
+ return (0);
+
+ } else {
+ DPMSEnable(ast_xw.xw_display);
+
+ ast_xw.xw_dpms_disabled = False;
+
+ TraceMessage(VTS_DEBUG, "ast_restore_dpms",
+ "DPMSEnable(display)\n");
+
+ ast_xw.xw_dpms_saved = False;
+ return (1);
+ }
+}
+
+
+int
+ast_sleep(
+ uint_t const seconds)
+{
+ register int signo;
+ struct sigaction oldhup;
+ struct sigaction oldint;
+ struct sigaction oldalrm;
+ struct sigaction oldterm;
+ struct sigaction newsigact;
+ sigset_t oldprocmask;
+
+ /*
+ * Allow a SIGHUP, SIGINT, SIGALRM, or SIGTERM to interrupt our
+ * sleep. These signals should already be masked from a
+ * call to ast_block_signals.
+ */
+
+ /* Save the current signals. */
+
+ sigaction(SIGHUP, NULL, &oldhup);
+ sigaction(SIGINT, NULL, &oldint);
+ sigaction(SIGALRM, NULL, &oldalrm);
+ sigaction(SIGTERM, NULL, &oldterm);
+
+ /* Setup up new signal action. */
+
+ newsigact.sa_handler = ast_signal_routine;
+ sigemptyset(&newsigact.sa_mask);
+ newsigact.sa_flags = 0;
+
+ signo = sigsetjmp(ast_xw.xw_sigjmpbuf, 1);
+ if (!signo) {
+ /* First time goes here. */
+
+ /* Set signal routines. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &newsigact, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &newsigact, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &newsigact, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &newsigact, NULL);
+
+ /* Unmask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &ast_xw.xw_procmask, &oldprocmask);
+
+ sleep(seconds);
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+ }
+
+ else {
+ /* We come here from the siglongjmp in ast_signal_routine. */
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+
+ /* Cause us to get the signal, when we unmask the signals. */
+ kill(getpid(), signo);
+ return (signo);
+ }
+
+ signo = ast_check_for_interrupt();
+ return (signo);
+}
+
+
+void
+ast_signal_routine(
+ register int const signo)
+{
+ siglongjmp(ast_xw.xw_sigjmpbuf, signo);
+}
+
+
+void
+graphicstest_finish(
+ register int const flag)
{
- TraceMessage(VTS_DEBUG, __func__, "call graphicstest_finish\n");
+ TraceMessage(VTS_DEBUG, "graphicstest_finish",
+ "call graphicstest_finish\n");
- TraceMessage(VTS_DEBUG, __func__, "call reset_memory_state\n");
+ TraceMessage(VTS_DEBUG, "graphicstest_finish",
+ "call reset_memory_state\n");
cleanup_tests(tests_info);
@@ -481,54 +722,50 @@
} /* graphicstest_finish() */
-
-/*
- * check4abort()
- *
- * This function sends a KILL signal to the program if it detects
- * that the user has pressed ^C. This functionality is usually
- * performed by the Command Tool which spawned a program, but in this
- * case we need to do it because we have grabbed all keyboard events.
- * It should be called anywhere where it's safe to end the program.
- */
-
-void
-check4abort(Display *dpy)
-{
-#define CTRL_C '\003' /* Ctrl-C (^C) */
-
- /*
- * If necessary, restore the original state following a test
- */
-#if !defined(VTS_STUBS)
- chip_test_reset();
-#endif
-
- if (dpy != NULL) {
-#if !defined(VTS_STUBS)
- while (XPending(dpy)) {
- XEvent event; /* Key event structure */
- int i; /* Loop counter / keystr[] index */
- char keystr[5] = ""; /* Buffer for returned string */
- int len; /* Length of returned string */
-
- XNextEvent(dpy, &event);
- if (event.type == KeyPress) {
- len = XLookupString((XKeyEvent *)&event,
- keystr, sizeof (keystr),
- NULL, NULL);
- for (i = 0; i < len; i++) {
- if (keystr[i] == CTRL_C) {
- kill(getpid(), SIGINT);
- graphicstest_finish(0);
- }
- }
- }
- }
-#endif /* VTS_STUBS */
- }
-
-} /* check4abort() */
+#define CTRL(x) ((x) & 0x1f)
+int
+ast_check_for_interrupt(
+ void)
+{
+ register size_t inputlength;
+ register size_t inputon;
+ register int ch;
+ struct sigaction oldint;
+ struct sigaction oldquit;
+ XEvent event;
+ char inputstring[16];
+
+ if (ast_xw.xw_display == NULL)
+ return (0);
+
+ while (XPending(ast_xw.xw_display)) {
+ XNextEvent(ast_xw.xw_display, &event);
+ if (event.type == KeyPress) {
+ inputlength = XLookupString(&event.xkey, inputstring,
+ sizeof (inputstring), NULL, NULL);
+ for (inputon = 0; inputon < inputlength; inputon++) {
+ ch = inputstring[inputon];
+
+ if (ch == CTRL('c')) {
+ sigaction(SIGINT, NULL, &oldint);
+ if (oldint.sa_handler != SIG_IGN) {
+ kill(getpid(), SIGINT);
+ return (SIGINT);
+ }
+
+ } else if (ch == CTRL('\\')) {
+ sigaction(SIGQUIT, NULL, &oldquit);
+ if (oldquit.sa_handler != SIG_IGN) {
+ kill(getpid(), SIGQUIT);
+ return (SIGQUIT);
+ }
+ }
+ }
+ }
+ }
+ return (0);
+}
+
/* End of libvtsSUNWast.c */
--- a/open-src/app/gfx-utils/sun-src/vts/ast/libvtsSUNWast.h Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/libvtsSUNWast.h Mon Sep 16 15:54:13 2013 -0700
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,36 +21,368 @@
* DEALINGS IN THE SOFTWARE.
*/
-
#ifndef _LIBVTSSUNWAST_H
#define _LIBVTSSUNWAST_H
-
+#include <sys/types.h>
+#include <sys/param.h> /* MAXPATHLEN */
+#include <errno.h>
+#include <memory.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <setjmp.h>
+#include <stropts.h> /* ioctl() */
+#include <sys/fbio.h>
+#include <sys/mman.h>
+#include <sys/systeminfo.h> /* sysinfo() */
+#include <sys/pci.h>
+#include <sys/time.h>
+#include <sys/visual_io.h>
+#include <X11/Xmd.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/extensions/dpms.h>
#include "libvtsSUNWxfb.h" /* Common VTS library definitions */
+#undef Status
+#define Status pciStatus
+#include "gfx_common.h"
+#undef Status
+#define Status int
+#include "graphicstest.h"
+#include "gfx_vts.h"
+
#include "astio.h"
+#include "ast.h"
+
+#define VIS_TEXT 0 /* Use text mode when displaying data */
+#define VIS_PIXEL 1 /* Use pixel mode when displaying data */
+
+typedef struct ast_info {
+ char const *ast_name;
+ int ast_fd;
+ uint16_t ast_vendor;
+ uint16_t ast_device;
+ offset_t ast_fb_addr;
+ size_t ast_fb_size;
+ uchar_t *ast_fb_ptr;
+ offset_t ast_mmio_addr;
+ size_t ast_mmio_size;
+ uchar_t *ast_mmio_ptr;
+ offset_t ast_relocate_io;
+ int ast_endian;
+ uchar_t ast_pcicr2;
+ uint_t ast_remap_base;
+ uint_t ast_prot_key;
+ uchar_t ast_misc_control;
+ uint_t ast_mode;
+ uint_t ast_width;
+ uint_t ast_height;
+ uint_t ast_depth;
+ uint_t ast_pixelsize;
+ uint_t ast_linesize;
+ int ast_palet_changed;
+ uchar_t ast_red[256];
+ uchar_t ast_green[256];
+ uchar_t ast_blue[256];
+ uint_t ast_queue;
+ uint_t ast_dst_base;
+ uint_t ast_dst_pitch;
+ uint_t ast_dst_xy;
+ uint_t ast_line_err;
+ uint_t ast_rect_xy;
+ uint_t ast_fg;
+ uint_t ast_bg;
+ uint_t ast_mono1;
+ uint_t ast_mono2;
+ uint_t ast_clip1;
+ uint_t ast_clip2;
+ } ast_info_t;
+
+
+typedef struct ast_xw_struct {
+ sigset_t xw_procmask;
+ sigjmp_buf xw_sigjmpbuf;
+ char const *xw_dispname;
+ Display *xw_display;
+ int xw_screen;
+ Window xw_window;
+ Cursor xw_cursor;
+ Bool xw_grab_server;
+ Bool xw_grab_keyboard;
+ Bool xw_grab_pointer;
+ Bool xw_ss_saved;
+ Bool xw_ss_disabled;
+ int xw_ss_timeout;
+ int xw_ss_interval;
+ int xw_ss_prefer_blanking;
+ int xw_ss_allow_exposures;
+ Status xw_dpms_saved;
+ CARD16 xw_dpms_power;
+ BOOL xw_dpms_state;
+ Bool xw_dpms_disabled;
+ } ast_xw_t;
-/* Test Open, initialization & read back; basic ability to talk to device */
-return_packet *ast_test_open(int fd);
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* chip.c */
+
+extern return_packet *ast_test_chip(
+ int const fd);
+
+extern int chip_test(
+ return_packet *const rp,
+ int const fd);
+
+extern int draw_lines(
+ uint_t const width,
+ uint_t const height);
+
+extern int draw_cascaded_box(
+ uint_t const width,
+ uint_t const height);
+
+/* dma.c */
+
+extern return_packet *ast_test_dma(
+ register int const fd);
+
+extern int dma_test(
+ return_packet *const rp,
+ int const fd);
+
+/* mapper.c */
+
+extern return_packet *ast_test_open(
+ int const fd);
+
+extern int map_me(
+ return_packet *const rp,
+ int const fd);
+
+extern int ast_test_scratch(
+ return_packet *const rp,
+ int const test);
+
+/* memory.c */
+
+extern return_packet *ast_test_memory(
+ int const fd);
+
+extern int memory_test(
+ return_packet *const rp,
+ int const fd);
+
+extern void check_plane(
+ int const num_planes,
+ int const access_mode,
+ int const fb_pitch,
+ int const fb_height,
+ int const fb_width,
+ int const bytepp,
+ caddr_t const base);
-/* Test DMA, read/write via dma, memory and, chip tests will use DMA */
-return_packet *ast_test_dma(int fd);
+extern void init_data(
+ int const num_planes);
+
+extern uint_t test_data(
+ void);
+
+extern boolean_t write_read(
+ int const xoff,
+ int const yoff,
+ boolean_t const complement,
+ int const access_mode,
+ boolean_t const pass,
+ int const fb_pitch,
+ int const bytepp,
+ caddr_t const base);
+
+/* tools.c */
+
+extern int ast_map_mem(
+ return_packet *const rp,
+ int const test);
+
+extern int ast_get_pci_info(
+ void);
+
+extern int ast_map_mmio(
+ void);
+
+extern int ast_map_fb(
+ void);
-/* Test Memory, various address, data, and, random patterns */
-return_packet *ast_test_memory(int fd);
+extern int ast_init_info(
+ return_packet *const rp,
+ int const test);
+
+extern int ast_init_graphics(
+ void);
+
+extern int ast_finish_graphics(
+ void);
+
+extern int ast_save_palet(
+ void);
+
+extern int ast_set_palet(
+ void);
+
+extern int ast_restore_palet(
+ void);
+
+extern uint_t ast_color(
+ uint_t const red,
+ uint_t const green,
+ uint_t const blue);
+
+extern int ast_open_key(
+ void);
+
+extern int ast_fill_solid_rect(
+ uint_t const x1,
+ uint_t const y1,
+ uint_t const x2,
+ uint_t const y2,
+ uint_t const fg);
-/* Test Chip, functional tests */
-return_packet *ast_test_chip(int fd);
+extern int ast_fill_pattern_rect(
+ uint_t const x1,
+ uint_t const y1,
+ uint_t const x2,
+ uint_t const y2,
+ uint_t const bg,
+ uint_t const fg,
+ uint64_t const pat);
+
+extern int ast_draw_solid_line(
+ uint_t const x1,
+ uint_t const y1,
+ uint_t const x2,
+ uint_t const y2,
+ uint_t const fg);
+
+extern int ast_unmap_mem(
+ return_packet *const rp,
+ int const test);
+
+extern int ast_unmap_fb(
+ void);
+
+extern int ast_unmap_mmio(
+ void);
+
+extern int ast_store_mmio(
+ uint_t const port,
+ uint_t const value);
+
+extern int ast_get_index_reg(
+ uchar_t *const valueptr,
+ uchar_t const offset,
+ uchar_t const index);
+
+extern int ast_set_index_reg(
+ uchar_t const offset,
+ uchar_t const index,
+ uchar_t const value);
+
+extern int ast_get_reg(
+ uchar_t *const valueptr,
+ uchar_t const offset);
+
+extern int ast_set_reg(
+ uchar_t const offset,
+ uchar_t const value);
+
+extern uint_t ast_mmio_read32(
+ uint_t const port);
+
+extern void ast_mmio_write32(
+ uint_t const port,
+ uint_t const val);
+
+extern int ast_wait_idle(
+ void);
+
+/* libvtsSUNWast.c */
+
+extern ast_info_t ast_info;
+
+extern ast_xw_t ast_xw;
-void check4abort();
-int get_processHandle(int, void **);
+extern void ast_block_signals(
+ void);
+
+extern void ast_restore_signals(
+ void);
+
+extern int ast_lock_display(
+ void);
+
+extern int ast_unlock_display(
+ void);
+
+extern int ast_open_display(
+ void);
+
+extern int ast_create_cursor(
+ void);
+
+extern int ast_create_window(
+ void);
+
+extern int ast_grab_server(
+ void);
+
+extern int ast_ungrab_server(
+ void);
+
+extern int ast_grab_keyboard(
+ void);
+
+extern int ast_ungrab_keyboard(
+ void);
-extern int backup_clut_init;
-extern struct fbcmap backup_clut;
-extern int myfd;
+extern int ast_grab_pointer(
+ void);
+
+extern int ast_ungrab_pointer(
+ void);
+
+extern int ast_disable_screensaver(
+ void);
+
+extern int ast_restore_screensaver(
+ void);
+
+extern int ast_disable_dpms(
+ void);
+extern int ast_restore_dpms(
+ void);
+
+extern int ast_sleep(
+ uint_t const seconds);
+
+extern void ast_signal_routine(
+ int const signo);
+
+extern int ast_check_for_interrupt(
+ void);
+
+extern void graphicstest_finish(
+ int const flag);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _LIBVTSSUNWAST_H */
-
/* End of libvtsSUNWast.h */
--- a/open-src/app/gfx-utils/sun-src/vts/ast/mapfile Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/mapfile Mon Sep 16 15:54:13 2013 -0700
@@ -1,7 +1,46 @@
-SUNW_1.1 {
- global:
- get_tests;
- cleanup_tests;
- local:
- *;
+#
+# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION SUNW_1.1 {
+ global:
+ get_tests;
+ cleanup_tests;
+ local:
+ *;
};
--- a/open-src/app/gfx-utils/sun-src/vts/ast/mapper.c Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/mapper.c Mon Sep 16 15:54:13 2013 -0700
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,86 +21,138 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/mman.h>
+#include "libvtsSUNWast.h"
+
+
+/*
+ * ast_test_open()
+ *
+ * This test will open the device, read and write some registers
+ * after mmaping in the register and frame buffer spaces.
+ */
+
+return_packet *
+ast_test_open(
+ register int const fd)
+{
+ static return_packet rp;
+ int rc = 0;
+ struct vis_identifier vis_identifier;
+
+ memset(&rp, 0, sizeof (return_packet));
+
+ if (gfx_vts_check_fd(fd, &rp))
+ return (&rp);
+
+ TraceMessage(VTS_TEST_STATUS, "ast_test_open", "check_fd passed.\n");
+
+ /* vis identifier will do this */
+ rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
-#include "gfx_common.h" /* GFX Common definitions */
-#include "graphicstest.h"
-#include "libvtsSUNWast.h" /* Common VTS library definitions */
+ TraceMessage(VTS_TEST_STATUS, "ast_test_open", "rc = %d\n", rc);
+
+ if (rc != 0) {
+ gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
+ return (&rp);
+ }
+
+ if (strncmp(vis_identifier.name, "SUNWast", 7) != 0 &&
+ strncmp(vis_identifier.name, "ORCLast", 7) != 0) {
+ gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
+ return (&rp);
+ }
-#include "X11/Xlib.h"
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-#include "ast.h"
+ ast_block_signals();
+
+ ast_lock_display();
+
+ map_me(&rp, fd);
+
+ ast_unlock_display();
+
+ ast_restore_signals();
+
+ TraceMessage(VTS_DEBUG, "ast_test_open", "Open completed OK\n");
+
+ return (&rp);
+
+} /* ast_test_open() */
/*
* map_me()
*/
-void
-map_me(return_packet *rp, int fd)
+int
+map_me(
+ register return_packet *const rp,
+ register int const fd)
{
- struct ast_info ast_info;
- struct ast_info *pAST;
unsigned int value, chipType;
-
- pAST = &ast_info;
- pAST->fd = fd;
+ memset(&ast_info, 0, sizeof (ast_info));
+ ast_info.ast_fd = fd;
/*
* map the registers & frame buffers memory
*/
- if (ast_map_mem(pAST, rp, GRAPHICS_ERR_OPEN) == -1) {
- return;
- }
+ if (ast_map_mem(rp, GRAPHICS_ERR_OPEN) != 0)
+ return (-1);
- if (ast_init_info(pAST) == -1) {
- return;
- }
-
- /*
- * 32 bits support only for now
- */
- if (pAST->bytesPerPixel == 1) {
- goto done;
+ if (ast_test_scratch(rp, GRAPHICS_ERR_OPEN) != 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
+ return (-1);
}
-
- /*
- * Write some registers
- */
- pAST->write32(pAST->MMIOvaddr + 0xF004, 0x1e6e0000);
- value = pAST->read32(pAST->MMIOvaddr + 0xF004);
- if (value != 0x1e6e0000) {
- gfx_vts_set_message(rp, 1, GRAPHICS_ERR_OPEN, "write/read registers failed");
- return;
- }
+ value = ast_mmio_read32(0x1207c);
+ chipType = value & 0x0300;
+ TraceMessage(VTS_DEBUG, "ast_test_chip",
+ "chip type 0x%x\n", chipType);
- pAST->write32(pAST->MMIOvaddr + 0xF000, 0x1);
- value = pAST->read32(pAST->MMIOvaddr + 0xF000);
- if (value != 0x1) {
- gfx_vts_set_message(rp, 1, GRAPHICS_ERR_OPEN, "write/read registers failed");
- return;
- }
-
-
- value = pAST->read32(pAST->MMIOvaddr + 0x1207c);
- chipType = value & 0x0300;
-#if DEBUG
- printf("chipType = 0x%x\n", chipType);
-#endif
-
-
-done:
/*
* Unmap the registers & frame buffers memory
*/
- if (ast_unmap_mem(pAST, rp, GRAPHICS_ERR_OPEN) == -1) {
- return;
- }
+ if (ast_unmap_mem(rp, GRAPHICS_ERR_OPEN) != 0)
+ return (-1);
+ return (0);
} /* map_me() */
+int
+ast_test_scratch(
+ register return_packet *const rp,
+ register int const test)
+{
+ uchar_t scratch;
+ uchar_t newscratch;
+
+ if (ast_get_index_reg(&scratch, CRTC_PORT, 0x90) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get scratch");
+ return (-1);
+ }
+
+ if (ast_set_index_reg(CRTC_PORT, 0x90, scratch ^ 0x33) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to set scratch");
+ return (-1);
+ }
+
+ if (ast_get_index_reg(&newscratch, CRTC_PORT, 0x90) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get newscratch");
+ return (-1);
+ }
+
+ if ((scratch ^ 0x33) != newscratch) {
+ gfx_vts_set_message(rp, 1, test, "scratch mismatch");
+ return (-1);
+ }
+
+ if (ast_set_index_reg(CRTC_PORT, 0x90, scratch) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to set scratch");
+ return (-1);
+ }
+
+ return (1);
+}
+
+
/* End of mapper.c */
--- a/open-src/app/gfx-utils/sun-src/vts/ast/memory.c Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/memory.c Mon Sep 16 15:54:13 2013 -0700
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,20 +21,7 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <errno.h> /* errno */
-#include <stdio.h>
-#include <string.h> /* strerror() */
-#include <stropts.h> /* ioctl() */
-#include <unistd.h> /* ioctl() */
-#include <sys/mman.h>
-#include <stdlib.h>
-
-#include "gfx_common.h"
-#include "graphicstest.h"
-#include "libvtsSUNWxfb.h" /* Common VTS library definitions */
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-#include "ast.h"
+#include "libvtsSUNWast.h" /* Common VTS library definitions */
typedef union MemType {
uint64_t val[8];
@@ -47,306 +33,401 @@
static const int access_mode[] = {
1, 2, 4, 8, 0
};
-static const char *const access_tname[] = {
- "\tverifying byte access mode...",
- "\tverifying short access mode...",
- "\tverifying word access mode...",
- "\tverifying long long access mode...",
-};
+
+static MemType data[32 * 8];
+static MemType cdata[32 * 8];
+static MemType rdval[4];
-void
-Write8(void *addr, uint8_t data) {
- *(uint8_t *)addr = data;
-}
+/*
+ * ast_test_memory()
+ *
+ * This test will open the device and read and write to all memory
+ * addresses.
+ */
-void
-Write16(void *addr, uint16_t data) {
- *(uint16_t *)addr = data;
-}
+return_packet *
+ast_test_memory(
+ register int const fd)
+{
+ static return_packet rp;
-void
-Write32(void *addr, uint32_t data) {
- *(uint32_t *)addr = data;
-}
+ memset(&rp, 0, sizeof (return_packet));
-void
-Write64(void *addr, uint64_t data) {
- *(uint64_t *)addr = data;
-}
+ if (gfx_vts_debug_mask & GRAPHICS_VTS_MEM_OFF)
+ return (&rp);
-uint8_t
-read8(void *addr) {
- return (*(uint8_t *)addr);
-}
+ TraceMessage(VTS_DEBUG, "ast_test_memory",
+ "ast_test_memory running\n");
+
+ ast_block_signals();
+
+ ast_lock_display();
-uint16_t
-read16(void *addr) {
- return (*(uint16_t *)addr);
-}
+ memory_test(&rp, fd);
+
+ ast_unlock_display();
+
+ ast_restore_signals();
-uint32_t
-read32(void *addr) {
- return (*(uint32_t *)addr);
-}
+ TraceMessage(VTS_DEBUG, "ast_test_memory",
+ "ast_test_memory completed\n");
-uint64_t
-read64(void *addr) {
- return (*(uint64_t *)addr);
-}
+ return (&rp);
+} /* ast_test_memory() */
-u_int
-test_data() {
- u_int ret;
+int
+memory_test(
+ register return_packet *const rp,
+ register int const fd)
+{
+ register size_t i;
+ register int signo;
+ struct sigaction oldhup;
+ struct sigaction oldint;
+ struct sigaction oldalrm;
+ struct sigaction oldterm;
+ struct sigaction newsigact;
+ sigset_t oldprocmask;
+
+ memset(&ast_info, 0, sizeof (ast_info));
+ ast_info.ast_fd = fd;
+
+ if (ast_map_mem(rp, GRAPHICS_ERR_MEMORY_MSG) != 0)
+ return (-1);
+
+ if (ast_init_info(rp, GRAPHICS_ERR_MEMORY_MSG) != 0) {
+ ast_unmap_mem(NULL, GRAPHICS_ERR_MEMORY_MSG);
+ return (-1);
+ }
+
+ ast_save_palet();
+ ast_set_palet();
+
+ /*
+ * Allow a SIGHUP, SIGINT, SIGALRM, or SIGTERM to interrupt our
+ * memory_test. These signals should already be masked from a
+ * call to ast_block_signals.
+ */
+
+ /* Save the current signals. */
+
+ sigaction(SIGHUP, NULL, &oldhup);
+ sigaction(SIGINT, NULL, &oldint);
+ sigaction(SIGALRM, NULL, &oldalrm);
+ sigaction(SIGTERM, NULL, &oldterm);
+
+ /* Setup up new signal action. */
+
+ newsigact.sa_handler = ast_signal_routine;
+ sigemptyset(&newsigact.sa_mask);
+ newsigact.sa_flags = 0;
+
+ signo = sigsetjmp(ast_xw.xw_sigjmpbuf, 1);
+ if (!signo) {
+ /* First time goes here. */
+
+ /* Set signal routines. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &newsigact, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &newsigact, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &newsigact, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &newsigact, NULL);
- ret = (u_int)mrand48();
- return (ret);
+ for (i = 0; access_mode[i] != 0; i++) {
+ /* Unmask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &ast_xw.xw_procmask,
+ &oldprocmask);
+
+ check_plane(ast_info.ast_depth, access_mode[i],
+ ast_info.ast_linesize / ast_info.ast_pixelsize,
+ ast_info.ast_height,
+ ast_info.ast_width, ast_info.ast_pixelsize,
+ (caddr_t)ast_info.ast_fb_ptr);
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ signo = ast_check_for_interrupt();
+ if (signo != 0)
+ break;
+ }
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+ }
+
+ else {
+ /* We come here from the siglongjmp in ast_signal_routine. */
+
+ /* Mask SIGHUP, SIGINT, SIGALRM, SIGTERM. */
+
+ sigprocmask(SIG_SETMASK, &oldprocmask, NULL);
+
+ /* Restore the signals. */
+
+ if (oldhup.sa_handler != SIG_IGN)
+ sigaction(SIGHUP, &oldhup, NULL);
+ if (oldint.sa_handler != SIG_IGN)
+ sigaction(SIGINT, &oldint, NULL);
+ if (oldalrm.sa_handler != SIG_IGN)
+ sigaction(SIGALRM, &oldalrm, NULL);
+ if (oldterm.sa_handler != SIG_IGN)
+ sigaction(SIGTERM, &oldterm, NULL);
+
+ /* Cause us to get the signal, when we unmask the signals. */
+
+ kill(getpid(), signo);
+ }
+
+ ast_restore_palet();
+
+ if (ast_unmap_mem(rp, GRAPHICS_ERR_MEMORY_MSG) != 0)
+ return (-1);
+
+ return (0);
}
-MemType *data;
-MemType *cdata;
-
void
-plane_change(int num_planes_, caddr_t base_, int sh, int sw)
+check_plane(
+ register int const num_planes,
+ register int const access_mode,
+ register int const fb_pitch,
+ register int const fb_height,
+ register int const fb_width,
+ register int const bytepp,
+ register caddr_t const base)
{
- int num_planes = num_planes_;
- caddr_t base = base_;
- int i;
- int j;
+ register int x;
+ register int y;
+ register int complement;
+
+ /* Set up raster for this plane group */
+
+ init_data(num_planes);
+
+ /* Cover each 64x64 chunk of screen space */
+
+ y = 0;
+ while (y < fb_height) {
+ x = 0;
+ while (x < fb_width) {
+ if (x + 63 > fb_width)
+ x = fb_width - 64;
+ if (y + 63 > fb_height)
+ y = fb_height - 64;
+
+ /* Do each chunk twice - once normal, once complement */
- int pix_per_write, old_pix_per_write;
+ for (complement = B_FALSE;
+ complement <= B_TRUE;
+ complement++) {
+ write_read(x, y,
+ (boolean_t)complement,
+ access_mode,
+ B_TRUE,
+ fb_pitch,
+ bytepp,
+ base) ||
+ write_read(x, y,
+ (boolean_t)complement,
+ access_mode,
+ B_FALSE,
+ fb_pitch,
+ bytepp,
+ base);
+ }
+
+ /* Move over one 64x64 chunk */
+
+ x += 64;
+ }
+
+ /* Move down one 64x64 chunk */
+
+ y += 64;
+ }
+}
+
+
+void
+init_data(
+ register int const num_planes)
+{
+ register int i;
+ register int j;
/* Get memory to store data */
- int memcount = num_planes * 8;
+ /* Write data to memory */
- if (data) free(data);
- if (cdata) free(cdata);
+ for (i = 0; i < num_planes * 8; i++) {
+ for (j = 0; j < 8; j++) {
- data = (MemType *)memalign(64, memcount * sizeof (MemType));
- cdata = (MemType *)memalign(64, memcount * sizeof (MemType));
+ /* Figure out the value to write */
- /* Write data to memory */
- for (i = 0; i < memcount; i++) {
- for (j = 0; j < 8; j++) {
- /* Figure out the value to write */
- data[i].val[j] = ((unsigned long long)test_data() << 32)
- | test_data();
- cdata[i].val[j] = ~data[i].val[j];
- }
+ data[i].val[j] = ((unsigned long long)
+ test_data() << 32) | test_data();
+ cdata[i].val[j] = ~data[i].val[j];
+ }
}
+}
-} /* plane_change() */
+
+
+uint_t
+test_data(
+ void)
+{
+ register uint_t ret;
+
+ ret = (uint_t)mrand48();
+ return (ret);
+}
boolean_t
-write_read(int xoff, int yoff, boolean_t complement, int access_mode,
- boolean_t pass, int fb_pitch, int bytepp, caddr_t base)
+write_read(
+ register int const xoff,
+ register int const yoff,
+ register boolean_t const complement,
+ register int const access_mode,
+ register boolean_t const pass,
+ register int const fb_pitch,
+ register int const bytepp,
+ register caddr_t const base)
{
- MemType *dp;
- int pitch = fb_pitch;
- int x;
- int y;
- int i;
- caddr_t mem_addr;
- caddr_t dp_addr;
- u_int second_rdval;
- MemType *rdval;
- int subscr = 0;
-
- if (complement) {
- dp = cdata;
- } else {
- dp = data;
- }
+ register MemType *const dp = complement ? cdata : data;
+ register int const pitch = fb_pitch;
+ register int x;
+ register int y;
+ register int i;
+ register caddr_t mem_addr;
+ register int subscr = 0;
/* Write Data to Screen */
+
for (y = yoff; y < yoff + 64; y++) {
- for (x = xoff * bytepp, i = 0;
- x < ((xoff + 64) *bytepp);
- x += access_mode, i++) {
- mem_addr = (y*pitch*bytepp) + x + base;
- /* Check which access mode to use for write */
- switch (access_mode) {
- case 8: /* long long (8-byte) access mode */
- Write64(mem_addr, dp[subscr].val[i]);
- break;
- case 4: /* word (4-byte) access mode */
- Write32(mem_addr, dp[subscr].word[i]);
- break;
- case 2: /* short (2-byte) access mode */
- Write16(mem_addr, dp[subscr].halfwd[i]);
- break;
- default: /* default to byte access */
- Write8(mem_addr, dp[subscr].byte[i]);
- break;
+ for (x = xoff * bytepp, i = 0;
+ x < ((xoff + 64) * bytepp);
+ x += access_mode, i++) {
+ mem_addr = (y * pitch * bytepp) + x + base;
+
+ /* Check which access mode to use for write */
+
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ *(uint64_t volatile *)mem_addr =
+ dp[subscr].val[i];
+ break;
+
+ case 4: /* word (4-byte) access mode */
+ *(uint32_t volatile *)mem_addr =
+ dp[subscr].word[i];
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ *(uint16_t volatile *)mem_addr =
+ dp[subscr].halfwd[i];
+ break;
+
+ default: /* default to byte access */
+ *(uint8_t volatile *)mem_addr =
+ dp[subscr].byte[i];
+ break;
+ }
}
- }
- subscr++;
+ subscr++;
}
/* Read the Data From the Screen */
- rdval = (MemType *)memalign(64, (sizeof (MemType) * bytepp));
+ for (y = yoff; y < yoff + 64; y++) {
+ for (x = xoff * bytepp, i = 0;
+ x < ((xoff + 64) * bytepp);
+ x += access_mode, i++) {
+ mem_addr = (y * pitch * bytepp) + x + base;
- for (y = yoff; y < yoff + 64; y++) {
- for (x = xoff * bytepp, i = 0;
- x < ((xoff + 64) * bytepp);
- x += access_mode, i++) {
- mem_addr = (y*pitch*bytepp) + x + base;
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ rdval[0].val[i] =
+ *(uint64_t volatile const *)mem_addr;
+ break;
- switch (access_mode) {
- case 8: /* long long (8-byte) access mode */
- rdval->val[i] = read64(mem_addr);
- break;
- case 4: /* word (4-byte) access mode */
- rdval->word[i] = read32(mem_addr);
- break;
- case 2: /* short (2-byte) access mode */
- rdval->halfwd[i] = read16(mem_addr);
- break;
- default: /* default to byte access */
- rdval->byte[i] = read8(mem_addr);
- break;
+ case 4: /* word (4-byte) access mode */
+ rdval[0].word[i] =
+ *(uint32_t volatile const *)mem_addr;
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ rdval[0].halfwd[i] =
+ *(uint16_t volatile const *)mem_addr;
+ break;
+
+ default: /* default to byte access */
+ rdval[0].byte[i] =
+ *(uint8_t volatile const *)mem_addr;
+ break;
+ }
}
- }
/* TODO: verification */
- if (memcmp(rdval, dp[subscr].byte, 64 * bytepp) != 0) {
- switch (access_mode) {
- case 8: /* long long (8-byte) access mode */
- for (i = 0; i < (16 * bytepp); i++) {
- if (rdval->word[i] != dp[subscr].word[i]) {
- free(rdval);
- return (B_FALSE);
- }
- }
- break;
- case 4: /* word (4-byte) access mode */
- for (i = 0; i < (16 * bytepp); i++) {
- if (rdval->word[i] != dp[subscr].word[i]) {
- free(rdval);
- return (B_FALSE);
- }
+
+ if (memcmp(rdval, dp[subscr].byte, 64 * bytepp) != 0) {
+ switch (access_mode) {
+ case 8: /* long long (8-byte) access mode */
+ for (i = 0; i < (8 * bytepp); i++) {
+ if (rdval[0].val[i] !=
+ dp[subscr].val[i])
+ return (B_FALSE);
+ }
+ break;
+
+ case 4: /* word (4-byte) access mode */
+ for (i = 0; i < (16 * bytepp); i++) {
+ if (rdval[0].word[i] !=
+ dp[subscr].word[i])
+ return (B_FALSE);
+ }
+ break;
+
+ case 2: /* short (2-byte) access mode */
+ for (i = 0; i < (32 * bytepp); i++) {
+ if (rdval[0].halfwd[i] !=
+ dp[subscr].halfwd[i])
+ return (B_FALSE);
+ }
+ break;
+
+ default: /* default to byte access */
+ for (i = 0; i < (64 * bytepp); i++) {
+ if (rdval[0].byte[i] !=
+ dp[subscr].byte[i])
+ return (B_FALSE);
+ }
+ break;
}
- break;
- case 2: /* short (2-byte) access mode */
- for (i = 0; i < (32 * bytepp); i++) {
- if (rdval->halfwd[i] != dp[subscr].halfwd[i]) {
- free(rdval);
- return (B_FALSE);
- }
- }
- break;
- default: /* default to byte access */
- for (i = 0; i < (64 * bytepp); i++) {
- if (rdval->byte[i] != dp[subscr].byte[i]) {
- free(rdval);
- return (B_FALSE);
- }
- }
- break;
}
- }
- subscr ++;
+ subscr++;
}
return (B_TRUE);
-
-} /* write_read() */
-
-
-void
-check_plane(int num_planes, int access_mode, char *test_name,
- int fb_offset, int fb_pitch, int fb_height,
- int fb_width, int bytepp, caddr_t base)
-{
- int x;
- int y;
- int complement;
-
- /* Set up raster for this plane group */
- plane_change(num_planes, base + fb_offset, fb_width, fb_height);
-
- /* Cover each 64x64 chunk of screen space */
- y = 0;
- while (y < fb_height) {
- x = 0;
- while (x < fb_width) {
- if (x + 63 > fb_width) x = fb_width - 64;
- if (y + 63 > fb_height) y = fb_height - 64;
-
- /* Do each chunk twice - once normal, once complement */
- for (complement = B_FALSE;
- complement <= B_TRUE;
- complement++) {
- write_read(x, y,
- (boolean_t)complement,
- access_mode,
- B_TRUE,
- fb_pitch,
- bytepp,
- base) ||
- write_read(x, y,
- (boolean_t)complement,
- access_mode,
- B_FALSE,
- fb_pitch,
- bytepp,
- base);
- }
-
- /* Move over one 64x64 chunk */
- x += 64;
- }
-
- /* Move down one 64x64 chunk */
- y += 64;
- }
-
-} /* check_plane() */
-
-
-void
-memory_test(return_packet *rp, int fd)
-{
- struct ast_info ast_info;
- struct ast_info *pAST;
- unsigned int red;
- unsigned char *fbaddr;
- int i;
- int bytepp;
- int fb_offset, fb_pitch, fb_height, fb_width;
-
- pAST = &ast_info;
- pAST->fd = fd;
-
- /*
- * map the registers & frame buffers memory
- */
- if (ast_map_mem(pAST, rp, GRAPHICS_ERR_MEMORY_MSG) == -1) {
- return;
- }
-
- if (ast_init_info(pAST) == -1) {
- return;
- }
-
- for (i = 0; access_mode[i] != 0; i++) {
- check_plane((size_t) 8*pAST->bytesPerPixel, access_mode[i],
- (char *)"Memory Test",
- 0, pAST->screenWidth, pAST->screenHeight, pAST->screenWidth,
- pAST->bytesPerPixel, (caddr_t)pAST->FBvaddr);
- }
-
- /*
- * Unmap the registers & frame buffers memory
- */
- if (ast_unmap_mem(pAST, rp, GRAPHICS_ERR_MEMORY_MSG) == -1) {
- return;
- }
-} /* memory_test() */
+}
/* End of memory.c */
--- a/open-src/app/gfx-utils/sun-src/vts/ast/tools.c Wed Sep 11 11:55:15 2013 -0700
+++ b/open-src/app/gfx-utils/sun-src/vts/ast/tools.c Mon Sep 16 15:54:13 2013 -0700
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -22,984 +21,1226 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/mman.h>
+#include "libvtsSUNWast.h"
-#include "gfx_common.h" /* GFX Common definitions */
-#include "graphicstest.h"
-#include "libvtsSUNWast.h" /* Common VTS library definitions */
+hrtime_t ast_loop_time = (hrtime_t)10 * NANOSEC; /* time to busy wait */
-#include "X11/Xlib.h"
-#include "gfx_vts.h" /* VTS Graphics Test common routines */
-#include "ast.h"
-void
-ASTSetReg(int fd, int offset, int value)
-{
- ast_io_reg io_reg;
-
- io_reg.offset = offset;
- io_reg.value = value;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
-}
-
-void
-ASTGetReg(int fd, int offset, int *value)
+int
+ast_map_mem(
+ register return_packet *const rp,
+ register int const test)
{
- ast_io_reg io_reg;
-
- io_reg.offset = offset;
- ioctl(fd, AST_GET_IO_REG, &io_reg);
- *value = io_reg.value;
-}
-
-void
-ASTSetIndexReg(int fd, int offset, int index, unsigned char value)
-{
- ast_io_reg io_reg;
+ register int const pagesize = getpagesize();
- io_reg.offset = offset;
- io_reg.value = index;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
- io_reg.offset = offset + 1;
- io_reg.value = value;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
-}
+ if (ast_get_pci_info() != 0) {
+ gfx_vts_set_message(rp, 1, test, "get pci info failed");
+ return (-1);
+ }
-void
-ASTGetIndexReg(int fd, int offset, int index, unsigned char *value)
-{
- ast_io_reg io_reg;
+
+ ast_info.ast_fb_size = (ast_info.ast_fb_size + pagesize - 1) /
+ pagesize * pagesize;
- io_reg.offset = offset;
- io_reg.value = index;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
- io_reg.offset = offset + 1;
- ioctl(fd, AST_GET_IO_REG, &io_reg);
- *value = io_reg.value;
-}
-
-void
-ASTSetIndexRegMask(int fd, int offset, int index, int and, unsigned char value)
-{
- ast_io_reg io_reg;
- unsigned char temp;
+ /*
+ * Map framebuffer
+ */
- io_reg.offset = offset;
- io_reg.value = index;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
- io_reg.offset = offset + 1;
- ioctl(fd, AST_GET_IO_REG, &io_reg);
- temp = (io_reg.value & and) | value;
- io_reg.offset = offset;
- io_reg.value = index;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
- io_reg.offset = offset + 1;
- io_reg.value = temp;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
-}
+ if (ast_map_fb() != 0) {
+ gfx_vts_set_message(rp, 1, test, "map framebuffer failed");
+ return (-1);
+ }
+
-void
-ASTGetIndexRegMask(int fd, int offset, int index, int and, unsigned char *value)
-{
- ast_io_reg io_reg;
- unsigned char temp;
-
- io_reg.offset = offset;
- io_reg.value = index;
- ioctl(fd, AST_SET_IO_REG, &io_reg);
- io_reg.offset = offset + 1;
- ioctl(fd, AST_GET_IO_REG, &io_reg);
- *value = io_reg.value & and;
-}
+ ast_info.ast_mmio_size = (ast_info.ast_mmio_size + pagesize - 1) /
+ pagesize * pagesize;
-void
-ASTOpenKey(int fd)
-{
- ASTSetIndexReg(fd, CRTC_PORT, 0x80, 0xA8);
-}
+ /*
+ * Map MMIO
+ */
+ if (ast_map_mmio() != 0) {
+ gfx_vts_set_message(rp, 1, test, "map MMIO failed");
+ return (-1);
+ }
-unsigned int
-ASTMMIORead32(unsigned char *addr)
-{
- return (*(volatile unsigned int *)(addr));
-}
-
-void
-ASTMMIOWrite32(unsigned char *addr, unsigned int data)
-{
- *(unsigned int *)(addr) = data;
+ return (0);
}
-unsigned int
-ASTMMIORead32_8pp(unsigned char *addr)
+int
+ast_get_pci_info(
+ void)
{
- union
- {
- unsigned int ul;
- unsigned char b[4];
- } data;
-
- unsigned int m;
-
- data.ul = *((volatile unsigned int *)(addr));
-
- m = (((unsigned int)data.b[3]) << 24) |
- (((unsigned int)data.b[2]) << 16) |
- (((unsigned int)data.b[1]) << 8) |
- (((unsigned int)data.b[0]));
- return (m);
-}
-
-void
-ASTMMIOWrite32_8pp(unsigned char *addr, unsigned int val)
-{
- union
- {
- unsigned int ul;
- unsigned char b[4];
- } data;
+ struct gfx_pci_cfg pciconfig;
+ int i;
+ uint_t bar;
+ uint_t bar_hi;
+ offset_t mem_base[6];
+ offset_t io_base[6];
+ int type[6];
+ uchar_t pots;
- unsigned int m;
-
- data.ul = val;
- m = (((unsigned int)data.b[3]) << 24) |
- (((unsigned int)data.b[2]) << 16) |
- (((unsigned int)data.b[1]) << 8) |
- (((unsigned int)data.b[0]));
-
- *(unsigned int*)(addr) = m;
-}
+ if (ioctl(ast_info.ast_fd, GFX_IOCTL_GET_PCI_CONFIG,
+ &pciconfig) != 0) {
+ return (-1);
+ }
-void
-ASTWaitEngIdle(struct ast_info *pAST)
-{
- unsigned int ulEngState, ulEngState2;
- unsigned char reg;
- unsigned int ulEngCheckSetting;
-
+ ast_info.ast_vendor = pciconfig.VendorID;
+ ast_info.ast_device = pciconfig.DeviceID;
- if (pAST->MMIO2D)
- return;
-
- ulEngCheckSetting = 0x80000000;
-
- ASTGetIndexRegMask(pAST->fd, CRTC_PORT, 0xA4, 0x01, ®);
- if (!reg) {
- printf("2d disabled\n");
- return;
+ for (i = 0; i < 6; i++) {
+ type[i] = 0;
+ mem_base[i] = 0;
+ io_base[i] = 0;
}
- ASTGetIndexRegMask(pAST->fd, CRTC_PORT, 0xA3, 0x0F, ®);
- if (!reg) {
- printf("2d not work if in std mode\n");
- return;
+ for (i = 0; i < 6; i++) {
+ bar = pciconfig.bar[i];
+ if (bar != 0) {
+ if (bar & PCI_MAP_IO) {
+ io_base[i] = PCIGETIO(bar);
+ type[i] = bar & PCI_MAP_IO_ATTR_MASK;
+ } else {
+ type[i] = bar & PCI_MAP_MEMORY_ATTR_MASK;
+ mem_base[i] = PCIGETMEMORY(bar);
+ if (PCI_MAP_IS64BITMEM(bar)) {
+ if (i == 5) {
+ mem_base[i] = 0;
+ } else {
+ bar_hi = pciconfig.bar[i+1];
+ mem_base[i] |=
+ ((offset_t)bar_hi << 32);
+ ++i;
+ }
+ }
+ }
+ }
}
- do
- {
- ulEngState = pAST->read32((pAST->CMDQInfo.pjEngStatePort));
- ulEngState2 = pAST->read32((pAST->CMDQInfo.pjEngStatePort));
- ulEngState2 = pAST->read32((pAST->CMDQInfo.pjEngStatePort));
- ulEngState2 = pAST->read32((pAST->CMDQInfo.pjEngStatePort));
- ulEngState2 = pAST->read32((pAST->CMDQInfo.pjEngStatePort));
- ulEngState2 = pAST->read32((pAST->CMDQInfo.pjEngStatePort));
- ulEngState &= 0xFFFC0000;
- ulEngState2 &= 0xFFFC0000;
- } while ((ulEngState & ulEngCheckSetting) || (ulEngState != ulEngState2));
-}
+ ast_info.ast_fb_addr = mem_base[0] & 0xfff00000;
+ ast_info.ast_fb_size = 0;
+
+ ast_info.ast_mmio_addr = mem_base[1] & 0xffff0000;
+ ast_info.ast_mmio_size = AST_MMIO_SIZE;
+
+ ast_info.ast_relocate_io = io_base[2];
+
+ if (ast_open_key() != 0)
+ return (-1);
+
+ if (ast_get_index_reg(&pots, CRTC_PORT, 0xAA) != 0)
+ return (-1);
+
+ switch (pots & 0x03) {
+ case 0x00:
+ ast_info.ast_fb_size = AST_VRAM_SIZE_08M;
+ break;
+
+ case 0x01:
+ ast_info.ast_fb_size = AST_VRAM_SIZE_16M;
+ break;
-void
-ASTSaveState(struct ast_info *pAST)
-{
- pAST->save_dst_base = pAST->read32(MMIOREG_DST_BASE);
- pAST->save_line_xy = pAST->read32(MMIOREG_LINE_XY);
- pAST->save_line_err = pAST->read32(MMIOREG_LINE_Err);
- pAST->save_line_width = pAST->read32(MMIOREG_LINE_WIDTH);
- pAST->save_line_k1 = pAST->read32(MMIOREG_LINE_K1);
- pAST->save_line_k2 = pAST->read32(MMIOREG_LINE_K2);
- pAST->save_mono_pat1 = pAST->read32(MMIOREG_MONO1);
- pAST->save_mono_pat2 = pAST->read32(MMIOREG_MONO2);
-}
+ case 0x02:
+ ast_info.ast_fb_size = AST_VRAM_SIZE_32M;
+ break;
+
+ case 0x03:
+ ast_info.ast_fb_size = AST_VRAM_SIZE_64M;
+ break;
+ }
-void
-ASTResetState(struct ast_info *pAST)
-{
- pAST->write32(MMIOREG_DST_BASE, pAST->save_dst_base);
- pAST->write32(MMIOREG_LINE_XY, pAST->save_line_xy);
- pAST->write32(MMIOREG_LINE_Err, pAST->save_line_err);
- pAST->write32(MMIOREG_LINE_WIDTH, pAST->save_line_width);
- pAST->write32(MMIOREG_LINE_K1, pAST->save_line_k1);
- pAST->write32(MMIOREG_LINE_K2, pAST->save_line_k2);
- pAST->write32(MMIOREG_MONO1, pAST->save_mono_pat1);
- pAST->write32(MMIOREG_MONO2, pAST->save_mono_pat2);
+ if (gfx_vts_debug_mask & VTS_DEBUG) {
+ printf("ast_vendor = 0x%04x, ast_device = 0x%04x\n",
+ ast_info.ast_vendor, ast_info.ast_device);
+ printf("ast_fb_addr 0x%llx, ast_fb_size 0x%lx\n",
+ (unsigned long long)ast_info.ast_fb_addr,
+ (unsigned long)ast_info.ast_fb_size);
+ printf("ast_mmio_addr 0x%llx, ast_mmio_size 0x%lx\n",
+ (unsigned long long)ast_info.ast_mmio_addr,
+ (unsigned long)ast_info.ast_mmio_size);
+ printf("ast_relocate_io 0x%llx\n",
+ (unsigned long long)ast_info.ast_relocate_io);
+ }
+
+ return (0);
}
int
-ASTInitCMDQ(struct ast_info *pAST)
+ast_map_mmio(
+ void)
{
- int availableLen;
-
- availableLen = pAST->FBMapSize -
- (pAST->screenWidth * pAST->bytesPerPixel * pAST->screenHeight);
+ register void *ptr;
- if (availableLen < 0x100000) {
+ if (ast_info.ast_mmio_ptr == NULL) {
+ ptr = mmap(NULL, ast_info.ast_mmio_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ ast_info.ast_fd, ast_info.ast_mmio_addr);
-#if DEBUG
- printf("Not enough memory to initialize CMDQ, fallback to MMIO\n");
-#endif
- return -1;
+ if (ptr == MAP_FAILED)
+ return (-1);
}
- pAST->CMDQInfo.pjCmdQBasePort = pAST->MMIOvaddr + 0x8044;
- pAST->CMDQInfo.pjWritePort = pAST->MMIOvaddr + 0x8048;
- pAST->CMDQInfo.pjReadPort = pAST->MMIOvaddr + 0x804C;
- pAST->CMDQInfo.pjEngStatePort = pAST->MMIOvaddr + 0x804C;
-
- pAST->CMDQInfo.ulCMDQSize = 0x40000; /* byte */
- pAST->CMDQInfo.ulCMDQOffset =
- (pAST->screenWidth * pAST->bytesPerPixel * pAST->screenHeight);
- pAST->CMDQInfo.pjCMDQvaddr = pAST->FBvaddr + pAST->CMDQInfo.ulCMDQOffset;
- pAST->CMDQInfo.ulCMDQueueLen = pAST->CMDQInfo.ulCMDQSize - CMD_QUEUE_GUARD_BAND;
- pAST->CMDQInfo.ulCMDQMask = pAST->CMDQInfo.ulCMDQSize - 1;
-
-
- pAST->CMDQInfo.ulWritePointer = 0;
+ ast_info.ast_mmio_ptr = (uchar_t *)ptr;
- return 0;
-}
-
-ASTEnableCMDQ(struct ast_info *pAST)
-{
- unsigned int ulVMCmdQBasePort = 0;
-
- ASTWaitEngIdle(pAST);
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("ast_mmio_ptr = 0x%llx\n",
+ (unsigned long long)ast_info.ast_mmio_ptr);
- ulVMCmdQBasePort = pAST->CMDQInfo.ulCMDQOffset >> 3;
-
- /*
- * set CMDQ Threshold
- */
- ulVMCmdQBasePort |= 0xF0000000;
-
- pAST->write32((pAST->CMDQInfo.pjCmdQBasePort), ulVMCmdQBasePort);
- pAST->CMDQInfo.ulWritePointer = pAST->read32((pAST->CMDQInfo.pjWritePort));
- pAST->CMDQInfo.ulWritePointer <<= 3; /* byte offset */
+ return (0);
}
-ASTEnable2D(struct ast_info *pAST)
+int
+ast_map_fb(
+ void)
{
- unsigned int ulData;
-
- pAST->write32((pAST->MMIOvaddr + 0xF004), 0x1e6e0000);
- pAST->write32((pAST->MMIOvaddr + 0xF000), 0x1);
-
- ulData = pAST->read32((pAST->MMIOvaddr + 0x1200c));
- pAST->write32((pAST->MMIOvaddr + 0x1200c), (ulData & 0xFFFFFFFD));
-
- ASTSetIndexRegMask(pAST->fd, CRTC_PORT, 0xA4, 0xFE, 0x01);
-}
-
-unsigned int
-ASTGetCMDQLength(struct ast_info *pAST, unsigned int ulWritePointer, unsigned int ulCMDQMask)
-{
- unsigned long ulReadPointer, ulReadPointer2;
-
- do {
- ulReadPointer = pAST->read32((pAST->CMDQInfo.pjReadPort));
- ulReadPointer2 = pAST->read32((pAST->CMDQInfo.pjReadPort));
- ulReadPointer2 = pAST->read32((pAST->CMDQInfo.pjReadPort));
- ulReadPointer2 = pAST->read32((pAST->CMDQInfo.pjReadPort));
- ulReadPointer2 = pAST->read32((pAST->CMDQInfo.pjReadPort));
- ulReadPointer2 = pAST->read32((pAST->CMDQInfo.pjReadPort));
- ulReadPointer &= 0x3FFFF;
- ulReadPointer2 &= 0x3FFFF;
- } while (ulReadPointer != ulReadPointer2);
+ register void *ptr;
- return ((ulReadPointer << 3) - ulWritePointer - CMD_QUEUE_GUARD_BAND) & ulCMDQMask;
-}
-
-PKT_SC *
-ASTRequestCMDQ(struct ast_info *pAST, int ncmd)
-{
- unsigned char *pjBuffer;
- unsigned long i, ulWritePointer, ulCMDQMask, ulCurCMDQLen, ulContinueCMDQLen;
- unsigned long ulDataLen;
-
- ulDataLen = ncmd * 2 * 4;
- ulWritePointer = pAST->CMDQInfo.ulWritePointer;
- ulContinueCMDQLen = pAST->CMDQInfo.ulCMDQSize - ulWritePointer;
- ulCMDQMask = pAST->CMDQInfo.ulCMDQMask;
+ if (ast_info.ast_fb_ptr == NULL) {
+ ptr = mmap(NULL, ast_info.ast_fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ ast_info.ast_fd, ast_info.ast_fb_addr);
- if (ulContinueCMDQLen >= ulDataLen)
- {
- /* Get CMDQ Buffer */
- if (pAST->CMDQInfo.ulCMDQueueLen >= ulDataLen)
- {
- ;
- }
- else
- {
- do
- {
- ulCurCMDQLen = ASTGetCMDQLength(pAST, ulWritePointer, ulCMDQMask);
- } while (ulCurCMDQLen < ulDataLen);
+ if (ptr == MAP_FAILED)
+ return (-1);
- pAST->CMDQInfo.ulCMDQueueLen = ulCurCMDQLen;
-
- }
-
- pjBuffer = pAST->CMDQInfo.pjCMDQvaddr + ulWritePointer;
- pAST->CMDQInfo.ulCMDQueueLen -= ulDataLen;
- pAST->CMDQInfo.ulWritePointer = (ulWritePointer + ulDataLen) & ulCMDQMask;
- return (PKT_SC *)pjBuffer;
+ ast_info.ast_fb_ptr = (uchar_t *)ptr;
}
- else
- { /* Fill NULL CMD to the last of the CMDQ */
- if (pAST->CMDQInfo.ulCMDQueueLen >= ulContinueCMDQLen)
- {
- ;
- }
- else
- {
-
- do
- {
- ulCurCMDQLen = ASTGetCMDQLength(pAST, ulWritePointer, ulCMDQMask);
- } while (ulCurCMDQLen < ulContinueCMDQLen);
-
- pAST->CMDQInfo.ulCMDQueueLen = ulCurCMDQLen;
-
- }
-
- pjBuffer = pAST->CMDQInfo.pjCMDQvaddr + ulWritePointer;
- for (i = 0; i<ulContinueCMDQLen/8; i++, pjBuffer+=8)
- {
- pAST->write32(pjBuffer , (unsigned long) PKT_NULL_CMD);
- pAST->write32((pjBuffer+4) , 0);
-
- }
- pAST->CMDQInfo.ulCMDQueueLen -= ulContinueCMDQLen;
- pAST->CMDQInfo.ulWritePointer = ulWritePointer = 0;
-
- /* Get CMDQ Buffer */
- if (pAST->CMDQInfo.ulCMDQueueLen >= ulDataLen)
- {
- ;
- }
- else
- {
-
- do
- {
- ulCurCMDQLen = ASTGetCMDQLength(pAST, ulWritePointer, ulCMDQMask);
- } while (ulCurCMDQLen < ulDataLen);
-
- pAST->CMDQInfo.ulCMDQueueLen = ulCurCMDQLen;
-
- }
- pAST->CMDQInfo.ulCMDQueueLen -= ulDataLen;
- pjBuffer = pAST->CMDQInfo.pjCMDQvaddr + ulWritePointer;
- pAST->CMDQInfo.ulWritePointer = (ulWritePointer + ulDataLen) & ulCMDQMask;
- return (PKT_SC *)pjBuffer;
- }
-}
-
-void
-ASTUpdateWritePointer(struct ast_info *pAST)
-{
- pAST->write32((pAST->CMDQInfo.pjWritePort), (pAST->CMDQInfo.ulWritePointer >> 3));
-}
-
+ if (gfx_vts_debug_mask & VTS_DEBUG)
+ printf("ast_fb_ptr = 0x%llx\n",
+ (unsigned long long)ast_info.ast_fb_ptr);
-void
-ASTSetupCmdArg1(struct ast_info *pAST, PKT_SC *pCMD, unsigned int header, unsigned int arg)
-{
- pAST->write32((unsigned char *)&pCMD->header, PKT_SINGLE_CMD_HEADER + header);
- pAST->write32((unsigned char *)pCMD->data, arg);
- return;
-}
-
-void
-ASTSetupCmdArg2(struct ast_info *pAST, PKT_SC *pCMD, unsigned int header,
- unsigned int arg1, unsigned int arg2,
- unsigned int shift1, unsigned int shift2)
-{
- unsigned int ul;
-
- pAST->write32((unsigned char *)&pCMD->header, PKT_SINGLE_CMD_HEADER + header);
- ul = (arg1 << shift1) | (arg2 << shift2);
- pAST->write32((unsigned char *)pCMD->data, ul);
- return;
+ return (0);
}
-void
-ASTSetupMMIOArg1(struct ast_info *pAST, unsigned char *addr, unsigned int arg)
+int
+ast_init_info(
+ register return_packet *const rp,
+ register int const test)
{
- unsigned int argr;
-
- do {
- pAST->write32(addr, arg);
- argr = pAST->read32(addr);
- } while (arg != argr);
+ register uint_t mode;
+ register uint_t width;
+ register uint_t height;
+ register uint_t depth;
+ register uint_t pixelsize;
+ register uint_t offset;
+ register uint_t memsize;
+ uchar_t save_gctl;
+ uchar_t misc;
+ uchar_t hde;
+ uchar_t ovf;
+ uchar_t vde;
+ uchar_t off;
+ uchar_t undloc;
+ uchar_t modectl;
+ uchar_t pcicr3;
+ uchar_t ecm;
+ uchar_t xhovf;
+ uchar_t xvovf;
+ uchar_t offovf;
+ unsigned int status = 0;
- return;
-}
+ /*
+ * first check if the hardware is already initialized.
+ * If not, abort
+ */
+ if (ioctl(ast_info.ast_fd, AST_GET_STATUS_FLAGS, &status) != 0) {
+ gfx_vts_set_message(rp, 1, test,
+ "AST_GET_STATUS_FLAGS failed");
+ return (-1);
+ }
-void
-ASTSetupMMIOArg2(struct ast_info *pAST, unsigned char *addr,
- unsigned int arg1, unsigned int arg2,
- unsigned int shift1, unsigned int shift2)
-{
- unsigned int ul;
- unsigned int ulr;
-
- ul = (arg1 << shift1) | (arg2 << shift2);
+ if (!(status & AST_STATUS_HW_INITIALIZED)) {
+ gfx_vts_set_message(rp, 1, test,
+ "AST_GET_STATUS_FLAGS not initialized");
+ return (-1);
+ }
- do {
- pAST->write32(addr, ul);
- ulr = pAST->read32(addr);
- } while (ul != ulr);
+ if (ast_open_key() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to open key");
+ return (-1);
+ }
+
+ if (ast_get_reg(&save_gctl, GR_PORT) != 0) {
+ gfx_vts_set_message(rp, 1, test,
+ "unable to get the gctl index");
+ return (-1);
+ }
- return;
-}
+ if (ast_get_index_reg(&misc, GR_PORT, 0x06) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the misc");
+ return (-1);
+ }
+ if (ast_set_reg(GR_PORT, save_gctl) != 0) {
+ gfx_vts_set_message(rp, 1, test,
+ "unable to set the gctl index");
+ return (-1);
+ }
-void *
-ASTSetupForMonoPatternFill(struct ast_info *pAST, int patx, int paty, int fg, int bg, int rop)
-{
- unsigned int cmdreg;
- unsigned int ul;
- PKT_SC *pCMD;
-
- cmdreg = CMD_BITBLT | CMD_PAT_MONOMASK;
- switch (pAST->bytesPerPixel) {
- case 1:
- cmdreg |= CMD_COLOR_08;
- break;
- case 2:
- cmdreg |= CMD_COLOR_16;
- break;
- case 3:
- case 4:
- default:
- cmdreg |= CMD_COLOR_32;
- break;
+ if (ast_get_index_reg(&hde, CRTC_PORT, 0x01) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the hde");
+ return (-1);
+ }
+
+ if (ast_get_index_reg(&ovf, CRTC_PORT, 0x07) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the ovf");
+ return (-1);
+ }
+
+ if (ast_get_index_reg(&vde, CRTC_PORT, 0x12) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the vde");
+ return (-1);
+ }
+
+ if (ast_get_index_reg(&off, CRTC_PORT, 0x13) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the offset");
+ return (-1);
+ }
+
+ if (ast_get_index_reg(&undloc, CRTC_PORT, 0x14) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the undloc");
+ return (-1);
+ }
+
+ if (ast_get_index_reg(&modectl, CRTC_PORT, 0x17) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the modectl");
+ return (-1);
}
- cmdreg |= rop << 8;
- pAST->cmdreg = cmdreg;
-
- if (!pAST->MMIO2D) {
- pCMD = ASTRequestCMDQ(pAST, 5);
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_DST_PITCH, pAST->screenPitch, MASK_DST_HEIGHT, 16, 0);
- pCMD++;
+ if (ast_get_index_reg(&pcicr3, CRTC_PORT, 0xa2) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the pcicr3");
+ return (-1);
+ }
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_FG, fg);
- pCMD++;
+ if (ast_get_index_reg(&ecm, CRTC_PORT, 0xa3) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the ecm");
+ return (-1);
+ }
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_BG, bg);
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_MONO1, patx);
- pCMD++;
+ if (ast_get_index_reg(&xhovf, CRTC_PORT, 0xac) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the xhovf");
+ return (-1);
+ }
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_MONO2, paty);
-
- } else {
- ASTSetupMMIOArg2(pAST, MMIOREG_DST_PITCH, pAST->screenPitch, MASK_DST_HEIGHT, 16, 0);
- ASTSetupMMIOArg1(pAST, MMIOREG_FG, fg);
- ASTSetupMMIOArg1(pAST, MMIOREG_BG, bg);
- ASTSetupMMIOArg1(pAST, MMIOREG_MONO1, patx);
- ASTSetupMMIOArg1(pAST, MMIOREG_MONO2, paty);
+ if (ast_get_index_reg(&xvovf, CRTC_PORT, 0xae) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the xvovf");
+ return (-1);
}
-}
+
+ if (ast_get_index_reg(&offovf, CRTC_PORT, 0xb0) != 0) {
+ gfx_vts_set_message(rp, 1, test, "unable to get the offovf");
+ return (-1);
+ }
-void
-ASTMonoPatternFill(struct ast_info *pAST, int patx, int paty, int x, int y,
- int width, int height)
-{
- unsigned int cmdreg;
- PKT_SC *pCMD;
+ width = (((((uint_t)xhovf & 0x4) >> 2 << 8) |
+ (uint_t)hde) + 1) << 3;
- cmdreg = pAST->cmdreg;
+ height = ((((uint_t)xvovf & 0x2) >> 1 << 10) |
+ (((uint_t)ovf & 0x40) >> 6 << 9) |
+ (((uint_t)ovf & 0x02) >> 1 << 8) |
+ (uint_t)vde) + 1;
- if (!pAST->MMIO2D) {
+ offset = (((uint_t)offovf & 0x3f) << 8) | (uint_t)off;
+
+ memsize = (undloc & 0x40) ? 4 :
+ ((modectl & 0x40) ? 1 : 2);
- pCMD = ASTRequestCMDQ(pAST, 4);
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_DST_BASE, 0);
- pCMD++;
+ if (!(misc & 0x01)) {
+ if (!(ecm & 0x01)) {
+ mode = VIS_TEXT;
+ depth = 4;
+ width /= 8;
+ height /= 16;
+ pixelsize = 2;
+ } else {
+ mode = VIS_PIXEL;
+ depth = 8;
+ pixelsize = 1;
+ }
+ } else {
+ mode = VIS_PIXEL;
+
+ switch (ecm & 0xf) {
+ case 0x01:
+ /* enable enhanced 256 color display mode */
+ depth = 8;
+ pixelsize = 1;
+ break;
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_DST_XY, x, y, 16, 0);
- pCMD++;
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_RECT_XY, width, height, 16, 0);
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_CMD, cmdreg);
+ case 0x02:
+ /* enable 15-bpp high color display mode (rgb:555) */
+ depth = 15;
+ pixelsize = 2;
+ break;
- ASTUpdateWritePointer(pAST);
-
- } else {
+ case 0x04:
+ /* enable 16-bpp high color display mode (rgb:565) */
+ depth = 16;
+ pixelsize = 2;
+ break;
- ASTSetupMMIOArg1(pAST, MMIOREG_DST_BASE, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_DST_XY, x, y, 16, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_RECT_XY, width, height, 16, 0);
- ASTSetupMMIOArg1(pAST, MMIOREG_CMD, cmdreg);
+ case 0x08:
+ /* enable 32-bpp true color display mode (argb:8888) */
+ depth = 32;
+ pixelsize = 4;
+ break;
+
+ default:
+ gfx_vts_set_message(rp, 1, test, "invalid ecm");
+ return (-1);
+ }
}
-}
+
+ ast_info.ast_mode = mode;
+ ast_info.ast_width = width;
+ ast_info.ast_height = height;
+ ast_info.ast_depth = depth;
+ ast_info.ast_pixelsize = pixelsize;
+ ast_info.ast_linesize = offset * memsize * 2;
-void
-ASTSetupForSolidFill(struct ast_info *pAST, int color, int rop)
-{
- unsigned int cmdreg;
- unsigned int ul;
- PKT_SC *pCMD;
-
- cmdreg = CMD_BITBLT | CMD_PAT_FGCOLOR;
- switch (pAST->bytesPerPixel) {
- case 1:
- cmdreg |= CMD_COLOR_08;
+ switch (pcicr3 & 0xc0) {
+ case 0x00: /* little endian */
+ case 0x40:
+ ast_info.ast_endian = 0;
break;
- case 2:
- cmdreg |= CMD_COLOR_16;
+
+ case 0x80: /* big endian 32 */
+ ast_info.ast_endian = 2;
break;
- case 3:
- case 4:
- default:
- cmdreg |= CMD_COLOR_32;
+
+ case 0xc0: /* big endian 16 */
+ ast_info.ast_endian = 1;
break;
}
- cmdreg |= rop << 8;
- pAST->cmdreg = cmdreg;
-
- if (!pAST->MMIO2D) {
-
- pCMD = ASTRequestCMDQ(pAST, 2);
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_DST_PITCH, pAST->screenPitch, MASK_DST_HEIGHT, 16, 0);
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_FG, color);
- pCMD++;
-
- } else {
-
- ASTSetupMMIOArg2(pAST, MMIOREG_DST_PITCH, pAST->screenPitch, MASK_DST_HEIGHT, 16, 0);
- ASTSetupMMIOArg1(pAST, MMIOREG_FG, color);
+ if (gfx_vts_debug_mask & VTS_DEBUG) {
+ printf("width=%d height=%d depth=%d pitch=%d\n",
+ ast_info.ast_width, ast_info.ast_height,
+ ast_info.ast_depth, ast_info.ast_linesize);
}
-}
-
-void
-ASTSolidFillRect(struct ast_info *pAST, int x, int y, int width, int height)
-{
- unsigned int cmdreg;
- unsigned int ul;
- PKT_SC *pCMD;
- cmdreg = pAST->cmdreg;
-
-
- if (!pAST->MMIO2D) {
-
- pCMD = ASTRequestCMDQ(pAST, 4);
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_DST_BASE, 0);
- pCMD++;
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_DST_XY, x, y, 16, 0);
- pCMD++;
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_RECT_XY, width, height, 16, 0);
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_CMD, cmdreg);
- pCMD++;
-
- ASTUpdateWritePointer(pAST);
-
- } else {
-
- ASTSetupMMIOArg1(pAST, MMIOREG_DST_BASE, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_DST_XY, x, y, 16, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_RECT_XY, width, height, 16, 0);
- ASTSetupMMIOArg1(pAST, MMIOREG_CMD, cmdreg);
- }
+ return (0);
}
-void
-ASTSetupForSolidLine(struct ast_info *pAST, int color, int rop)
+
+int
+ast_init_graphics(
+ void)
{
- unsigned int cmdreg;
- unsigned int ul;
- PKT_SC *pCMD;
-
- cmdreg = CMD_BITBLT;
- switch (pAST->bytesPerPixel) {
- case 1:
- cmdreg |= CMD_COLOR_08;
- break;
- case 2:
- cmdreg |= CMD_COLOR_16;
- break;
- case 3:
- case 4:
- default:
- cmdreg |= CMD_COLOR_32;
- break;
+ unsigned int ulData;
+ register int status = 0;
+
+ /*
+ * Enable MMIO
+ */
+
+ if (ast_get_index_reg(&ast_info.ast_pcicr2, CRTC_PORT, 0xA1) != 0)
+ return (-1);
+
+ if (ast_set_index_reg(CRTC_PORT, 0xA1, 0x4) != 0)
+ return (-1);
+
+ ast_info.ast_remap_base = ast_mmio_read32(0xF004);
+ ast_info.ast_prot_key = ast_mmio_read32(0xF000);
+ if (ast_get_index_reg(&ast_info.ast_misc_control, CRTC_PORT, 0xA4) != 0)
+ return (-1);
+
+ ast_mmio_write32(0xF004, 0x1e6e0000);
+ ast_mmio_write32(0xF000, 0x1);
+
+ ulData = ast_mmio_read32(0x1200c);
+ ast_mmio_write32(0x1200c, ulData & 0xFFFFFFFD);
+
+ if (!(ast_info.ast_misc_control & 0x01)) {
+ if (ast_set_index_reg(CRTC_PORT, 0xA4,
+ ast_info.ast_misc_control | 0x01) != 0)
+ return (-1);
+ status = 1;
}
- cmdreg |= rop << 8;
- pAST->cmdreg = cmdreg;
-
- if (!pAST->MMIO2D) {
-
- pCMD = ASTRequestCMDQ(pAST, 3);
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_DST_PITCH, pAST->screenPitch, MASK_DST_HEIGHT, 16, 0);
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_FG, color);
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_BG, 0);
- pCMD++;
-
- } else {
-
- ASTSetupMMIOArg2(pAST, MMIOREG_DST_PITCH, pAST->screenPitch, MASK_DST_HEIGHT, 16, 0);
- ASTSetupMMIOArg1(pAST, MMIOREG_FG, color);
- ASTSetupMMIOArg1(pAST, MMIOREG_BG, 0);
- }
-}
+ if (!ast_wait_idle())
+ return (-1);
-void
-ASTSolidLine(struct ast_info *pAST, int x1, int y1, int x2, int y2)
-{
- unsigned int cmdreg;
- unsigned int ul;
- PKT_SC *pCMD;
- int GAbsX, GAbsY;
- int MM, mm, err, k1, k2, xm;
- int width, height;
-
- cmdreg = (pAST->cmdreg & (~CMD_MASK)) | CMD_ENABLE_CLIP | CMD_NOT_DRAW_LAST_PIXEL;
-
- GAbsX = abs(x1 - x2);
- GAbsY = abs(y1 - y2);
-
- cmdreg |= CMD_LINEDRAW;
+ ast_info.ast_queue = ast_mmio_read32(MMIOREG_QUEUE);
+ ast_info.ast_dst_base = ast_mmio_read32(MMIOREG_DST_BASE);
+ ast_info.ast_dst_pitch = ast_mmio_read32(MMIOREG_DST_PITCH);
+ ast_info.ast_dst_xy = ast_mmio_read32(MMIOREG_DST_XY);
+ ast_info.ast_line_err = ast_mmio_read32(MMIOREG_LINE_ERR);
+ ast_info.ast_rect_xy = ast_mmio_read32(MMIOREG_RECT_XY);
+ ast_info.ast_fg = ast_mmio_read32(MMIOREG_FG);
+ ast_info.ast_bg = ast_mmio_read32(MMIOREG_BG);
+ ast_info.ast_mono1 = ast_mmio_read32(MMIOREG_MONO1);
+ ast_info.ast_mono2 = ast_mmio_read32(MMIOREG_MONO2);
+ ast_info.ast_clip1 = ast_mmio_read32(MMIOREG_CLIP1);
+ ast_info.ast_clip2 = ast_mmio_read32(MMIOREG_CLIP2);
- if (GAbsX >= GAbsY) {
- MM = GAbsX;
- mm = GAbsY;
- xm = 1;
- } else {
- MM = GAbsY;
- mm = GAbsX;
- xm = 0;
- }
-
- if (x1 >= x2) {
- cmdreg |= CMD_X_DEC;
- }
-
- if (y1 >= y2) {
- cmdreg |= CMD_Y_DEC;
+ if (!(ast_info.ast_queue & QUEUE_MEMORY_MAP)) {
+ ast_mmio_write32(MMIOREG_QUEUE,
+ ast_info.ast_queue | QUEUE_MEMORY_MAP);
+ status = 1;
}
- err = (signed) (2 * mm - MM);
- k1 = 2 * mm;
- k2 = (signed) 2 * mm - 2 * MM;
-
-
- if (!pAST->MMIO2D) {
-
- pCMD = ASTRequestCMDQ(pAST, 7);
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_DST_BASE, 0);
- pCMD++;
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_LINE_XY, x1, y1, 16, 0);
- pCMD++;
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_LINE_Err, xm, (err & MASK_LINE_ERR), 24, 0);
- pCMD++;
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_LINE_WIDTH, (MM & MASK_LINE_WIDTH), 0, 16, 0);
- pCMD++;
+ if (!ast_store_mmio(MMIOREG_CLIP1,
+ ((0 & MASK_CLIP) << 16) |
+ (0 & MASK_CLIP)))
+ return (-1);
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_LINE_K1, (k1 & MASK_LINE_K1));
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_LINE_K2, (k2 & MASK_LINE_K2));
- pCMD++;
-
- ASTSetupCmdArg1(pAST, pCMD, CMDQREG_CMD, cmdreg);
- pCMD++;
-
- ASTUpdateWritePointer(pAST);
+ if (!ast_store_mmio(MMIOREG_CLIP2,
+ ((ast_info.ast_width & MASK_CLIP) << 16) |
+ (ast_info.ast_height & MASK_CLIP)))
+ return (-1);
- ASTWaitEngIdle(pAST);
-
- } else {
-
- ASTSetupMMIOArg1(pAST, MMIOREG_DST_BASE, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_LINE_XY, x1, y1, 16, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_LINE_Err, xm, (err & MASK_LINE_ERR), 24, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_LINE_WIDTH, (MM & MASK_LINE_WIDTH), 0, 16, 0);
- ASTSetupMMIOArg1(pAST, MMIOREG_LINE_K1, (k1 & MASK_LINE_K1));
- ASTSetupMMIOArg1(pAST, MMIOREG_LINE_K2, (k1 & MASK_LINE_K2));
- ASTSetupMMIOArg1(pAST, MMIOREG_CMD, cmdreg);
- }
+ return (status);
}
-void
-ASTSetClippingRectangle(struct ast_info *pAST, int left, int top, int right, int bottom)
-{
- PKT_SC *pCMD;
-
- if (!pAST->MMIO2D) {
-
- pCMD = ASTRequestCMDQ(pAST, 2);
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_CLIP1, (left & MASK_CLIP), (top & MASK_CLIP), 16, 0);
- pCMD++;
-
- ASTSetupCmdArg2(pAST, pCMD, CMDQREG_CLIP2, (right & MASK_CLIP), (bottom & MASK_CLIP), 16, 0);
- ASTUpdateWritePointer(pAST);
-
- } else {
-
- ASTSetupMMIOArg2(pAST, MMIOREG_CLIP1, (left & MASK_CLIP), (top & MASK_CLIP), 16, 0);
- ASTSetupMMIOArg2(pAST, MMIOREG_CLIP2, (right & MASK_CLIP), (bottom & MASK_CLIP), 16, 0);
- }
-}
int
-ast_get_pci_info(int fd, struct pci_info *pciInfo)
+ast_finish_graphics(
+ void)
{
- struct gfx_pci_cfg pciCfg;
- int i;
- unsigned int bar;
+ register int status = 0;
- if (ioctl(fd, GFX_IOCTL_GET_PCI_CONFIG, &pciCfg) == -1) {
- return -1;
+ ast_store_mmio(MMIOREG_DST_BASE, ast_info.ast_dst_base);
+ ast_store_mmio(MMIOREG_DST_PITCH, ast_info.ast_dst_pitch);
+ ast_store_mmio(MMIOREG_DST_XY, ast_info.ast_dst_xy);
+ ast_store_mmio(MMIOREG_LINE_ERR, ast_info.ast_line_err);
+ ast_store_mmio(MMIOREG_RECT_XY, ast_info.ast_rect_xy);
+ ast_store_mmio(MMIOREG_FG, ast_info.ast_fg);
+ ast_store_mmio(MMIOREG_BG, ast_info.ast_bg);
+ ast_store_mmio(MMIOREG_MONO1, ast_info.ast_mono1);
+ ast_store_mmio(MMIOREG_MONO2, ast_info.ast_mono2);
+ ast_store_mmio(MMIOREG_CLIP1, ast_info.ast_clip1);
+ ast_store_mmio(MMIOREG_CLIP2, ast_info.ast_clip2);
+
+ ast_store_mmio(MMIOREG_QUEUE, ast_info.ast_queue);
+
+ if (!(ast_info.ast_misc_control & 0x01)) {
+ if (ast_set_index_reg(CRTC_PORT,
+ 0xA4, ast_info.ast_misc_control) != 0)
+ status = -1;
+ else
+ status = 1;
}
- for (i = 0; i < 6; i++) {
- bar = pciCfg.bar[i];
- if (bar != 0) {
- if (bar & PCI_MAP_IO) {
- pciInfo->ioBase[i] = PCIGETIO(bar);
- pciInfo->type[i] = bar & PCI_MAP_IO_ATTR_MASK;
- } else {
- pciInfo->type[i] = bar & PCI_MAP_MEMORY_ATTR_MASK;
- pciInfo->memBase[i] = PCIGETMEMORY(bar);
- if (PCI_MAP_IS64BITMEM(bar)) {
- if (i == 5) {
- pciInfo->memBase[i] = 0;
- } else {
- int bar_hi = pciCfg.bar[i+1];
- pciInfo->memBase[i] |= (bar_hi << 32);
- ++i;
- }
- }
- pciInfo->size[i] = AST_REG_SIZE_LOG2;
- }
- }
- }
+ ast_mmio_write32(0xF004, ast_info.ast_remap_base);
+ ast_mmio_write32(0xF000, ast_info.ast_prot_key);
- return 0;
+ if (ast_set_index_reg(CRTC_PORT, 0xA1, ast_info.ast_pcicr2) != 0)
+ status = -1;
+
+ return (status);
}
+
int
-ast_get_mem_info(struct pci_info *pci_info, struct ast_info *pAST)
+ast_save_palet(
+ void)
{
- unsigned char reg;
+ register uint_t coloron;
+ register int status = 1;
+ uchar_t junk;
- pAST->FBPhysAddr = pci_info->memBase[0] & 0xfff00000;
- pAST->FBMapSize = 0;
+ for (coloron = 0; coloron < 256; coloron++) {
+ if (ast_set_reg(DAC_INDEX_READ, coloron) != 0)
+ status = -1;
- pAST->MMIOPhysAddr = pci_info->memBase[1] & 0xffff0000;
- pAST->MMIOMapSize = AST_MMIO_SIZE;
-
- pAST->RelocateIO = pci_info->ioBase[2];
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
- ASTOpenKey(pAST->fd);
- ASTGetIndexRegMask(pAST->fd, CRTC_PORT, 0xAA, 0xFF, ®);
- switch (reg & 0x03)
- {
- case 0x00:
- pAST->FBMapSize = AST_VRAM_SIZE_08M;
- break;
- case 0x01:
- pAST->FBMapSize = AST_VRAM_SIZE_16M;
- break;
- case 0x02:
- pAST->FBMapSize = AST_VRAM_SIZE_32M;
- break;
- case 0x03:
- pAST->FBMapSize = AST_VRAM_SIZE_64M;
- break;
- default:
- pAST->FBMapSize = AST_VRAM_SIZE_08M;
- break;
+ if (ast_get_reg(&ast_info.ast_red[coloron], DAC_DATA) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_get_reg(&ast_info.ast_green[coloron], DAC_DATA) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_get_reg(&ast_info.ast_blue[coloron], DAC_DATA) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
}
-#if DEBUG
- printf("FBPhysAddr=0x%x FBMapSize=0x%x\n", pAST->FBPhysAddr, pAST->FBMapSize);
- printf("MMIOPhysAddr=0x%x MMIOMapSize=0x%x\n", pAST->MMIOPhysAddr, pAST->MMIOMapSize);
- printf("RelocateIO=0x%x\n", pAST->RelocateIO);
-#endif
-
- return 0;
+ return (status);
}
int
-ast_init_info(struct ast_info *pAST)
+ast_set_palet(
+ void)
{
- unsigned char val;
- unsigned int status = 0;
+ register uint_t coloron;
+ register int status = 1;
+ register uint_t maxdac;
+ uchar_t ramdac_ctrl;
+ uchar_t new_red[256];
+ uchar_t new_green[256];
+ uchar_t new_blue[256];
+ uchar_t junk;
+
+ if (ast_get_index_reg(&ramdac_ctrl, CRTC_PORT, 0xA8) != 0)
+ return (-1);
+
+ maxdac = (ramdac_ctrl & 0x2) ? 255 : 63;
+
+ switch (ast_info.ast_depth) {
+ case 8: /* 3, 3, 2 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] =
+ (uint8_t)(((coloron >> 5) & 0x7) * maxdac / 7);
+ new_green[coloron] =
+ (uint8_t)(((coloron >> 2) & 0x7) * maxdac / 7);
+ new_blue[coloron] =
+ (uint8_t)((coloron & 0x3) * maxdac / 3);
+ }
+ break;
+
+ case 15: /* 5, 5, 5 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] =
+ (uint8_t)((coloron / 8) * maxdac / 31);
+ new_green[coloron] =
+ (uint8_t)((coloron / 8) * maxdac / 31);
+ new_blue[coloron] =
+ (uint8_t)((coloron / 8) * maxdac / 31);
+ }
+ break;
+
+ case 16: /* 5, 6, 5 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] =
+ (uint8_t)((coloron / 8) * maxdac / 31);
+ new_green[coloron] =
+ (uint8_t)((coloron / 4) * maxdac / 63);
+ new_blue[coloron] =
+ (uint8_t)((coloron / 8) * maxdac / 31);
+ }
+ break;
+
+ default: /* 8, 8, 8 */
+ for (coloron = 0; coloron < 256; coloron++) {
+ new_red[coloron] =
+ (uint8_t)(coloron * maxdac / 255);
+ new_green[coloron] =
+ (uint8_t)(coloron * maxdac / 255);
+ new_blue[coloron] =
+ (uint8_t)(coloron * maxdac / 255);
+ }
+ break;
+ }
+
+ /* Don't set the palet if it matches what we will set. */
- /*
- * first check if the hardware is already initialized.
- * If not, abort
- */
- ioctl(pAST->fd, AST_GET_STATUS_FLAGS, &status);
- if (!(status & AST_STATUS_HW_INITIALIZED))
- return -1;
+ for (coloron = 0; coloron < 256; coloron++) {
+ if ((ast_info.ast_red[coloron] != new_red[coloron]) ||
+ (ast_info.ast_green[coloron] != new_green[coloron]) ||
+ (ast_info.ast_blue[coloron] != new_blue[coloron]))
+ break;
+ }
+
+ if (coloron == 256)
+ return (0);
+
+ ast_info.ast_palet_changed = 1;
+
+ for (coloron = 0; coloron < 256; coloron++) {
+ if (ast_set_reg(DAC_INDEX_WRITE, coloron) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_set_reg(DAC_DATA, new_red[coloron]) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_set_reg(DAC_DATA, new_green[coloron]) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_set_reg(DAC_DATA, new_blue[coloron]) != 0)
+ status = -1;
- pAST->MMIO2D = 0;
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+ }
+
+ return (status);
+}
+
+
+int
+ast_restore_palet(
+ void)
+{
+ register uint_t coloron;
+ register int status = 1;
+ uchar_t junk;
+
+ if (!ast_info.ast_palet_changed)
+ return (0);
+
+ for (coloron = 0; coloron < 256; coloron++) {
+ if (ast_set_reg(DAC_INDEX_WRITE, coloron) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_set_reg(DAC_DATA, ast_info.ast_red[coloron]) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_set_reg(DAC_DATA, ast_info.ast_green[coloron]) != 0)
+ status = -1;
- ASTOpenKey(pAST->fd);
-
- /*
- * get the VDE
- */
- ASTGetIndexRegMask(pAST->fd, CRTC_PORT, 0x01, 0xff, &val);
- pAST->screenWidth = ((int)(val + 1)) << 3;
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+
+ if (ast_set_reg(DAC_DATA, ast_info.ast_blue[coloron]) != 0)
+ status = -1;
+
+ if (ast_get_reg(&junk, SEQ_PORT) != 0)
+ status = -1;
+ }
+
+ ast_info.ast_palet_changed = 0;
+ return (status);
+}
+
+
+uint_t
+ast_color(
+ register uint_t const red,
+ register uint_t const green,
+ register uint_t const blue)
+{
+ register uint_t value;
- switch (pAST->screenWidth) {
- case 1920:
- case 1600:
- pAST->screenHeight = 1200;
+ switch (ast_info.ast_depth) {
+ case 8: /* 3, 3, 2 */
+ value = ((red >> 5) & 0x7) << 5;
+ value |= ((green >> 5) & 0x7) << 2;
+ value |= (blue >> 6) & 0x3;
+ break;
+
+ case 15: /* 5, 5, 5 */
+ value = ((red >> 3) & 0x1f) << 10;
+ value |= ((green >> 3) & 0x1f) << 5;
+ value |= (blue >> 3) & 0x1f;
+ break;
+
+ case 16: /* 5, 6, 5 */
+ value = ((red >> 3) & 0x1f) << 11;
+ value |= ((green >> 2) & 0x3f) << 5;
+ value |= (blue >> 3) & 0x1f;
+ break;
+
+ default: /* 8, 8, 8 */
+ value = (red & 0xff) << 16;
+ value |= (green & 0xff) << 8;
+ value |= blue & 0xff;
break;
- case 1280:
- pAST->screenHeight = 1024;
+ }
+
+ return (value);
+}
+
+
+int
+ast_open_key(
+ void)
+{
+ if (ast_set_index_reg(CRTC_PORT, 0x80, 0xA8) != 0)
+ return (-1);
+ return (0);
+}
+
+
+int
+ast_fill_solid_rect(
+ register uint_t const x1,
+ register uint_t const y1,
+ register uint_t const x2,
+ register uint_t const y2,
+ register uint_t const fg)
+{
+ register uint_t cmdreg;
+
+ cmdreg = CMD_BITBLT | CMD_PAT_FGCOLOR | 0xf000;
+ switch (ast_info.ast_pixelsize) {
+ case 1:
+ cmdreg |= CMD_COLOR_08;
break;
- case 1024:
- pAST->screenHeight = 768;
+ case 2:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 3:
+ case 4:
+ default:
+ cmdreg |= CMD_COLOR_32;
break;
- case 800:
- pAST->screenHeight = 600;
+ }
+
+ if (!ast_store_mmio(MMIOREG_DST_PITCH,
+ (ast_info.ast_linesize << 16) | MASK_DST_HEIGHT))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_FG, fg))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_DST_BASE, 0))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_DST_XY,
+ (x1 << 16) | y1))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_RECT_XY,
+ ((x2 - x1) << 16) | (y2 - y1)))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_CMD, cmdreg))
+ return (0);
+
+ return (1);
+}
+
+
+int
+ast_fill_pattern_rect(
+ register uint_t const x1,
+ register uint_t const y1,
+ register uint_t const x2,
+ register uint_t const y2,
+ register uint_t const bg,
+ register uint_t const fg,
+ register uint64_t const pat)
+{
+ register uint_t cmdreg;
+
+ cmdreg = CMD_BITBLT | CMD_PAT_MONOMASK | 0xf000;
+ switch (ast_info.ast_pixelsize) {
+ case 1:
+ cmdreg |= CMD_COLOR_08;
break;
- case 640:
+ case 2:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 3:
+ case 4:
default:
- pAST->screenHeight = 480;
+ cmdreg |= CMD_COLOR_32;
break;
}
- /*
- * get the display depth info
- */
- ASTGetIndexRegMask(pAST->fd, CRTC_PORT, 0xA2, 0xff, &val);
- if (val & 0x80) {
- /* 32 bits */
- pAST->bytesPerPixel = 4;
- pAST->read32 = (PFNRead32) ASTMMIORead32;
- pAST->write32 = (PFNWrite32) ASTMMIOWrite32;
-
- } else {
- pAST->bytesPerPixel = 1;
- pAST->read32 = (PFNRead32) ASTMMIORead32_8pp;
- pAST->write32 = (PFNWrite32) ASTMMIOWrite32_8pp;
+ if (!ast_store_mmio(MMIOREG_DST_PITCH,
+ (ast_info.ast_linesize << 16) | MASK_DST_HEIGHT))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_FG, fg))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_BG, bg))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_MONO1, (uint_t)(pat >> 32)))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_MONO2, (uint_t)pat))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_DST_BASE, 0))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_DST_XY,
+ (x1 << 16) | y1))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_RECT_XY,
+ ((x2 - x1) << 16) | (y2 - y1)))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_CMD, cmdreg))
+ return (0);
+
+ return (1);
+}
+
+
+int
+ast_draw_solid_line(
+ register uint_t const x1,
+ register uint_t const y1,
+ register uint_t const x2,
+ register uint_t const y2,
+ register uint_t const fg)
+{
+ register uint_t cmdreg;
+ register uint_t GAbsX;
+ register uint_t GAbsY;
+ register uint_t MM;
+ register uint_t mm;
+ register int err;
+ register int k1;
+ register int k2;
+ register int xm;
+
+ cmdreg = 0xf000 | CMD_LINEDRAW | CMD_ENABLE_CLIP |
+ CMD_NOT_DRAW_LAST_PIXEL;
+ switch (ast_info.ast_pixelsize) {
+ case 1:
+ cmdreg |= CMD_COLOR_08;
+ break;
+ case 2:
+ cmdreg |= CMD_COLOR_16;
+ break;
+ case 3:
+ case 4:
+ default:
+ cmdreg |= CMD_COLOR_32;
+ break;
}
- pAST->screenPitch = pAST->screenWidth * pAST->bytesPerPixel;
+ if (x1 < x2)
+ GAbsX = x2 - x1;
+ else
+ GAbsX = x1 - x2;
+
+ if (y1 < y2)
+ GAbsY = y2 - y1;
+ else
+ GAbsY = y1 - y2;
+
+ if (GAbsX >= GAbsY) {
+ MM = GAbsX;
+ mm = GAbsY;
+ xm = 1;
+ } else {
+ MM = GAbsY;
+ mm = GAbsX;
+ xm = 0;
+ }
+
+ if (x1 >= x2)
+ cmdreg |= CMD_X_DEC;
+
+ if (y1 >= y2)
+ cmdreg |= CMD_Y_DEC;
+
+ err = (int)(2 * mm) - (int)MM;
+ k1 = 2 * mm;
+ k2 = (int)(2 * mm) - (int)(2 * MM);
- /*
- * Enable MMIO
- */
- ASTSetIndexRegMask(pAST->fd, CRTC_PORT, 0xA1, 0xff, 0x04);
+ if (!ast_store_mmio(MMIOREG_DST_BASE, 0))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_DST_PITCH,
+ (ast_info.ast_linesize << 16) | MASK_DST_HEIGHT))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_FG, fg))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_LINE_XY,
+ (x1 << 16) | y1))
+ return (0);
- return 0;
+ if (!ast_store_mmio(MMIOREG_LINE_ERR,
+ (xm << 24) | (err & MASK_LINE_ERR)))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_LINE_WIDTH,
+ (MM & MASK_LINE_WIDTH) << 16))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_LINE_K1,
+ (k1 & MASK_LINE_K1)))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_LINE_K2,
+ (k2 & MASK_LINE_K2)))
+ return (0);
+
+ if (!ast_store_mmio(MMIOREG_CMD, cmdreg))
+ return (0);
+
+ return (1);
}
int
-ast_map_mem(struct ast_info *pAST, return_packet *rp, int test)
+ast_unmap_mem(
+ register return_packet *const rp,
+ register int const test)
{
- struct pci_info pci_info;
- int pageSize, size;
- int fd = pAST->fd;
+ if (ast_unmap_fb() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unmap framebuffer failed");
+ return (-1);
+ }
+
+ if (ast_unmap_mmio() != 0) {
+ gfx_vts_set_message(rp, 1, test, "unmap MMIO failed");
+ return (-1);
+ }
+
+ return (0);
+}
+
- if (ast_get_pci_info(fd, &pci_info) == -1) {
- gfx_vts_set_message(rp, 1, test, "get pci info failed");
- return -1;
- }
+int
+ast_unmap_fb(
+ void)
+{
+ register int status;
+
+ if (ast_info.ast_fb_ptr == NULL)
+ return (0);
+
+ status = munmap((char *)ast_info.ast_fb_ptr, ast_info.ast_fb_size);
+ ast_info.ast_fb_ptr = NULL;
+
+ return (status);
+}
- if (ast_get_mem_info(&pci_info, pAST) == -1) {
- gfx_vts_set_message(rp, 1, test, "get mem info failed");
- return -1;
- }
+int
+ast_unmap_mmio(
+ void)
+{
+ register int status;
- /*
- * Map framebuffer
- */
- pageSize = getpagesize();
- size = pAST->FBMapSize + (pageSize - 1) & (~(pageSize - 1));
+ if (ast_info.ast_mmio_ptr == NULL)
+ return (0);
- pAST->FBvaddr = (unsigned char *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
- fd, pAST->FBPhysAddr);
+ status = munmap((char *)ast_info.ast_mmio_ptr,
+ ast_info.ast_mmio_size);
+ ast_info.ast_mmio_ptr = NULL;
- if (pAST->FBvaddr == MAP_FAILED) {
- gfx_vts_set_message(rp, 1, test, "map framebuffer failed");
- return -1;
- }
+ return (status);
+}
+
- /*
- * Map MMIO
- */
- size = pAST->MMIOMapSize + (pageSize - 1) & (~(pageSize - 1));
+int
+ast_store_mmio(
+ register uint_t const port,
+ register uint_t const value)
+{
+ register uint_t readvalue;
+ register hrtime_t starttime;
+ register hrtime_t curtime;
+ register hrtime_t endtime;
+ register ulong_t count = 0;
+
+ ast_mmio_write32(port, value);
+ readvalue = ast_mmio_read32(port);
+
+ if (readvalue == value)
+ return (1);
- pAST->MMIOvaddr = (unsigned char *)mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED,
- fd, pAST->MMIOPhysAddr);
+ starttime = gethrtime();
+ endtime = starttime + ast_loop_time;
+
+ do {
+ count++;
+ ast_mmio_write32(port, value);
+ readvalue = ast_mmio_read32(port);
- if (pAST->MMIOvaddr == MAP_FAILED) {
- gfx_vts_set_message(rp, 1, test, "map MMIO failed");
- return -1;
- }
+ if (readvalue == value)
+ return (1);
+ curtime = gethrtime();
+ } while (curtime < endtime);
- return 0;
+ ast_mmio_write32(port, value);
+ readvalue = ast_mmio_read32(port);
+
+ if (readvalue == value)
+ return (1);
+
+ return (0);
}
int
-ast_unmap_mem(struct ast_info *pAST, return_packet *rp, int test)
+ast_get_index_reg(
+ register uchar_t *const valueptr,
+ register uchar_t const offset,
+ register uchar_t const index)
+{
+ if (ast_set_reg(offset, index) != 0)
+ return (-1);
+
+ if (ast_get_reg(valueptr, offset + 1) != 0)
+ return (-1);
+
+ return (0);
+}
+
+
+int
+ast_set_index_reg(
+ register uchar_t const offset,
+ register uchar_t const index,
+ register uchar_t const value)
+{
+ if (ast_set_reg(offset, index) != 0)
+ return (-1);
+
+ if (ast_set_reg(offset + 1, value) != 0)
+ return (-1);
+
+ return (0);
+}
+
+
+int
+ast_get_reg(
+ register uchar_t *const valueptr,
+ register uchar_t const offset)
{
- /*
- * Unmap Frame Buffer
- */
+ ast_io_reg io_reg;
+
+ io_reg.offset = offset;
+ io_reg.value = (uchar_t)-1;
+
+ if (ioctl(ast_info.ast_fd, AST_GET_IO_REG, &io_reg) != 0)
+ return (-1);
+
+ *valueptr = io_reg.value;
+ return (0);
+}
+
+
+int
+ast_set_reg(
+ register uchar_t const offset,
+ register uchar_t const value)
+{
+ ast_io_reg io_reg;
+
+ io_reg.offset = offset;
+ io_reg.value = value;
+
+ if (ioctl(ast_info.ast_fd, AST_SET_IO_REG, &io_reg) != 0)
+ return (-1);
+
+ return (0);
+}
+
+
+uint_t
+ast_mmio_read32(
+ register uint_t const port)
+{
+ register uint_t volatile const *const addr =
+ (uint_t volatile const *) (ast_info.ast_mmio_ptr + port);
+ register uint_t value;
+
+ union {
+ uint_t l;
+ ushort_t w[2];
+ uchar_t b[4];
+ } data;
+
+ data.l = *addr;
- if (munmap((void *)pAST->FBvaddr, pAST->FBMapSize) == -1) {
- gfx_vts_set_message(rp, 1, test, "unmap framebuffer failed");
- return -1;
- }
+ switch (ast_info.ast_endian) {
+ case 0: /* little endian */
+ value = ((uint_t)data.b[3] << 24) |
+ ((uint_t)data.b[2] << 16) |
+ ((uint_t)data.b[1] << 8) |
+ (uint_t)data.b[0];
+ break;
+
+ case 1: /* big endian 16 */
+ case 2: /* big endian 32 */
+ value = ((uint_t)data.b[0] << 24) |
+ ((uint_t)data.b[1] << 16) |
+ ((uint_t)data.b[2] << 8) |
+ (uint_t)data.b[3];
+ break;
+ }
+
+ return (value);
+}
+
+
+
+void
+ast_mmio_write32(
+ register uint_t const port,
+ register uint_t const val)
+{
+ register uint_t volatile *const addr =
+ (uint_t volatile *) (ast_info.ast_mmio_ptr + port);
+ register uint_t value;
+
+ union {
+ uint_t l;
+ ushort_t w[2];
+ uchar_t b[4];
+ } data;
+
+ data.l = val;
- if (munmap((void *)pAST->MMIOvaddr, pAST->MMIOMapSize) == -1) {
- gfx_vts_set_message(rp, 1, test, "unmap MMIO failed");
- return -1;
- }
+ switch (ast_info.ast_endian) {
+ case 0: /* little endian */
+ value = ((uint_t)data.b[3] << 24) |
+ ((uint_t)data.b[2] << 16) |
+ ((uint_t)data.b[1] << 8) |
+ (uint_t)data.b[0];
+ break;
+
+ case 1: /* big endian 16 */
+ case 2: /* big endian 32 */
+ value = ((uint_t)data.b[0] << 24) |
+ ((uint_t)data.b[1] << 16) |
+ ((uint_t)data.b[2] << 8) |
+ (uint_t)data.b[3];
+ break;
+ }
+
+ *addr = value;
+}
+
- return 0;
+int
+ast_wait_idle(
+ void)
+{
+ register hrtime_t starttime;
+ register hrtime_t curtime;
+ register hrtime_t endtime;
+ register ulong_t count = 0;
+
+ if (!(ast_mmio_read32(MMIOREG_STAT) & STAT_BUSY))
+ return (1);
+
+ starttime = gethrtime();
+ endtime = starttime + ast_loop_time;
+
+ do {
+ count++;
+ if (!(ast_mmio_read32(MMIOREG_STAT) & STAT_BUSY))
+ return (1);
+ curtime = gethrtime();
+ } while (curtime < endtime);
+
+ if (!(ast_mmio_read32(MMIOREG_STAT) & STAT_BUSY))
+ return (1);
+
+ return (0);
}