mapper.c revision 1368
1117N/A/*
1368N/A * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
1117N/A *
1117N/A * Permission is hereby granted, free of charge, to any person obtaining a
1117N/A * copy of this software and associated documentation files (the "Software"),
1117N/A * to deal in the Software without restriction, including without limitation
1117N/A * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1117N/A * and/or sell copies of the Software, and to permit persons to whom the
1117N/A * Software is furnished to do so, subject to the following conditions:
1117N/A *
1117N/A * The above copyright notice and this permission notice (including the next
1117N/A * paragraph) shall be included in all copies or substantial portions of the
1117N/A * Software.
1117N/A *
1117N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1117N/A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1117N/A * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1117N/A * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1117N/A * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1117N/A * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1117N/A * DEALINGS IN THE SOFTWARE.
1117N/A */
1117N/A
1368N/A#include "libvtsSUNWefb.h" /* Common VTS library definitions */
1368N/A#include "efb.h"
1368N/A
1368N/A/*
1368N/A * efb_test_open()
1368N/A *
1368N/A * This test will open the device, read and write some registers
1368N/A * after mmaping in the register and frame buffer spaces.
1368N/A */
1368N/A
1368N/Areturn_packet *
1368N/Aefb_test_open(
1368N/A register int const fd)
1368N/A{
1368N/A static return_packet rp;
1368N/A int rc = 0;
1368N/A struct vis_identifier vis_identifier;
1368N/A
1368N/A memset(&rp, 0, sizeof (return_packet));
1368N/A
1368N/A if (gfx_vts_check_fd(fd, &rp))
1368N/A return (&rp);
1368N/A
1368N/A TraceMessage(VTS_TEST_STATUS, "efb_test_open", "check_fd passed.\n");
1368N/A
1368N/A /* vis identifier will do this */
1368N/A rc = ioctl(fd, VIS_GETIDENTIFIER, &vis_identifier);
1117N/A
1368N/A TraceMessage(VTS_TEST_STATUS, "efb_test_open", "rc = %d\n", rc);
1368N/A
1368N/A if (rc != 0) {
1368N/A gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
1368N/A return (&rp);
1368N/A }
1368N/A
1368N/A if (strncmp(vis_identifier.name, "SUNWefb", 7) != 0 &&
1368N/A strncmp(vis_identifier.name, "ORCLefb", 7) != 0) {
1368N/A gfx_vts_set_message(&rp, 1, GRAPHICS_ERR_OPEN, NULL);
1368N/A return (&rp);
1368N/A }
1117N/A
1368N/A efb_block_signals();
1368N/A
1368N/A efb_lock_display();
1368N/A
1368N/A map_me(&rp, fd);
1368N/A
1368N/A efb_unlock_display();
1368N/A
1368N/A efb_restore_signals();
1368N/A
1368N/A TraceMessage(VTS_DEBUG, "efb_test_open", "Open completed OK\n");
1368N/A
1368N/A return (&rp);
1368N/A
1368N/A} /* efb_test_open() */
1117N/A
1117N/A
1117N/A/*
1117N/A * map_me()
1117N/A */
1117N/A
1368N/Aint
1368N/Amap_me(
1368N/A register return_packet *const rp,
1368N/A register int const fd)
1117N/A{
1368N/A memset(&efb_info, 0, sizeof (efb_info));
1368N/A efb_info.efb_fd = fd;
1117N/A
1368N/A if (efb_map_mem(rp, GRAPHICS_ERR_OPEN) != 0)
1368N/A return (-1);
1117N/A
1368N/A if (efb_test_semaphore(rp, GRAPHICS_ERR_OPEN) != 0) {
1368N/A efb_unmap_mem(NULL, GRAPHICS_ERR_OPEN);
1368N/A return (-1);
1117N/A }
1117N/A
1117N/A /*
1117N/A * Unmap the registers & frame buffers memory
1117N/A */
1368N/A if (efb_unmap_mem(rp, GRAPHICS_ERR_OPEN) != 0)
1368N/A return (-1);
1117N/A
1368N/A return (0);
1117N/A} /* map_me() */
1117N/A
1368N/A#define RADEON_SW_SEMAPHORE_MASK 0xffff
1368N/A#define SEMAPHORE_XOR_VALUE 0x5555
1368N/A
1368N/Aint
1368N/Aefb_test_semaphore(
1368N/A register return_packet *const rp,
1368N/A register int const test)
1368N/A{
1368N/A register uint_t save_semaphore;
1368N/A register uint_t new_semaphore;
1368N/A
1368N/A /*
1368N/A * Test the software bits of the semaphore register.
1368N/A * Complement the bits, and see if they read back
1368N/A * complemented.
1368N/A */
1368N/A
1368N/A /* Save the original semaphore. */
1368N/A
1368N/A save_semaphore = REGR(RADEON_SW_SEMAPHORE);
1368N/A
1368N/A /* Write the semaphore with the software bits complemented. */
1368N/A REGW(RADEON_SW_SEMAPHORE,
1368N/A save_semaphore ^ SEMAPHORE_XOR_VALUE);
1368N/A
1368N/A /* Get the new semaphore. */
1368N/A
1368N/A new_semaphore = REGR(RADEON_SW_SEMAPHORE);
1368N/A
1368N/A /* Restore the old semaphore. */
1368N/A
1368N/A REGW(RADEON_SW_SEMAPHORE, save_semaphore);
1368N/A
1368N/A /* Check if the software bits did complement. */
1368N/A
1368N/A if ((save_semaphore & RADEON_SW_SEMAPHORE_MASK) !=
1368N/A ((new_semaphore ^ SEMAPHORE_XOR_VALUE) &
1368N/A RADEON_SW_SEMAPHORE_MASK)) {
1368N/A printf("semaphore 0x%08x 0x%08x 0x%08x\n",
1368N/A save_semaphore, new_semaphore,
1368N/A save_semaphore ^ SEMAPHORE_XOR_VALUE);
1368N/A
1368N/A gfx_vts_set_message(rp, 1, test, "semaphore test failed");
1368N/A return (0);
1368N/A }
1368N/A return (1);
1368N/A}
1117N/A
1117N/A/* End of mapper.c */