update vivant gpu(gc830) driver

This commit is contained in:
杜坤明
2010-11-05 20:13:19 +08:00
parent 7fa3d11bb7
commit 7abcfd1c42
52 changed files with 40211 additions and 0 deletions

2
drivers/staging/Kconfig Normal file → Executable file
View File

@@ -130,5 +130,7 @@ source "drivers/staging/rk2818/rk2818_dsp/Kconfig"
source "drivers/staging/rk2818/rk1000_control/Kconfig"
source "drivers/staging/rk2818/rk2818_power/Kconfig"
source "drivers/staging/rk29/vivante/Kconfig"
endif # !STAGING_EXCLUDE_BUILD
endif # STAGING

1
drivers/staging/Makefile Normal file → Executable file
View File

@@ -48,3 +48,4 @@ obj-$(CONFIG_RK2818_DSP) += rk2818/rk2818_dsp/
obj-$(CONFIG_RK1000_CONTROL) += rk2818/rk1000_control/
obj-$(CONFIG_RK1000_TVOUT) += rk2818/rk1000_tv/
obj-$(CONFIG_RK2818_POWER) += rk2818/rk2818_power/
obj-$(CONFIG_VIVANTE) += rk29/vivante/

View File

@@ -0,0 +1,171 @@
##############################################################################
#
# Copyright (C) 2005 - 2010 by Vivante Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the license, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##############################################################################
#
# Linux build file for kernel HAL driver.
#
include $(AQROOT)/config
DRIVER_OUT_DIR = hal/driver
KERNEL_DIR ?= $(TOOL_DIR)/kernel
OS_KERNEL_DIR := hal/os/linux/kernel
ARCH_KERNEL_DIR := arch/$(notdir $(AQARCH))/hal/kernel
HAL_KERNEL_DIR := hal/kernel
EXTRA_CFLAGS += -Werror
OBJS := $(OS_KERNEL_DIR)/gc_hal_kernel_debug.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_device.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_driver.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_linux.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_os.o
ifeq ($(USE_3D_VG), 1)
OBJS += $(HAL_KERNEL_DIR)/gc_hal_kernel.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_command.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_event.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_heap.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_mmu.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_video_memory.o
OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o
else
OBJS += $(HAL_KERNEL_DIR)/gc_hal_kernel.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_command.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_heap.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_interrupt.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_mmu.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_video_memory.o
OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o \
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_command.o
endif
ifeq ($(KERNELRELEASE), )
.PHONY: all clean install
# Define targets.
all:
@mkdir -p $(DRIVER_OUT_DIR)
@make V=$(V) ARCH=$(ARCH_TYPE) -C $(KERNEL_DIR) SUBDIRS=`pwd` modules
clean:
@rm -rf $(OBJS)
@rm -rf $(DRIVER_OUT_DIR)
@rm -rf modules.order Module.symvers
install: all
@mkdir -p $(SDK_DIR)/drivers
@cp $(DRIVER_OUT_DIR)/galcore.ko $(SDK_DIR)/drivers
else
EXTRA_CFLAGS += -DLINUX -DDRIVER
ifeq ($(ENUM_WORKAROUND), 1)
EXTRA_CFLAGS += -DENUM_WORKAROUND=1
else
EXTRA_CFLAGS += -DENUM_WORKAROUND=0
endif
ifeq ($(FLAREON),1)
EXTRA_CFLAGS += -DFLAREON
endif
ifeq ($(DEBUG), 1)
EXTRA_CFLAGS += -DDBG=1 -DDEBUG -D_DEBUG
else
EXTRA_CFLAGS += -DDBG=0
endif
ifeq ($(NO_DMA_COHERENT), 1)
EXTRA_CFLAGS += -DNO_DMA_COHERENT
endif
ifeq ($(ENABLE_ARM_L2_CACHE), 1)
EXTRA_CFLAGS += -DENABLE_ARM_L2_CACHE=1
else
EXTRA_CFLAGS += -DENABLE_ARM_L2_CACHE=0
endif
ifeq ($(CONFIG_DOVE_GPU), 1)
EXTRA_CFLAGS += -DCONFIG_DOVE_GPU=1
endif
ifeq ($(gcdNO_POWER_MANAGEMENT), 1)
EXTRA_CFLAGS += -DgcdNO_POWER_MANAGEMENT=1
else
EXTRA_CFLAGS += -DgcdNO_POWER_MANAGEMENT=0
endif
ifneq ($(USE_PLATFORM_DRIVER), 0)
EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=1
else
EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=0
endif
ifeq ($(USE_PROFILER), 1)
EXTRA_CFLAGS += -DVIVANTE_PROFILER=1
else
EXTRA_CFLAGS += -DVIVANTE_PROFILER=0
endif
ifeq ($(ANDROID), 1)
EXTRA_CFLAGS += -DANDROID=1
endif
ifeq ($(ENABLE_GPU_CLOCK_BY_DRIVER), 1)
EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=1
else
EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=0
endif
ifeq ($(USE_NEW_LINUX_SIGNAL), 1)
EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=1
else
EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=0
endif
ifeq ($(NO_USER_DIRECT_ACCESS_FROM_KERNEL), 1)
EXTRA_CFLAGS += -DNO_USER_DIRECT_ACCESS_FROM_KERNEL=1
else
EXTRA_CFLAGS += -DNO_USER_DIRECT_ACCESS_FROM_KERNEL=0
endif
EXTRA_CFLAGS += -I$(AQROOT)/hal/inc
EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel
EXTRA_CFLAGS += -I$(AQARCH)/hal/kernel
EXTRA_CFLAGS += -I$(AQARCH)/cmodel/inc
EXTRA_CFLAGS += -I$(AQROOT)/hal/user
obj-m = $(DRIVER_OUT_DIR)/galcore.o
$(DRIVER_OUT_DIR)/galcore-objs = $(OBJS)
endif

View File

@@ -0,0 +1,7 @@
menu "GPU Vivante"
config VIVANTE
tristate "ROCKCHIP Vivante GPU"
default y
help
Vivante GPU module.
endmenu

View File

@@ -0,0 +1,202 @@
##############################################################################
#
# Copyright (C) 2005 - 2010 by Vivante Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the license, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##############################################################################
#
# Linux build file for kernel HAL driver.
#
################################################################
# Arch.
ARCH_TYPE ?= arm
CPU_TYPE ?= arm920
CPU_ARCH ?= 0
STATIC_LINK ?= 0
EGL_API_FB ?= 0
USE_VDK ?= 0
USE_PROFILER ?= 0
USE_SW_FB ?= 0
USE_3D_VG =1
ABI ?= 0
ANDROID ?= 0
EGL_API_ANDROID ?= 0
ENUM_WORKAROUND ?= 0
ENDIANNESS ?=
QNX ?= 0
LINUX_OABI ?= 0
USE_ARMCC ?= 0
ifeq ($(LINUX_OABI), 1)
ABI ?= 0
else
ABI ?= aapcs-linux
endif
################################################################
# Force to use dma_coherent_* stuff.
NO_DMA_COHERENT ?= 0
################################################################
# Set this value to 1 if you are using ARM L2 cache.
ENABLE_ARM_L2_CACHE = 0
################################################################
# Set this value to 1 if you are using DOVE board.
CONFIG_DOVE_GPU = 0
ENABLE_GPU_CLOCK_BY_DRIVER = 0
AQROOT ?= drivers/staging/rk29/vivante
AQARCH ?= $(AQROOT)/arch/XAQ2
#include $(AQROOT)/config
ARCH_TYPE ?= arm
SDK_DIR ?= $(AQROOT)/build/sdk
USE_3D_VG = 1
DEBUG = 1
#DRIVER_OUT_DIR = hal/driver
#KERNEL_DIR ?= $(TOOL_DIR)/kernel
OS_KERNEL_DIR := hal/os/linux/kernel
ARCH_KERNEL_DIR := arch/XAQ2/hal/kernel
HAL_KERNEL_DIR := hal/kernel
EXTRA_CFLAGS += -Werror
OBJS := $(OS_KERNEL_DIR)/gc_hal_kernel_debug.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_device.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_driver.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_linux.o \
$(OS_KERNEL_DIR)/gc_hal_kernel_os.o
ifeq ($(USE_3D_VG), 1)
OBJS += $(HAL_KERNEL_DIR)/gc_hal_kernel.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_command.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_event.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_heap.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_mmu.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_video_memory.o
OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o
else
OBJS += $(HAL_KERNEL_DIR)/gc_hal_kernel.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_command.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_heap.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_interrupt.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_mmu.o \
$(HAL_KERNEL_DIR)/gc_hal_kernel_video_memory.o
OBJS += $(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware.o \
$(ARCH_KERNEL_DIR)/gc_hal_kernel_hardware_command.o
endif
EXTRA_CFLAGS += -DLINUX -DDRIVER
ifeq ($(ENUM_WORKAROUND), 1)
EXTRA_CFLAGS += -DENUM_WORKAROUND=1
else
EXTRA_CFLAGS += -DENUM_WORKAROUND=0
endif
ifeq ($(FLAREON),1)
EXTRA_CFLAGS += -DFLAREON
endif
ifeq ($(DEBUG), 1)
EXTRA_CFLAGS += -DDBG=1 -DDEBUG -D_DEBUG
else
EXTRA_CFLAGS += -DDBG=0
endif
ifeq ($(NO_DMA_COHERENT), 1)
EXTRA_CFLAGS += -DNO_DMA_COHERENT
endif
ifeq ($(ENABLE_ARM_L2_CACHE), 1)
EXTRA_CFLAGS += -DENABLE_ARM_L2_CACHE=1
else
EXTRA_CFLAGS += -DENABLE_ARM_L2_CACHE=0
endif
ifeq ($(CONFIG_DOVE_GPU), 1)
EXTRA_CFLAGS += -DCONFIG_DOVE_GPU=1
endif
ifeq ($(gcdNO_POWER_MANAGEMENT), 1)
EXTRA_CFLAGS += -DgcdNO_POWER_MANAGEMENT=1
else
EXTRA_CFLAGS += -DgcdNO_POWER_MANAGEMENT=0
endif
ifneq ($(USE_PLATFORM_DRIVER), 0)
EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=1
else
EXTRA_CFLAGS += -DUSE_PLATFORM_DRIVER=0
endif
ifeq ($(USE_PROFILER), 1)
EXTRA_CFLAGS += -DVIVANTE_PROFILER=1
else
EXTRA_CFLAGS += -DVIVANTE_PROFILER=0
endif
ifeq ($(ANDROID), 1)
EXTRA_CFLAGS += -DANDROID=1
endif
ifeq ($(ENABLE_GPU_CLOCK_BY_DRIVER), 1)
EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=1
else
EXTRA_CFLAGS += -DENABLE_GPU_CLOCK_BY_DRIVER=0
endif
ifeq ($(USE_NEW_LINUX_SIGNAL), 1)
EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=1
else
EXTRA_CFLAGS += -DUSE_NEW_LINUX_SIGNAL=0
endif
ifeq ($(NO_USER_DIRECT_ACCESS_FROM_KERNEL), 1)
EXTRA_CFLAGS += -DNO_USER_DIRECT_ACCESS_FROM_KERNEL=1
else
EXTRA_CFLAGS += -DNO_USER_DIRECT_ACCESS_FROM_KERNEL=0
endif
EXTRA_CFLAGS += -I$(AQROOT)/hal/inc
EXTRA_CFLAGS += -I$(AQROOT)/hal/kernel
EXTRA_CFLAGS += -I$(AQARCH)/hal/kernel
EXTRA_CFLAGS += -I$(AQARCH)/cmodel/inc
EXTRA_CFLAGS += -I$(AQROOT)/hal/user
obj-$(CONFIG_VIVANTE) += galcore.o
galcore-objs := $(OBJS)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_kernel_hardware_h_
#define __gc_hal_kernel_hardware_h_
#ifdef __cplusplus
extern "C" {
#endif
/* gckHARDWARE object. */
struct _gckHARDWARE
{
/* Object. */
gcsOBJECT object;
/* Pointer to gctKERNEL object. */
gckKERNEL kernel;
/* Pointer to gctOS object. */
gckOS os;
/* Chip characteristics. */
gceCHIPMODEL chipModel;
gctUINT32 chipRevision;
gctUINT32 chipFeatures;
gctUINT32 chipMinorFeatures0;
gctUINT32 chipMinorFeatures1;
gctBOOL allowFastClear;
gctBOOL allowCompression;
gctUINT32 powerBaseAddress;
gctBOOL extraEventStates;
gctUINT32 streamCount;
gctUINT32 registerMax;
gctUINT32 threadCount;
gctUINT32 shaderCoreCount;
gctUINT32 vertexCacheSize;
gctUINT32 vertexOutputBufferSize;
/* Big endian */
gctBOOL bigEndian;
/* Chip status */
gctPOINTER powerMutex;
gctUINT32 powerProcess;
gctUINT32 powerThread;
gceCHIPPOWERSTATE chipPowerState;
gctUINT32 lastWaitLink;
};
gceSTATUS
gckHARDWARE_GetBaseAddress(
IN gckHARDWARE Hardware,
OUT gctUINT32_PTR BaseAddress
);
gceSTATUS
gckHARDWARE_NeedBaseAddress(
IN gckHARDWARE Hardware,
IN gctUINT32 State,
OUT gctBOOL_PTR NeedBase
);
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_kernel_hardware_h_ */

View File

@@ -0,0 +1,55 @@
##############################################################################
#
# Copyright (C) 2005 - 2010 by Vivante Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the license, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##############################################################################
#
# Linux build file for architecture dependent kernel HAL layer.
#
#
################################################################################
# Include common definitions.
include $(AQROOT)/makefile.linux.def
################################################################################
# Define a shortcut for the main target.
STATIC = 1
TARGET_NAME = libhalarchkernel.a
################################################################################
# Supply additional include directories.
INCLUDE += -I$(AQROOT)/hal/inc
INCLUDE += -I$(AQROOT)/hal/kernel
INCLUDE += -I$(AQARCH)/hal/kernel
INCLUDE += -I$(AQARCH)/cmodel/inc
CFLAGS += $(INCLUDE) -Werror -ansi
################################################################################
# Describe object files.
OBJECTS = $(OBJ_DIR)/gc_hal_kernel_hardware.o
include $(AQROOT)/common.target

View File

@@ -0,0 +1,24 @@
##############################################################################
#
# Copyright (C) 2005 - 2010 by Vivante Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the license, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##############################################################################
ARCH_TYPE ?= arm
SDK_DIR ?= $(AQROOT)/build/sdk
USE_3D_VG = 1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,633 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_driver_h_
#define __gc_hal_driver_h_
#include "gc_hal_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************\
******************************* I/O Control Codes ******************************
\******************************************************************************/
#define gcvHAL_CLASS "galcore"
#define IOCTL_GCHAL_INTERFACE 30000
#define IOCTL_GCHAL_KERNEL_INTERFACE 30001
#define IOCTL_GCHAL_TERMINATE 30002
/******************************************************************************\
********************************* Command Codes ********************************
\******************************************************************************/
typedef enum _gceHAL_COMMAND_CODES
{
/* Generic query. */
gcvHAL_QUERY_VIDEO_MEMORY,
gcvHAL_QUERY_CHIP_IDENTITY,
/* Contiguous memory. */
gcvHAL_ALLOCATE_NON_PAGED_MEMORY,
gcvHAL_FREE_NON_PAGED_MEMORY,
gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY,
gcvHAL_FREE_CONTIGUOUS_MEMORY,
/* Video memory allocation. */
gcvHAL_ALLOCATE_VIDEO_MEMORY, /* Enforced alignment. */
gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY, /* No alignment. */
gcvHAL_FREE_VIDEO_MEMORY,
/* Physical-to-logical mapping. */
gcvHAL_MAP_MEMORY,
gcvHAL_UNMAP_MEMORY,
/* Logical-to-physical mapping. */
gcvHAL_MAP_USER_MEMORY,
gcvHAL_UNMAP_USER_MEMORY,
/* Surface lock/unlock. */
gcvHAL_LOCK_VIDEO_MEMORY,
gcvHAL_UNLOCK_VIDEO_MEMORY,
/* Event queue. */
gcvHAL_EVENT_COMMIT,
gcvHAL_USER_SIGNAL,
gcvHAL_SIGNAL,
gcvHAL_WRITE_DATA,
gcvHAL_COMMIT,
gcvHAL_STALL,
gcvHAL_READ_REGISTER,
gcvHAL_WRITE_REGISTER,
gcvHAL_GET_PROFILE_SETTING,
gcvHAL_SET_PROFILE_SETTING,
gcvHAL_READ_ALL_PROFILE_REGISTERS,
gcvHAL_PROFILE_REGISTERS_2D,
/* Power management. */
gcvHAL_SET_POWER_MANAGEMENT_STATE,
gcvHAL_QUERY_POWER_MANAGEMENT_STATE,
gcvHAL_GET_BASE_ADDRESS,
gcvHAL_SET_IDLE, /* reserved */
/* Queries. */
gcvHAL_QUERY_KERNEL_SETTINGS,
/* Reset. */
gcvHAL_RESET,
/* Map physical address into handle. */
gcvHAL_MAP_PHYSICAL,
/* Debugger stuff. */
gcvHAL_DEBUG,
/* Cache stuff. */
gcvHAL_CACHE,
}
gceHAL_COMMAND_CODES;
/******************************************************************************\
****************************** Interface Structure *****************************
\******************************************************************************/
#define gcdMAX_PROFILE_FILE_NAME 128
typedef struct _gcsHAL_INTERFACE
{
/* Command code. */
gceHAL_COMMAND_CODES command;
/* Status value. */
gceSTATUS status;
/* Handle to this interface channel. */
gctHANDLE handle;
/* Pid of the client. */
gctUINT32 pid;
/* Union of command structures. */
union _u
{
/* gcvHAL_GET_BASE_ADDRESS */
struct _gcsHAL_GET_BASE_ADDRESS
{
/* Physical memory address of internal memory. */
OUT gctUINT32 baseAddress;
}
GetBaseAddress;
/* gcvHAL_QUERY_VIDEO_MEMORY */
struct _gcsHAL_QUERY_VIDEO_MEMORY
{
/* Physical memory address of internal memory. */
OUT gctPHYS_ADDR internalPhysical;
/* Size in bytes of internal memory.*/
OUT gctSIZE_T internalSize;
/* Physical memory address of external memory. */
OUT gctPHYS_ADDR externalPhysical;
/* Size in bytes of external memory.*/
OUT gctSIZE_T externalSize;
/* Physical memory address of contiguous memory. */
OUT gctPHYS_ADDR contiguousPhysical;
/* Size in bytes of contiguous memory.*/
OUT gctSIZE_T contiguousSize;
}
QueryVideoMemory;
/* gcvHAL_QUERY_CHIP_IDENTITY */
struct _gcsHAL_QUERY_CHIP_IDENTITY
{
/* Chip model. */
OUT gceCHIPMODEL chipModel;
/* Revision value.*/
OUT gctUINT32 chipRevision;
/* Supported feature fields. */
OUT gctUINT32 chipFeatures;
/* Supported minor feature fields. */
OUT gctUINT32 chipMinorFeatures;
/* Supported minor feature 1 fields. */
OUT gctUINT32 chipMinorFeatures1;
/* Number of streams supported. */
OUT gctUINT32 streamCount;
/* Total number of temporary registers per thread. */
OUT gctUINT32 registerMax;
/* Maximum number of threads. */
OUT gctUINT32 threadCount;
/* Number of shader cores. */
OUT gctUINT32 shaderCoreCount;
/* Size of the vertex cache. */
OUT gctUINT32 vertexCacheSize;
/* Number of entries in the vertex output buffer. */
OUT gctUINT32 vertexOutputBufferSize;
}
QueryChipIdentity;
/* gcvHAL_MAP_MEMORY */
struct _gcsHAL_MAP_MEMORY
{
/* Physical memory address to map. */
IN gctPHYS_ADDR physical;
/* Number of bytes in physical memory to map. */
IN gctSIZE_T bytes;
/* Address of mapped memory. */
OUT gctPOINTER logical;
}
MapMemory;
/* gcvHAL_UNMAP_MEMORY */
struct _gcsHAL_UNMAP_MEMORY
{
/* Physical memory address to unmap. */
IN gctPHYS_ADDR physical;
/* Number of bytes in physical memory to unmap. */
IN gctSIZE_T bytes;
/* Address of mapped memory to unmap. */
IN gctPOINTER logical;
}
UnmapMemory;
/* gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY */
struct _gcsHAL_ALLOCATE_LINEAR_VIDEO_MEMORY
{
/* Number of bytes to allocate. */
IN OUT gctUINT bytes;
/* Buffer alignment. */
IN gctUINT alignment;
/* Type of allocation. */
IN gceSURF_TYPE type;
/* Memory pool to allocate from. */
IN OUT gcePOOL pool;
/* Allocated video memory. */
OUT gcuVIDMEM_NODE_PTR node;
}
AllocateLinearVideoMemory;
/* gcvHAL_ALLOCATE_VIDEO_MEMORY */
struct _gcsHAL_ALLOCATE_VIDEO_MEMORY
{
/* Width of rectangle to allocate. */
IN OUT gctUINT width;
/* Height of rectangle to allocate. */
IN OUT gctUINT height;
/* Depth of rectangle to allocate. */
IN gctUINT depth;
/* Format rectangle to allocate in gceSURF_FORMAT. */
IN gceSURF_FORMAT format;
/* Type of allocation. */
IN gceSURF_TYPE type;
/* Memory pool to allocate from. */
IN OUT gcePOOL pool;
/* Allocated video memory. */
OUT gcuVIDMEM_NODE_PTR node;
}
AllocateVideoMemory;
/* gcvHAL_FREE_VIDEO_MEMORY */
struct _gcsHAL_FREE_VIDEO_MEMORY
{
/* Allocated video memory. */
IN gcuVIDMEM_NODE_PTR node;
#ifdef __QNXNTO__
/* TODO: This is part of the unlock - why is it here? */
/* Mapped logical address to unmap in user space. */
OUT gctPOINTER memory;
/* Number of bytes to allocated. */
OUT gctSIZE_T bytes;
#endif
}
FreeVideoMemory;
/* gcvHAL_LOCK_VIDEO_MEMORY */
struct _gcsHAL_LOCK_VIDEO_MEMORY
{
/* Allocated video memory. */
IN gcuVIDMEM_NODE_PTR node;
/* Hardware specific address. */
OUT gctUINT32 address;
/* Mapped logical address. */
OUT gctPOINTER memory;
}
LockVideoMemory;
/* gcvHAL_UNLOCK_VIDEO_MEMORY */
struct _gcsHAL_UNLOCK_VIDEO_MEMORY
{
/* Allocated video memory. */
IN gcuVIDMEM_NODE_PTR node;
/* Type of surface. */
IN gceSURF_TYPE type;
/* Flag to unlock surface asynchroneously. */
IN OUT gctBOOL asynchroneous;
}
UnlockVideoMemory;
/* gcvHAL_ALLOCATE_NON_PAGED_MEMORY */
struct _gcsHAL_ALLOCATE_NON_PAGED_MEMORY
{
/* Number of bytes to allocate. */
IN OUT gctSIZE_T bytes;
/* Physical address of allocation. */
OUT gctPHYS_ADDR physical;
/* Logical address of allocation. */
OUT gctPOINTER logical;
}
AllocateNonPagedMemory;
/* gcvHAL_FREE_NON_PAGED_MEMORY */
struct _gcsHAL_FREE_NON_PAGED_MEMORY
{
/* Number of bytes allocated. */
IN gctSIZE_T bytes;
/* Physical address of allocation. */
IN gctPHYS_ADDR physical;
/* Logical address of allocation. */
IN gctPOINTER logical;
}
FreeNonPagedMemory;
/* gcvHAL_EVENT_COMMIT. */
struct _gcsHAL_EVENT_COMMIT
{
/* Event queue. */
IN struct _gcsQUEUE * queue;
}
Event;
/* gcvHAL_COMMIT */
struct _gcsHAL_COMMIT
{
/* Command buffer. */
IN gcoCMDBUF commandBuffer;
/* Context buffer. */
IN gcoCONTEXT contextBuffer;
/* Process handle. */
IN gctHANDLE process;
}
Commit;
/* gcvHAL_MAP_USER_MEMORY */
struct _gcsHAL_MAP_USER_MEMORY
{
/* Base address of user memory to map. */
IN gctPOINTER memory;
/* Size of user memory in bytes to map. */
IN gctSIZE_T size;
/* Info record required by gcvHAL_UNMAP_USER_MEMORY. */
OUT gctPOINTER info;
/* Physical address of mapped memory. */
OUT gctUINT32 address;
}
MapUserMemory;
/* gcvHAL_UNMAP_USER_MEMORY */
struct _gcsHAL_UNMAP_USER_MEMORY
{
/* Base address of user memory to unmap. */
IN gctPOINTER memory;
/* Size of user memory in bytes to unmap. */
IN gctSIZE_T size;
/* Info record returned by gcvHAL_MAP_USER_MEMORY. */
IN gctPOINTER info;
/* Physical address of mapped memory as returned by
gcvHAL_MAP_USER_MEMORY. */
IN gctUINT32 address;
}
UnmapUserMemory;
#if !USE_NEW_LINUX_SIGNAL
/* gcsHAL_USER_SIGNAL */
struct _gcsHAL_USER_SIGNAL
{
/* Command. */
gceUSER_SIGNAL_COMMAND_CODES command;
/* Signal ID. */
IN OUT gctINT id;
/* Reset mode. */
IN gctBOOL manualReset;
/* Wait timedout. */
IN gctUINT32 wait;
/* State. */
IN gctBOOL state;
}
UserSignal;
#endif
/* gcvHAL_SIGNAL. */
struct _gcsHAL_SIGNAL
{
/* Signal handle to signal. */
IN gctSIGNAL signal;
/* Reserved. */
IN gctSIGNAL auxSignal;
/* Process owning the signal. */
IN gctHANDLE process;
#if defined(__QNXNTO__)
/* Client pulse side-channel connection ID. Set by client in gcoOS_CreateSignal. */
IN gctINT32 coid;
/* Set by server. */
IN gctINT32 rcvid;
#endif
/* Event generated from where of pipeline */
IN gceKERNEL_WHERE fromWhere;
}
Signal;
/* gcvHAL_WRITE_DATA. */
struct _gcsHAL_WRITE_DATA
{
/* Address to write data to. */
IN gctUINT32 address;
/* Data to write. */
IN gctUINT32 data;
}
WriteData;
/* gcvHAL_ALLOCATE_CONTIGUOUS_MEMORY */
struct _gcsHAL_ALLOCATE_CONTIGUOUS_MEMORY
{
/* Number of bytes to allocate. */
IN OUT gctSIZE_T bytes;
/* Physical address of allocation. */
OUT gctPHYS_ADDR physical;
/* Logical address of allocation. */
OUT gctPOINTER logical;
}
AllocateContiguousMemory;
/* gcvHAL_FREE_CONTIGUOUS_MEMORY */
struct _gcsHAL_FREE_CONTIGUOUS_MEMORY
{
/* Number of bytes allocated. */
IN gctSIZE_T bytes;
/* Physical address of allocation. */
IN gctPHYS_ADDR physical;
/* Logical address of allocation. */
IN gctPOINTER logical;
}
FreeContiguousMemory;
/* gcvHAL_READ_REGISTER */
struct _gcsHAL_READ_REGISTER
{
/* Logical address of memory to write data to. */
IN gctUINT32 address;
/* Data read. */
OUT gctUINT32 data;
}
ReadRegisterData;
/* gcvHAL_WRITE_REGISTER */
struct _gcsHAL_WRITE_REGISTER
{
/* Logical address of memory to write data to. */
IN gctUINT32 address;
/* Data read. */
IN gctUINT32 data;
}
WriteRegisterData;
/* gcvHAL_GET_PROFILE_SETTING */
struct _gcsHAL_GET_PROFILE_SETTING
{
/* Enable profiling */
OUT gctBOOL enable;
/* The profile file name */
OUT gctCHAR fileName[gcdMAX_PROFILE_FILE_NAME];
}
GetProfileSetting;
/* gcvHAL_SET_PROFILE_SETTING */
struct _gcsHAL_SET_PROFILE_SETTING
{
/* Enable profiling */
IN gctBOOL enable;
/* The profile file name */
IN gctCHAR fileName[gcdMAX_PROFILE_FILE_NAME];
}
SetProfileSetting;
/* gcvHAL_READ_ALL_PROFILE_REGISTERS */
struct _gcsHAL_READ_ALL_PROFILE_REGISTERS
{
/* Data read. */
OUT gcsPROFILER_COUNTERS counters;
}
RegisterProfileData;
/* gcvHAL_PROFILE_REGISTERS_2D */
struct _gcsHAL_PROFILE_REGISTERS_2D
{
/* Data read. */
OUT gcs2D_PROFILE_PTR hwProfile2D;
}
RegisterProfileData2D;
/* Power management. */
/* gcvHAL_SET_POWER_MANAGEMENT_STATE */
struct _gcsHAL_SET_POWER_MANAGEMENT
{
/* Data read. */
IN gceCHIPPOWERSTATE state;
}
SetPowerManagement;
/* gcvHAL_QUERY_POWER_MANAGEMENT_STATE */
struct _gcsHAL_QUERY_POWER_MANAGEMENT
{
/* Data read. */
OUT gceCHIPPOWERSTATE state;
/* Idle query. */
OUT gctBOOL isIdle;
}
QueryPowerManagement;
/* gcvHAL_QUERY_KERNEL_SETTINGS */
struct _gcsHAL_QUERY_KERNEL_SETTINGS
{
/* Settings.*/
OUT gcsKERNEL_SETTINGS settings;
}
QueryKernelSettings;
/* gcvHAL_MAP_PHYSICAL */
struct _gcsHAL_MAP_PHYSICAL
{
/* gcvTRUE to map, gcvFALSE to unmap. */
IN gctBOOL map;
/* Physical address. */
IN OUT gctPHYS_ADDR physical;
}
MapPhysical;
/* gcvHAL_DEBUG */
struct _gcsHAL_DEBUG
{
/* If gcvTRUE, set the debug information. */
IN gctBOOL set;
IN gctUINT32 level;
IN gctUINT32 zones;
IN gctBOOL enable;
/* Message to print if not empty. */
IN gctCHAR message[80];
}
Debug;
struct _gcsHAL_CACHE
{
IN gctBOOL invalidate;
IN gctHANDLE process;
IN gctPOINTER logical;
IN gctSIZE_T bytes;
}
Cache;
}
u;
}
gcsHAL_INTERFACE;
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_driver_h_ */

View File

@@ -0,0 +1,90 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_dump_h_
#define __gc_hal_dump_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** FILE LAYOUT:
**
** gcsDUMP_FILE structure
**
** gcsDUMP_DATA frame
** gcsDUMP_DATA or gcDUMP_DATA_SIZE records rendingring the frame
** gctUINT8 data[length]
*/
#define gcvDUMP_FILE_SIGNATURE gcmCC('g','c','D','B')
typedef struct _gcsDUMP_FILE
{
gctUINT32 signature; /* File signature */
gctSIZE_T length; /* Length of file */
gctUINT32 frames; /* Number of frames in file */
}
gcsDUMP_FILE;
typedef enum _gceDUMP_TAG
{
gcvTAG_SURFACE = gcmCC('s','u','r','f'),
gcvTAG_FRAME = gcmCC('f','r','m',' '),
gcvTAG_COMMAND = gcmCC('c','m','d',' '),
gcvTAG_INDEX = gcmCC('i','n','d','x'),
gcvTAG_STREAM = gcmCC('s','t','r','m'),
gcvTAG_TEXTURE = gcmCC('t','e','x','t'),
gcvTAG_RENDER_TARGET = gcmCC('r','n','d','r'),
gcvTAG_DEPTH = gcmCC('z','b','u','f'),
gcvTAG_RESOLVE = gcmCC('r','s','l','v'),
gcvTAG_DELETE = gcmCC('d','e','l',' '),
}
gceDUMP_TAG;
typedef struct _gcsDUMP_SURFACE
{
gceDUMP_TAG type; /* Type of record. */
gctUINT32 address; /* Address of the surface. */
gctINT16 width; /* Width of surface. */
gctINT16 height; /* Height of surface. */
gceSURF_FORMAT format; /* Surface pixel format. */
gctSIZE_T length; /* Number of bytes inside the surface. */
}
gcsDUMP_SURFACE;
typedef struct _gcsDUMP_DATA
{
gceDUMP_TAG type; /* Type of record. */
gctSIZE_T length; /* Number of bytes of data. */
gctUINT32 address; /* Address for the data. */
}
gcsDUMP_DATA;
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_dump_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,550 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_enum_h_
#define __gc_hal_enum_h_
#ifdef __cplusplus
extern "C" {
#endif
/* Chip models. */
typedef enum _gceCHIPMODEL
{
gcv300 = 0x0300,
gcv400 = 0x0400,
gcv410 = 0x0410,
gcv450 = 0x0450,
gcv500 = 0x0500,
gcv530 = 0x0530,
gcv600 = 0x0600,
gcv700 = 0x0700,
gcv800 = 0x0800,
gcv860 = 0x0860,
gcv1000 = 0x1000,
}
gceCHIPMODEL;
/* Chip features. */
typedef enum _gceFEATURE
{
gcvFEATURE_PIPE_2D,
gcvFEATURE_PIPE_3D,
gcvFEATURE_PIPE_VG,
gcvFEATURE_DC,
gcvFEATURE_HIGH_DYNAMIC_RANGE,
gcvFEATURE_MODULE_CG,
gcvFEATURE_MIN_AREA,
gcvFEATURE_BUFFER_INTERLEAVING,
gcvFEATURE_BYTE_WRITE_2D,
gcvFEATURE_ENDIANNESS_CONFIG,
gcvFEATURE_DUAL_RETURN_BUS,
gcvFEATURE_DEBUG_MODE,
gcvFEATURE_YUY2_RENDER_TARGET,
gcvFEATURE_FRAGMENT_PROCESSOR,
gcvFEATURE_2DPE20,
gcvFEATURE_FAST_CLEAR,
gcvFEATURE_YUV420_TILER,
gcvFEATURE_YUY2_AVERAGING,
gcvFEATURE_FLIP_Y,
gcvFEATURE_EARLY_Z,
gcvFEATURE_Z_COMPRESSION,
gcvFEATURE_MSAA,
gcvFEATURE_SPECIAL_ANTI_ALIASING,
gcvFEATURE_SPECIAL_MSAA_LOD,
gcvFEATURE_422_TEXTURE_COMPRESSION,
gcvFEATURE_DXT_TEXTURE_COMPRESSION,
gcvFEATURE_ETC1_TEXTURE_COMPRESSION,
gcvFEATURE_CORRECT_TEXTURE_CONVERTER,
gcvFEATURE_TEXTURE_8K,
gcvFEATURE_SCALER,
gcvFEATURE_YUV420_SCALER,
gcvFEATURE_SHADER_HAS_W,
gcvFEATURE_SHADER_HAS_SIGN,
gcvFEATURE_SHADER_HAS_FLOOR,
gcvFEATURE_SHADER_HAS_CEIL,
gcvFEATURE_SHADER_HAS_SQRT,
gcvFEATURE_SHADER_HAS_TRIG,
gcvFEATURE_VAA,
gcvFEATURE_HZ,
gcvFEATURE_CORRECT_STENCIL,
gcvFEATURE_VG20,
gcvFEATURE_VG_FILTER,
gcvFEATURE_VG21,
gcvFEATURE_VG_DOUBLE_BUFFER,
gcvFEATURE_MC20,
gcvFEATURE_SUPER_TILED,
}
gceFEATURE;
/* Chip Power Status. */
typedef enum _gceCHIPPOWERSTATE
{
gcvPOWER_ON,
gcvPOWER_OFF,
gcvPOWER_IDLE,
gcvPOWER_SUSPEND,
gcvPOWER_SUSPEND_ATPOWERON,
gcvPOWER_OFF_ATPOWERON,
gcvPOWER_IDLE_BROADCAST,
gcvPOWER_SUSPEND_BROADCAST,
gcvPOWER_OFF_BROADCAST,
gcvPOWER_OFF_RECOVERY,
}
gceCHIPPOWERSTATE;
/* Surface types. */
typedef enum _gceSURF_TYPE
{
gcvSURF_TYPE_UNKNOWN,
gcvSURF_INDEX,
gcvSURF_VERTEX,
gcvSURF_TEXTURE,
gcvSURF_RENDER_TARGET,
gcvSURF_DEPTH,
gcvSURF_BITMAP,
gcvSURF_TILE_STATUS,
gcvSURF_MASK,
gcvSURF_SCISSOR,
gcvSURF_HIERARCHICAL_DEPTH,
gcvSURF_NUM_TYPES, /* Make sure this is the last one! */
/* Combinations. */
gcvSURF_NO_TILE_STATUS = 0x100,
gcvSURF_RENDER_TARGET_NO_TILE_STATUS = gcvSURF_RENDER_TARGET
| gcvSURF_NO_TILE_STATUS,
gcvSURF_DEPTH_NO_TILE_STATUS = gcvSURF_DEPTH
| gcvSURF_NO_TILE_STATUS,
}
gceSURF_TYPE;
typedef enum _gceSURF_COLOR_TYPE
{
gcvSURF_COLOR_UNKNOWN,
gcvSURF_COLOR_LINEAR = 0x01,
gcvSURF_COLOR_ALPHA_PRE = 0x02,
}
gceSURF_COLOR_TYPE;
/* Rotation. */
typedef enum _gceSURF_ROTATION
{
gcvSURF_0_DEGREE,
gcvSURF_90_DEGREE,
gcvSURF_180_DEGREE,
gcvSURF_270_DEGREE
}
gceSURF_ROTATION;
/* Surface formats. */
typedef enum _gceSURF_FORMAT
{
/* Unknown format. */
gcvSURF_UNKNOWN,
/* Palettized formats. */
gcvSURF_INDEX1 = 100,
gcvSURF_INDEX4,
gcvSURF_INDEX8,
/* RGB formats. */
gcvSURF_A2R2G2B2 = 200,
gcvSURF_R3G3B2,
gcvSURF_A8R3G3B2,
gcvSURF_X4R4G4B4,
gcvSURF_A4R4G4B4,
gcvSURF_R4G4B4A4,
gcvSURF_X1R5G5B5,
gcvSURF_A1R5G5B5,
gcvSURF_R5G5B5A1,
gcvSURF_R5G6B5,
gcvSURF_R8G8B8,
gcvSURF_X8R8G8B8,
gcvSURF_A8R8G8B8,
gcvSURF_R8G8B8A8,
gcvSURF_G8R8G8B8,
gcvSURF_R8G8B8G8,
gcvSURF_X2R10G10B10,
gcvSURF_A2R10G10B10,
gcvSURF_X12R12G12B12,
gcvSURF_A12R12G12B12,
gcvSURF_X16R16G16B16,
gcvSURF_A16R16G16B16,
gcvSURF_R8G8B8X8,
gcvSURF_R5G5B5X1,
gcvSURF_R4G4B4X4,
/* BGR formats. */
gcvSURF_A4B4G4R4 = 300,
gcvSURF_A1B5G5R5,
gcvSURF_B5G6R5,
gcvSURF_B8G8R8,
gcvSURF_X8B8G8R8,
gcvSURF_A8B8G8R8,
gcvSURF_A2B10G10R10,
gcvSURF_A16B16G16R16,
gcvSURF_G16R16,
gcvSURF_B4G4R4A4,
gcvSURF_B5G5R5A1,
gcvSURF_B8G8R8X8,
gcvSURF_B8G8R8A8,
gcvSURF_X4B4G4R4,
gcvSURF_X1B5G5R5,
gcvSURF_B4G4R4X4,
gcvSURF_B5G5R5X1,
/* Compressed formats. */
gcvSURF_DXT1 = 400,
gcvSURF_DXT2,
gcvSURF_DXT3,
gcvSURF_DXT4,
gcvSURF_DXT5,
gcvSURF_CXV8U8,
gcvSURF_ETC1,
/* YUV formats. */
gcvSURF_YUY2 = 500,
gcvSURF_UYVY,
gcvSURF_YV12,
gcvSURF_I420,
gcvSURF_NV12,
gcvSURF_NV21,
gcvSURF_NV16,
gcvSURF_NV61,
gcvSURF_YVYU,
gcvSURF_VYUY,
/* Depth formats. */
gcvSURF_D16 = 600,
gcvSURF_D24S8,
gcvSURF_D32,
gcvSURF_D24X8,
/* Alpha formats. */
gcvSURF_A4 = 700,
gcvSURF_A8,
gcvSURF_A12,
gcvSURF_A16,
gcvSURF_A32,
gcvSURF_A1,
/* Luminance formats. */
gcvSURF_L4 = 800,
gcvSURF_L8,
gcvSURF_L12,
gcvSURF_L16,
gcvSURF_L32,
gcvSURF_L1,
/* Alpha/Luminance formats. */
gcvSURF_A4L4 = 900,
gcvSURF_A2L6,
gcvSURF_A8L8,
gcvSURF_A4L12,
gcvSURF_A12L12,
gcvSURF_A16L16,
/* Bump formats. */
gcvSURF_L6V5U5 = 1000,
gcvSURF_V8U8,
gcvSURF_X8L8V8U8,
gcvSURF_Q8W8V8U8,
gcvSURF_A2W10V10U10,
gcvSURF_V16U16,
gcvSURF_Q16W16V16U16,
/* Floating point formats. */
gcvSURF_R16F = 1100,
gcvSURF_G16R16F,
gcvSURF_A16B16G16R16F,
gcvSURF_R32F,
gcvSURF_G32R32F,
gcvSURF_A32B32G32R32F,
#if 0
/* FIXME: remove HDR support for now. */
/* HDR formats. */
gcvSURF_HDR7E3 = 1200,
gcvSURF_HDR6E4,
gcvSURF_HDR5E5,
gcvSURF_HDR6E5,
#endif
}
gceSURF_FORMAT;
/* Pixel swizzle modes. */
typedef enum _gceSURF_SWIZZLE
{
gcvSURF_NOSWIZZLE,
gcvSURF_ARGB,
gcvSURF_ABGR,
gcvSURF_RGBA,
gcvSURF_BGRA
}
gceSURF_SWIZZLE;
/* Transparency modes. */
typedef enum _gceSURF_TRANSPARENCY
{
/* Valid only for PE 1.0 */
gcvSURF_OPAQUE,
gcvSURF_SOURCE_MATCH,
gcvSURF_SOURCE_MASK,
gcvSURF_PATTERN_MASK,
}
gceSURF_TRANSPARENCY;
/* Transparency modes. */
typedef enum _gce2D_TRANSPARENCY
{
/* Valid only for PE 2.0 */
gcv2D_OPAQUE,
gcv2D_KEYED,
gcv2D_MASKED
}
gce2D_TRANSPARENCY;
/* Mono packing modes. */
typedef enum _gceSURF_MONOPACK
{
gcvSURF_PACKED8,
gcvSURF_PACKED16,
gcvSURF_PACKED32,
gcvSURF_UNPACKED,
}
gceSURF_MONOPACK;
/* Blending modes. */
typedef enum _gceSURF_BLEND_MODE
{
/* Porter-Duff blending modes. */
/* Fsrc Fdst */
gcvBLEND_CLEAR, /* 0 0 */
gcvBLEND_SRC, /* 1 0 */
gcvBLEND_DST, /* 0 1 */
gcvBLEND_SRC_OVER_DST, /* 1 1 - Asrc */
gcvBLEND_DST_OVER_SRC, /* 1 - Adst 1 */
gcvBLEND_SRC_IN_DST, /* Adst 0 */
gcvBLEND_DST_IN_SRC, /* 0 Asrc */
gcvBLEND_SRC_OUT_DST, /* 1 - Adst 0 */
gcvBLEND_DST_OUT_SRC, /* 0 1 - Asrc */
gcvBLEND_SRC_ATOP_DST, /* Adst 1 - Asrc */
gcvBLEND_DST_ATOP_SRC, /* 1 - Adst Asrc */
gcvBLEND_SRC_XOR_DST, /* 1 - Adst 1 - Asrc */
/* Special blending modes. */
gcvBLEND_SET, /* DST = 1 */
gcvBLEND_SUB /* DST = DST * (1 - SRC) */
}
gceSURF_BLEND_MODE;
/* Per-pixel alpha modes. */
typedef enum _gceSURF_PIXEL_ALPHA_MODE
{
gcvSURF_PIXEL_ALPHA_STRAIGHT,
gcvSURF_PIXEL_ALPHA_INVERSED
}
gceSURF_PIXEL_ALPHA_MODE;
/* Global alpha modes. */
typedef enum _gceSURF_GLOBAL_ALPHA_MODE
{
gcvSURF_GLOBAL_ALPHA_OFF,
gcvSURF_GLOBAL_ALPHA_ON,
gcvSURF_GLOBAL_ALPHA_SCALE
}
gceSURF_GLOBAL_ALPHA_MODE;
/* Color component modes for alpha blending. */
typedef enum _gceSURF_PIXEL_COLOR_MODE
{
gcvSURF_COLOR_STRAIGHT,
gcvSURF_COLOR_MULTIPLY
}
gceSURF_PIXEL_COLOR_MODE;
/* Color component modes for alpha blending. */
typedef enum _gce2D_PIXEL_COLOR_MULTIPLY_MODE
{
gcv2D_COLOR_MULTIPLY_DISABLE,
gcv2D_COLOR_MULTIPLY_ENABLE
}
gce2D_PIXEL_COLOR_MULTIPLY_MODE;
/* Color component modes for alpha blending. */
typedef enum _gce2D_GLOBAL_COLOR_MULTIPLY_MODE
{
gcv2D_GLOBAL_COLOR_MULTIPLY_DISABLE,
gcv2D_GLOBAL_COLOR_MULTIPLY_ALPHA,
gcv2D_GLOBAL_COLOR_MULTIPLY_COLOR
}
gce2D_GLOBAL_COLOR_MULTIPLY_MODE;
/* Alpha blending factor modes. */
typedef enum _gceSURF_BLEND_FACTOR_MODE
{
gcvSURF_BLEND_ZERO,
gcvSURF_BLEND_ONE,
gcvSURF_BLEND_STRAIGHT,
gcvSURF_BLEND_INVERSED,
gcvSURF_BLEND_COLOR,
gcvSURF_BLEND_COLOR_INVERSED,
gcvSURF_BLEND_SRC_ALPHA_SATURATED
}
gceSURF_BLEND_FACTOR_MODE;
/* Alpha blending porter duff rules. */
typedef enum _gce2D_PORTER_DUFF_RULE
{
gcvPD_CLEAR,
gcvPD_SRC,
gcvPD_SRC_OVER,
gcvPD_DST_OVER,
gcvPD_SRC_IN,
gcvPD_DST_IN,
gcvPD_SRC_OUT,
gcvPD_DST_OUT,
gcvPD_SRC_ATOP,
gcvPD_DST_ATOP,
gcvPD_ADD,
gcvPD_XOR,
gcvPD_DST
}
gce2D_PORTER_DUFF_RULE;
/* Alpha blending factor modes. */
typedef enum _gce2D_YUV_COLOR_MODE
{
gcv2D_YUV_601,
gcv2D_YUV_709
}
gce2D_YUV_COLOR_MODE;
/* 2D Rotation and flipping. */
typedef enum _gce2D_ORIENTATION
{
gcv2D_0_DEGREE,
gcv2D_90_DEGREE,
gcv2D_180_DEGREE,
gcv2D_270_DEGREE,
gcv2D_X_FLIP,
gcv2D_Y_FLIP
}
gce2D_ORIENTATION;
typedef enum _gce2D_COMMAND
{
gcv2D_CLEAR,
gcv2D_LINE,
gcv2D_BLT,
gcv2D_STRETCH,
gcv2D_HOR_FILTER,
gcv2D_VER_FILTER,
}
gce2D_COMMAND;
/* Texture functions. */
typedef enum _gceTEXTURE_FUNCTION
{
gcvTEXTURE_DUMMY = 0,
gcvTEXTURE_REPLACE = 0,
gcvTEXTURE_MODULATE,
gcvTEXTURE_ADD,
gcvTEXTURE_ADD_SIGNED,
gcvTEXTURE_INTERPOLATE,
gcvTEXTURE_SUBTRACT,
gcvTEXTURE_DOT3
}
gceTEXTURE_FUNCTION;
/* Texture sources. */
typedef enum _gceTEXTURE_SOURCE
{
gcvCOLOR_FROM_TEXTURE,
gcvCOLOR_FROM_CONSTANT_COLOR,
gcvCOLOR_FROM_PRIMARY_COLOR,
gcvCOLOR_FROM_PREVIOUS_COLOR
}
gceTEXTURE_SOURCE;
/* Texture source channels. */
typedef enum _gceTEXTURE_CHANNEL
{
gcvFROM_COLOR,
gcvFROM_ONE_MINUS_COLOR,
gcvFROM_ALPHA,
gcvFROM_ONE_MINUS_ALPHA
}
gceTEXTURE_CHANNEL;
/* Filter types. */
typedef enum _gceFILTER_TYPE
{
gcvFILTER_SYNC,
gcvFILTER_BLUR,
gcvFILTER_USER
}
gceFILTER_TYPE;
/* Filter pass types. */
typedef enum _gceFILTER_PASS_TYPE
{
gcvFILTER_HOR_PASS,
gcvFILTER_VER_PASS
}
gceFILTER_PASS_TYPE;
/* Endian hints. */
typedef enum _gceENDIAN_HINT
{
gcvENDIAN_NO_SWAP = 0,
gcvENDIAN_SWAP_WORD,
gcvENDIAN_SWAP_DWORD
}
gceENDIAN_HINT;
/* Endian hints. */
typedef enum _gceTILING
{
gcvLINEAR,
gcvTILED,
gcvSUPERTILED
}
gceTILING;
/******************************************************************************\
****************************** Object Declarations *****************************
\******************************************************************************/
typedef struct _gcoCONTEXT * gcoCONTEXT;
typedef struct _gcoCMDBUF * gcoCMDBUF;
typedef struct _gcoQUEUE * gcoQUEUE;
typedef struct _gcsHAL_INTERFACE * gcsHAL_INTERFACE_PTR;
typedef struct gcs2D_PROFILE * gcs2D_PROFILE_PTR;
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_enum_h_ */

View File

@@ -0,0 +1,471 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
/*
** Include file for the local memory management.
*/
#ifndef __gc_hal_mem_h_
#define __gc_hal_mem_h_
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
** Usage:
The macros to declare MemPool type and functions are
gcmMEM_DeclareFSMemPool (Type, TypeName, Prefix)
gcmMEM_DeclareVSMemPool (Type, TypeName, Prefix)
gcmMEM_DeclareAFSMemPool(Type, TypeName, Prefix)
The data structures for MemPool are
typedef struct _gcsMEM_FS_MEM_POOL * gcsMEM_FS_MEM_POOL;
typedef struct _gcsMEM_VS_MEM_POOL * gcsMEM_VS_MEM_POOL;
typedef struct _gcsMEM_AFS_MEM_POOL * gcsMEM_AFS_MEM_POOL;
The MemPool constructor and destructor functions are
gcfMEM_InitFSMemPool(gcsMEM_FS_MEM_POOL *, gcoOS, gctUINT, gctUINT);
gcfMEM_FreeFSMemPool(gcsMEM_FS_MEM_POOL *);
gcfMEM_InitVSMemPool(gcsMEM_VS_MEM_POOL *, gcoOS, gctUINT, gctBOOL);
gcfMEM_FreeVSMemPool(gcsMEM_VS_MEM_POOL *);
gcfMEM_InitAFSMemPool(gcsMEM_AFS_MEM_POOL *, gcoOS, gctUINT);
gcfMEM_FreeAFSMemPool(gcsMEM_AFS_MEM_POOL *);
FS: for Fixed-Size data structures
VS: for Variable-size data structures
AFS: for Array of Fixed-Size data structures
// Example 1: For a fixed-size data structure, struct gcsNode.
// It is used locally in a file, so the functions are static without prefix.
// At top level, declear allocate and free functions.
// The first argument is the data type.
// The second armument is the short name used in the fuctions.
gcmMEM_DeclareFSMemPool(struct gcsNode, Node, );
// The previous macro creates two inline functions,
// _AllocateNode and _FreeNode.
// In function or struct
gcsMEM_FS_MEM_POOL nodeMemPool;
// In function,
struct gcsNode * node;
gceSTATUS status;
// Before using the memory pool, initialize it.
// The second argument is the gcoOS object.
// The third argument is the number of data structures to allocate for each chunk.
status = gcfMEM_InitFSMemPool(&nodeMemPool, os, 100, sizeof(struct gcsNode));
...
// Allocate a node.
status = _AllocateNode(nodeMemPool, &node);
...
// Free a node.
_FreeNode(nodeMemPool, node);
// After using the memory pool, free it.
gcfMEM_FreeFSMemPool(&nodeMemPool);
// Example 2: For array of fixed-size data structures, struct gcsNode.
// It is used in several files, so the functions are extern with prefix.
// At top level, declear allocate and free functions.
// The first argument is the data type, and the second one is the short name
// used in the fuctions.
gcmMEM_DeclareAFSMemPool(struct gcsNode, NodeArray, gcfOpt);
// The previous macro creates two inline functions,
// gcfOpt_AllocateNodeArray and gcfOpt_FreeNodeArray.
// In function or struct
gcsMEM_AFS_MEM_POOL nodeArrayMemPool;
// In function,
struct gcsNode * nodeArray;
gceSTATUS status;
// Before using the array memory pool, initialize it.
// The second argument is the gcoOS object, the third is the number of data
// structures to allocate for each chunk.
status = gcfMEM_InitAFSMemPool(&nodeArrayMemPool, os, sizeof(struct gcsNode));
...
// Allocate a node array of size 100.
status = gcfOpt_AllocateNodeArray(nodeArrayMemPool, &nodeArray, 100);
...
// Free a node array.
gcfOpt_FreeNodeArray(&nodeArrayMemPool, nodeArray);
// After using the array memory pool, free it.
gcfMEM_FreeAFSMemPool(&nodeArrayMemPool);
*******************************************************************************/
/*******************************************************************************
** To switch back to use gcoOS_Allocate and gcoOS_Free, add
** #define USE_LOCAL_MEMORY_POOL 0
** before including this file.
*******************************************************************************/
#ifndef USE_LOCAL_MEMORY_POOL
/*
USE_LOCAL_MEMORY_POOL
This define enables the local memory management to improve performance.
*/
#define USE_LOCAL_MEMORY_POOL 1
#endif
/*******************************************************************************
** Memory Pool Data Structures
*******************************************************************************/
#if USE_LOCAL_MEMORY_POOL
typedef struct _gcsMEM_FS_MEM_POOL * gcsMEM_FS_MEM_POOL;
typedef struct _gcsMEM_VS_MEM_POOL * gcsMEM_VS_MEM_POOL;
typedef struct _gcsMEM_AFS_MEM_POOL * gcsMEM_AFS_MEM_POOL;
#else
typedef gcoOS gcsMEM_FS_MEM_POOL;
typedef gcoOS gcsMEM_VS_MEM_POOL;
typedef gcoOS gcsMEM_AFS_MEM_POOL;
#endif
/*******************************************************************************
** Memory Pool Macros
*******************************************************************************/
#if USE_LOCAL_MEMORY_POOL
#define gcmMEM_DeclareFSMemPool(Type, TypeName, Prefix) \
gceSTATUS \
Prefix##_Allocate##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type ** Pointer \
) \
{ \
return(gcfMEM_FSMemPoolGetANode(MemPool, (gctPOINTER *) Pointer)); \
} \
\
gceSTATUS \
Prefix##_CAllocate##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type ** Pointer \
) \
{ \
gceSTATUS status; \
gcmERR_RETURN(gcfMEM_FSMemPoolGetANode(MemPool, (gctPOINTER *) Pointer)); \
gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, gcmSIZEOF(Type))); \
return gcvSTATUS_OK; \
} \
\
gceSTATUS \
Prefix##_Free##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type * Pointer \
) \
{ \
return(gcfMEM_FSMemPoolFreeANode(MemPool, (gctPOINTER) Pointer)); \
} \
\
gceSTATUS \
Prefix##_Free##TypeName##List( \
gcsMEM_FS_MEM_POOL MemPool, \
Type * FirstPointer, \
Type * LastPointer \
) \
{ \
return(gcfMEM_FSMemPoolFreeAList(MemPool, (gctPOINTER) FirstPointer, (gctPOINTER) LastPointer)); \
}
#define gcmMEM_DeclareVSMemPool(Type, TypeName, Prefix) \
gceSTATUS \
Prefix##_Allocate##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Size \
) \
{ \
return(gcfMEM_VSMemPoolGetANode(MemPool, Size, (gctPOINTER *) Pointer)); \
} \
\
gceSTATUS \
Prefix##_CAllocate##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Size \
) \
{ \
gceSTATUS status; \
gcmERR_RETURN(gcfMEM_VSMemPoolGetANode(MemPool, Size, (gctPOINTER *) Pointer)); \
gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, size)); \
return gcvSTATUS_OK; \
} \
\
gceSTATUS \
Prefix##_Free##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type * Pointer \
) \
{ \
return(gcfMEM_VSMemPoolFreeANode(MemPool, (gctPOINTER) Pointer)); \
}
#define gcmMEM_DeclareAFSMemPool(Type, TypeName, Prefix) \
gceSTATUS \
Prefix##_Allocate##TypeName( \
gcsMEM_AFS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Count \
) \
{ \
return(gcfMEM_AFSMemPoolGetANode(MemPool, Count, (gctPOINTER *) Pointer)); \
} \
\
gceSTATUS \
Prefix##_CAllocate##TypeName( \
gcsMEM_AFS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Count \
) \
{ \
gceSTATUS status; \
gcmERR_RETURN(gcfMEM_AFSMemPoolGetANode(MemPool, Count, (gctPOINTER *) Pointer)); \
gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, Count * gcmSIZEOF(Type))); \
return gcvSTATUS_OK; \
} \
\
gceSTATUS \
Prefix##_Free##TypeName( \
gcsMEM_AFS_MEM_POOL MemPool, \
Type * Pointer \
) \
{ \
return(gcfMEM_AFSMemPoolFreeANode(MemPool, (gctPOINTER) Pointer)); \
}
#else
#define gcmMEM_DeclareFSMemPool(Type, TypeName, Prefix) \
gceSTATUS \
Prefix##_Allocate##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type ** Pointer \
) \
{ \
return(gcoOS_Allocate(MemPool, \
gcmSIZEOF(Type), \
(gctPOINTER *) Pointer)); \
} \
\
gceSTATUS \
Prefix##_CAllocate##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type ** Pointer \
) \
{ \
gceSTATUS status; \
gcmERR_RETURN(gcoOS_Allocate(MemPool, \
gcmSIZEOF(Type), \
(gctPOINTER *) Pointer)); \
gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, gcmSIZEOF(Type))); \
return gcvSTATUS_OK; \
} \
\
gceSTATUS \
Prefix##_Free##TypeName( \
gcsMEM_FS_MEM_POOL MemPool, \
Type * Pointer \
) \
{ \
return(gcoOS_Free(MemPool, Pointer)); \
}
#define gcmMEM_DeclareVSMemPool(Type, TypeName, Prefix) \
gceSTATUS \
Prefix##_Allocate##TypeName( \
gcsMEM_VS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Size \
) \
{ \
return(gcoOS_Allocate(MemPool, \
Size, \
(gctPOINTER *) Pointer)); \
} \
\
gceSTATUS \
Prefix##_CAllocate##TypeName( \
gcsMEM_VS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Size \
) \
{ \
gceSTATUS status; \
gcmERR_RETURN(gcoOS_Allocate(MemPool, \
Size, \
(gctPOINTER *) Pointer)); \
gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, Size)); \
return gcvSTATUS_OK; \
} \
\
gceSTATUS \
Prefix##_Free##TypeName( \
gcsMEM_VS_MEM_POOL MemPool, \
Type * Pointer \
) \
{ \
return(gcoOS_Free(MemPool, Pointer)); \
}
#define gcmMEM_DeclareAFSMemPool(Type, TypeName, Prefix) \
gceSTATUS \
Prefix##_Allocate##TypeName( \
gcsMEM_AFS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Count \
) \
{ \
return(gcoOS_Allocate(MemPool, \
Count * gcmSIZEOF(Type), \
(gctPOINTER *) Pointer)); \
} \
\
gceSTATUS \
Prefix##_CAllocate##TypeName( \
gcsMEM_AFS_MEM_POOL MemPool, \
Type ** Pointer, \
gctUINT Count \
) \
{ \
gceSTATUS status; \
gcmERR_RETURN(gcoOS_Allocate(MemPool, \
Count * gcmSIZEOF(Type), \
(gctPOINTER *) Pointer)); \
gcmVERIFY_OK(gcoOS_ZeroMemory(*(gctPOINTER *) Pointer, Count * gcmSIZEOF(Type))); \
return gcvSTATUS_OK; \
} \
\
gceSTATUS \
Prefix##_Free##TypeName( \
gcsMEM_AFS_MEM_POOL MemPool, \
Type * Pointer \
) \
{ \
return(gcoOS_Free(MemPool, Pointer)); \
}
#endif
/*******************************************************************************
** Memory Pool Data Functions
*******************************************************************************/
gceSTATUS
gcfMEM_InitFSMemPool(
IN gcsMEM_FS_MEM_POOL * MemPool,
IN gcoOS OS,
IN gctUINT NodeCount,
IN gctUINT NodeSize
);
gceSTATUS
gcfMEM_FreeFSMemPool(
IN gcsMEM_FS_MEM_POOL * MemPool
);
gceSTATUS
gcfMEM_FSMemPoolGetANode(
IN gcsMEM_FS_MEM_POOL MemPool,
OUT gctPOINTER * Node
);
gceSTATUS
gcfMEM_FSMemPoolFreeANode(
IN gcsMEM_FS_MEM_POOL MemPool,
IN gctPOINTER Node
);
gceSTATUS
gcfMEM_FSMemPoolFreeAList(
IN gcsMEM_FS_MEM_POOL MemPool,
IN gctPOINTER FirstNode,
IN gctPOINTER LastNode
);
gceSTATUS
gcfMEM_InitVSMemPool(
IN gcsMEM_VS_MEM_POOL * MemPool,
IN gcoOS OS,
IN gctUINT BlockSize,
IN gctBOOL RecycleFreeNode
);
gceSTATUS
gcfMEM_FreeVSMemPool(
IN gcsMEM_VS_MEM_POOL * MemPool
);
gceSTATUS
gcfMEM_VSMemPoolGetANode(
IN gcsMEM_VS_MEM_POOL MemPool,
IN gctUINT Size,
IN gctUINT Alignment,
OUT gctPOINTER * Node
);
gceSTATUS
gcfMEM_VSMemPoolFreeANode(
IN gcsMEM_VS_MEM_POOL MemPool,
IN gctPOINTER Node
);
gceSTATUS
gcfMEM_InitAFSMemPool(
IN gcsMEM_AFS_MEM_POOL *MemPool,
IN gcoOS OS,
IN gctUINT NodeCount,
IN gctUINT NodeSize
);
gceSTATUS
gcfMEM_FreeAFSMemPool(
IN gcsMEM_AFS_MEM_POOL *MemPool
);
gceSTATUS
gcfMEM_AFSMemPoolGetANode(
IN gcsMEM_AFS_MEM_POOL MemPool,
IN gctUINT Count,
OUT gctPOINTER * Node
);
gceSTATUS
gcfMEM_AFSMemPoolFreeANode(
IN gcsMEM_AFS_MEM_POOL MemPool,
IN gctPOINTER Node
);
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_mem_h_ */

View File

@@ -0,0 +1,259 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_options_h_
#define __gc_hal_options_h_
/*
USE_NEW_LINUX_SIGNAL
This define enables the Linux kernel signaling between kernel and user.
*/
#ifndef USE_NEW_LINUX_SIGNAL
# define USE_NEW_LINUX_SIGNAL 0
#endif
/*
NO_USER_DIRECT_ACCESS_FROM_KERNEL
This define enables the Linux kernel behavior accessing user memory.
*/
#ifndef NO_USER_DIRECT_ACCESS_FROM_KERNEL
# define NO_USER_DIRECT_ACCESS_FROM_KERNEL 0
#endif
/*
VIVANTE_PROFILER
This define enables the profiler.
*/
#ifndef VIVANTE_PROFILER
# define VIVANTE_PROFILER 0
#endif
/*
gcdUSE_VG
Enable VG HAL layer (only for GC350).
*/
#ifndef gcdUSE_VG
# define gcdUSE_VG 0
#endif
/*
USE_SW_FB
Set to 1 if the frame buffer memory cannot be accessed by the GPU.
*/
#ifndef USE_SW_FB
#define USE_SW_FB 0
#endif
/*
USE_SHADER_SYMBOL_TABLE
This define enables the symbol table in shader object.
*/
#define USE_SHADER_SYMBOL_TABLE 1
/*
USE_SUPER_SAMPLING
This define enables super-sampling support.
*/
#define USE_SUPER_SAMPLING 0
/*
PROFILE_HAL_COUNTERS
This define enables HAL counter profiling support.
HW and SHADER Counter profiling depends on this.
*/
#define PROFILE_HAL_COUNTERS 1
/*
PROFILE_HW_COUNTERS
This define enables HW counter profiling support.
*/
#define PROFILE_HW_COUNTERS 1
/*
PROFILE_SHADER_COUNTERS
This define enables SHADER counter profiling support.
*/
#define PROFILE_SHADER_COUNTERS 1
/*
COMMAND_PROCESSOR_VERSION
The version of the command buffer and task manager.
*/
#define COMMAND_PROCESSOR_VERSION 1
/*
gcdDUMP
When set to 1, a dump of all states and memory uploads, as well as other
hardware related execution will be printed to the debug console. This
data can be used for playing back applications.
*/
#define gcdDUMP 0
/*
gcdDUMP_API
When set to 1, a high level dump of the EGL and GL/VG APs's are
captured.
*/
#define gcdDUMP_API 0
/*
gcdDUMP_IN_KERNEL
When set to 1, all dumps will happen in the kernel. This is handy if
you want the kernel to dump its command buffers as well and the data
needs to be in sync.
*/
#define gcdDUMP_IN_KERNEL 0
/*
gcdDUMP_COMMAND
When set to non-zero, the command queue will dump all incoming command
and context buffers as well as all other modifications to the command
queue.
*/
#define gcdDUMP_COMMAND 0
/*
gcdNULL_DRIVER
*/
#define gcdNULL_DRIVER 0
/*
gcdENABLE_TIMEOUT_DETECTION
Enable timeout detection.
*/
#define gcdENABLE_TIMEOUT_DETECTION 0
/*
gcdCMD_BUFFERS
Number of command buffers to use per client. Each command buffer is 32kB in
size.
*/
#define gcdCMD_BUFFERS 2
/*
gcdPOWER_CONTROL_DELAY
The delay in milliseconds required to wait until the GPU has woke up from a
suspend or power-down state. This is system dependent because the bus clock
also needs to be stabalize.
*/
#define gcdPOWER_CONTROL_DELAY 1
/*
gcdMMU_SIZE
Size of the MMU page table in bytes. Each 4 bytes can hold 4kB worth of
virtual data.
*/
#define gcdMMU_SIZE (128 << 10)
/*
gcdSECURE_USER
Use logical addresses instead of physical addresses in user land. In this
case a hint table is created for both command buffers and context buffers,
and that hint table will be used to patch up those buffers in the kernel
when they are ready to submit.
*/
#define gcdSECURE_USER 0
/*
gcdSECURE_CACHE_SLOTS
Number of slots in the logical to DMA address cache table. Each time a
logical address needs to be translated into a DMA address for the GPU, this
cache will be walked. The replacement scheme is LRU.
*/
#define gcdSECURE_CACHE_SLOTS 64
/*
gcdREGISTER_ACCESS_FROM_USER
Set to 1 to allow IOCTL calls to get through from user land. This should
only be in debug or development drops.
*/
#ifndef gcdREGISTER_ACCESS_FROM_USER
# define gcdREGISTER_ACCESS_FROM_USER 1
#endif
/*
gcdHEAP_SIZE
Set the allocation size for the internal heaps. Each time a heap is full,
a new heap will be allocated with this minmimum amount of bytes. The bigger
this size, the fewer heaps there are to allocate, the better the
performance. However, heaps won't be freed until they are completely free,
so there might be some more memory waste if the size is too big.
*/
#define gcdHEAP_SIZE (64 << 10)
/*
gcdNO_POWER_MANAGEMENT
This define disables the power management code.
*/
#ifndef gcdNO_POWER_MANAGEMENT
# define gcdNO_POWER_MANAGEMENT 0
#endif
/*
gcdFPGA_BUILD
This define enables work arounds for FPGA images.
*/
#if !defined(gcdFPGA_BUILD)
# define gcdFPGA_BUILD 0
#endif
/*
gcdGPU_TIMEOUT
This define specified the number of milliseconds the system will wait before
it broadcasts the GPU is stuck. In other words, it will define the timeout
of any operation that needs to wait for the GPU.
If the value is 0, no timeout will be checked for.
*/
#if !defined(gcdGPU_TIMEOUT)
# define gcdGPU_TIMEOUT 0
#endif
#endif /* __gc_hal_options_h_ */

View File

@@ -0,0 +1,232 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_profiler_h_
#define __gc_hal_profiler_h_
#ifdef __cplusplus
extern "C" {
#endif
#define GLVERTEX_OBJECT 10
#define GLVERTEX_OBJECT_BYTES 11
#define GLINDEX_OBJECT 20
#define GLINDEX_OBJECT_BYTES 21
#define GLTEXTURE_OBJECT 30
#define GLTEXTURE_OBJECT_BYTES 31
#if VIVANTE_PROFILER
#define gcmPROFILE_GC(Hal, Enum, Value) gcoPROFILER_Count(Hal, Enum, Value)
#else
#define gcmPROFILE_GC(Hal, Enum, Value) do { } while (gcvFALSE)
#endif
/* HW profile information. */
typedef struct _gcsPROFILER_COUNTERS
{
/* HW static counters. */
gctUINT32 gpuClock;
gctUINT32 axiClock;
gctUINT32 shaderClock;
/* HW vairable counters. */
gctUINT32 gpuClockStart;
gctUINT32 gpuClockEnd;
/* HW vairable counters. */
gctUINT32 gpuCyclesCounter;
gctUINT32 gpuTotalRead64BytesPerFrame;
gctUINT32 gpuTotalWrite64BytesPerFrame;
/* PE */
gctUINT32 pe_pixel_count_killed_by_color_pipe;
gctUINT32 pe_pixel_count_killed_by_depth_pipe;
gctUINT32 pe_pixel_count_drawn_by_color_pipe;
gctUINT32 pe_pixel_count_drawn_by_depth_pipe;
/* SH */
gctUINT32 ps_inst_counter;
gctUINT32 rendered_pixel_counter;
gctUINT32 vs_inst_counter;
gctUINT32 rendered_vertice_counter;
gctUINT32 vtx_branch_inst_counter;
gctUINT32 vtx_texld_inst_counter;
gctUINT32 pxl_branch_inst_counter;
gctUINT32 pxl_texld_inst_counter;
/* PA */
gctUINT32 pa_input_vtx_counter;
gctUINT32 pa_input_prim_counter;
gctUINT32 pa_output_prim_counter;
gctUINT32 pa_depth_clipped_counter;
gctUINT32 pa_trivial_rejected_counter;
gctUINT32 pa_culled_counter;
/* SE */
gctUINT32 se_culled_triangle_count;
gctUINT32 se_culled_lines_count;
/* RA */
gctUINT32 ra_valid_pixel_count;
gctUINT32 ra_total_quad_count;
gctUINT32 ra_valid_quad_count_after_early_z;
gctUINT32 ra_total_primitive_count;
gctUINT32 ra_pipe_cache_miss_counter;
gctUINT32 ra_prefetch_cache_miss_counter;
gctUINT32 ra_eez_culled_counter;
/* TX */
gctUINT32 tx_total_bilinear_requests;
gctUINT32 tx_total_trilinear_requests;
gctUINT32 tx_total_discarded_texture_requests;
gctUINT32 tx_total_texture_requests;
gctUINT32 tx_mem_read_count;
gctUINT32 tx_mem_read_in_8B_count;
gctUINT32 tx_cache_miss_count;
gctUINT32 tx_cache_hit_texel_count;
gctUINT32 tx_cache_miss_texel_count;
/* MC */
gctUINT32 mc_total_read_req_8B_from_pipeline;
gctUINT32 mc_total_read_req_8B_from_IP;
gctUINT32 mc_total_write_req_8B_from_pipeline;
/* HI */
gctUINT32 hi_axi_cycles_read_request_stalled;
gctUINT32 hi_axi_cycles_write_request_stalled;
gctUINT32 hi_axi_cycles_write_data_stalled;
}
gcsPROFILER_COUNTERS;
/* HAL profile information. */
typedef struct _gcsPROFILER
{
gctFILE file;
/* Aggregate Information */
/* Clock Info */
gctUINT64 frameStart;
gctUINT64 frameEnd;
/* Current frame information */
gctUINT32 frameNumber;
gctUINT64 frameStartTimeusec;
gctUINT64 frameEndTimeusec;
gctUINT64 frameStartCPUTimeusec;
gctUINT64 frameEndCPUTimeusec;
#if PROFILE_HAL_COUNTERS
gctUINT32 vertexBufferTotalBytesAlloc;
gctUINT32 vertexBufferNewBytesAlloc;
int vertexBufferTotalObjectsAlloc;
int vertexBufferNewObjectsAlloc;
gctUINT32 indexBufferTotalBytesAlloc;
gctUINT32 indexBufferNewBytesAlloc;
int indexBufferTotalObjectsAlloc;
int indexBufferNewObjectsAlloc;
gctUINT32 textureBufferTotalBytesAlloc;
gctUINT32 textureBufferNewBytesAlloc;
int textureBufferTotalObjectsAlloc;
int textureBufferNewObjectsAlloc;
gctUINT32 numCommits;
gctUINT32 drawPointCount;
gctUINT32 drawLineCount;
gctUINT32 drawTriangleCount;
gctUINT32 drawVertexCount;
gctUINT32 redundantStateChangeCalls;
#endif
}
gcsPROFILER;
/* Memory profile information. */
struct _gcsMemProfile
{
/* Memory Usage */
gctUINT32 videoMemUsed;
gctUINT32 systemMemUsed;
gctUINT32 commitBufferSize;
gctUINT32 contextBufferCopyBytes;
};
/* Shader profile information. */
struct _gcsSHADER_PROFILER
{
gctUINT32 shaderLength;
gctUINT32 shaderALUCycles;
gctUINT32 shaderTexLoadCycles;
gctUINT32 shaderTempRegCount;
gctUINT32 shaderSamplerRegCount;
gctUINT32 shaderInputRegCount;
gctUINT32 shaderOutputRegCount;
};
/* Initialize the gcsProfiler. */
gceSTATUS
gcoPROFILER_Initialize(
IN gcoHAL Hal,
IN gctFILE File
);
/* Destroy the gcProfiler. */
gceSTATUS
gcoPROFILER_Destroy(
IN gcoHAL Hal
);
/* Call to signal end of frame. */
gceSTATUS
gcoPROFILER_EndFrame(
IN gcoHAL Hal
);
gceSTATUS
gcoPROFILER_Count(
IN gcoHAL Hal,
IN gctUINT32 Enum,
IN gctINT Value
);
/* Profile input vertex shader. */
gceSTATUS
gcoPROFILER_ShaderVS(
IN gcoHAL Hal,
IN gctPOINTER Vs
);
/* Profile input fragment shader. */
gceSTATUS
gcoPROFILER_ShaderFS(
IN gcoHAL Hal,
IN gctPOINTER Fs
);
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_profiler_h_ */

View File

@@ -0,0 +1,781 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_raster_h_
#define __gc_hal_raster_h_
#include "gc_hal_enum.h"
#include "gc_hal_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************\
****************************** Object Declarations *****************************
\******************************************************************************/
typedef struct _gcoBRUSH * gcoBRUSH;
typedef struct _gcoBRUSH_CACHE * gcoBRUSH_CACHE;
/******************************************************************************\
******************************** gcoBRUSH Object *******************************
\******************************************************************************/
/* Create a new solid color gcoBRUSH object. */
gceSTATUS
gcoBRUSH_ConstructSingleColor(
IN gcoHAL Hal,
IN gctUINT32 ColorConvert,
IN gctUINT32 Color,
IN gctUINT64 Mask,
gcoBRUSH * Brush
);
/* Create a new monochrome gcoBRUSH object. */
gceSTATUS
gcoBRUSH_ConstructMonochrome(
IN gcoHAL Hal,
IN gctUINT32 OriginX,
IN gctUINT32 OriginY,
IN gctUINT32 ColorConvert,
IN gctUINT32 FgColor,
IN gctUINT32 BgColor,
IN gctUINT64 Bits,
IN gctUINT64 Mask,
gcoBRUSH * Brush
);
/* Create a color gcoBRUSH object. */
gceSTATUS
gcoBRUSH_ConstructColor(
IN gcoHAL Hal,
IN gctUINT32 OriginX,
IN gctUINT32 OriginY,
IN gctPOINTER Address,
IN gceSURF_FORMAT Format,
IN gctUINT64 Mask,
gcoBRUSH * Brush
);
/* Destroy an gcoBRUSH object. */
gceSTATUS
gcoBRUSH_Destroy(
IN gcoBRUSH Brush
);
/******************************************************************************\
******************************** gcoSURF Object *******************************
\******************************************************************************/
/* Set cipping rectangle. */
gceSTATUS
gcoSURF_SetClipping(
IN gcoSURF Surface
);
/* Clear one or more rectangular areas. */
gceSTATUS
gcoSURF_Clear2D(
IN gcoSURF DestSurface,
IN gctUINT32 RectCount,
IN gcsRECT_PTR DestRect,
IN gctUINT32 LoColor,
IN gctUINT32 HiColor
);
/* Draw one or more Bresenham lines. */
gceSTATUS
gcoSURF_Line(
IN gcoSURF Surface,
IN gctUINT32 LineCount,
IN gcsRECT_PTR Position,
IN gcoBRUSH Brush,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop
);
/* Generic rectangular blit. */
gceSTATUS
gcoSURF_Blit(
IN OPTIONAL gcoSURF SrcSurface,
IN gcoSURF DestSurface,
IN gctUINT32 RectCount,
IN OPTIONAL gcsRECT_PTR SrcRect,
IN gcsRECT_PTR DestRect,
IN OPTIONAL gcoBRUSH Brush,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN OPTIONAL gceSURF_TRANSPARENCY Transparency,
IN OPTIONAL gctUINT32 TransparencyColor,
IN OPTIONAL gctPOINTER Mask,
IN OPTIONAL gceSURF_MONOPACK MaskPack
);
/* Monochrome blit. */
gceSTATUS
gcoSURF_MonoBlit(
IN gcoSURF DestSurface,
IN gctPOINTER Source,
IN gceSURF_MONOPACK SourcePack,
IN gcsPOINT_PTR SourceSize,
IN gcsPOINT_PTR SourceOrigin,
IN gcsRECT_PTR DestRect,
IN OPTIONAL gcoBRUSH Brush,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN gctBOOL ColorConvert,
IN gctUINT8 MonoTransparency,
IN gceSURF_TRANSPARENCY Transparency,
IN gctUINT32 FgColor,
IN gctUINT32 BgColor
);
/* Filter blit. */
gceSTATUS
gcoSURF_FilterBlit(
IN gcoSURF SrcSurface,
IN gcoSURF DestSurface,
IN gcsRECT_PTR SrcRect,
IN gcsRECT_PTR DestRect,
IN gcsRECT_PTR DestSubRect
);
/* Enable alpha blending engine in the hardware and disengage the ROP engine. */
gceSTATUS
gcoSURF_EnableAlphaBlend(
IN gcoSURF Surface,
IN gctUINT8 SrcGlobalAlphaValue,
IN gctUINT8 DstGlobalAlphaValue,
IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode,
IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode,
IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode,
IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode,
IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode,
IN gceSURF_BLEND_FACTOR_MODE DstFactorMode,
IN gceSURF_PIXEL_COLOR_MODE SrcColorMode,
IN gceSURF_PIXEL_COLOR_MODE DstColorMode
);
/* Disable alpha blending engine in the hardware and engage the ROP engine. */
gceSTATUS
gcoSURF_DisableAlphaBlend(
IN gcoSURF Surface
);
/* Copy a rectangular area with format conversion. */
gceSTATUS
gcoSURF_CopyPixels(
IN gcoSURF Source,
IN gcoSURF Target,
IN gctINT SourceX,
IN gctINT SourceY,
IN gctINT TargetX,
IN gctINT TargetY,
IN gctINT Width,
IN gctINT Height
);
/* Read surface pixel. */
gceSTATUS
gcoSURF_ReadPixel(
IN gcoSURF Surface,
IN gctPOINTER Memory,
IN gctINT X,
IN gctINT Y,
IN gceSURF_FORMAT Format,
OUT gctPOINTER PixelValue
);
/* Write surface pixel. */
gceSTATUS
gcoSURF_WritePixel(
IN gcoSURF Surface,
IN gctPOINTER Memory,
IN gctINT X,
IN gctINT Y,
IN gceSURF_FORMAT Format,
IN gctPOINTER PixelValue
);
/******************************************************************************\
********************************** gco2D Object *********************************
\******************************************************************************/
/* Construct a new gco2D object. */
gceSTATUS
gco2D_Construct(
IN gcoHAL Hal,
OUT gco2D * Hardware
);
/* Destroy an gco2D object. */
gceSTATUS
gco2D_Destroy(
IN gco2D Hardware
);
/* Sets the maximum number of brushes in the brush cache. */
gceSTATUS
gco2D_SetBrushLimit(
IN gco2D Hardware,
IN gctUINT MaxCount
);
/* Flush the brush. */
gceSTATUS
gco2D_FlushBrush(
IN gco2D Engine,
IN gcoBRUSH Brush,
IN gceSURF_FORMAT Format
);
/* Program the specified solid color brush. */
gceSTATUS
gco2D_LoadSolidBrush(
IN gco2D Engine,
IN gceSURF_FORMAT Format,
IN gctUINT32 ColorConvert,
IN gctUINT32 Color,
IN gctUINT64 Mask
);
/* Configure monochrome source. */
gceSTATUS
gco2D_SetMonochromeSource(
IN gco2D Engine,
IN gctBOOL ColorConvert,
IN gctUINT8 MonoTransparency,
IN gceSURF_MONOPACK DataPack,
IN gctBOOL CoordRelative,
IN gceSURF_TRANSPARENCY Transparency,
IN gctUINT32 FgColor,
IN gctUINT32 BgColor
);
/* Configure color source. */
gceSTATUS
gco2D_SetColorSource(
IN gco2D Engine,
IN gctUINT32 Address,
IN gctUINT32 Stride,
IN gceSURF_FORMAT Format,
IN gceSURF_ROTATION Rotation,
IN gctUINT32 SurfaceWidth,
IN gctBOOL CoordRelative,
IN gceSURF_TRANSPARENCY Transparency,
IN gctUINT32 TransparencyColor
);
/* Configure color source extension for full rotation. */
gceSTATUS
gco2D_SetColorSourceEx(
IN gco2D Engine,
IN gctUINT32 Address,
IN gctUINT32 Stride,
IN gceSURF_FORMAT Format,
IN gceSURF_ROTATION Rotation,
IN gctUINT32 SurfaceWidth,
IN gctUINT32 SurfaceHeight,
IN gctBOOL CoordRelative,
IN gceSURF_TRANSPARENCY Transparency,
IN gctUINT32 TransparencyColor
);
/* Configure color source. */
gceSTATUS
gco2D_SetColorSourceAdvanced(
IN gco2D Engine,
IN gctUINT32 Address,
IN gctUINT32 Stride,
IN gceSURF_FORMAT Format,
IN gceSURF_ROTATION Rotation,
IN gctUINT32 SurfaceWidth,
IN gctUINT32 SurfaceHeight,
IN gctBOOL CoordRelative
);
/* Configure masked color source. */
gceSTATUS
gco2D_SetMaskedSource(
IN gco2D Engine,
IN gctUINT32 Address,
IN gctUINT32 Stride,
IN gceSURF_FORMAT Format,
IN gctBOOL CoordRelative,
IN gceSURF_MONOPACK MaskPack
);
/* Configure masked color source extension for full rotation. */
gceSTATUS
gco2D_SetMaskedSourceEx(
IN gco2D Engine,
IN gctUINT32 Address,
IN gctUINT32 Stride,
IN gceSURF_FORMAT Format,
IN gctBOOL CoordRelative,
IN gceSURF_MONOPACK MaskPack,
IN gceSURF_ROTATION Rotation,
IN gctUINT32 SurfaceWidth,
IN gctUINT32 SurfaceHeight
);
/* Setup the source rectangle. */
gceSTATUS
gco2D_SetSource(
IN gco2D Engine,
IN gcsRECT_PTR SrcRect
);
/* Set clipping rectangle. */
gceSTATUS
gco2D_SetClipping(
IN gco2D Engine,
IN gcsRECT_PTR Rect
);
/* Configure destination. */
gceSTATUS
gco2D_SetTarget(
IN gco2D Engine,
IN gctUINT32 Address,
IN gctUINT32 Stride,
IN gceSURF_ROTATION Rotation,
IN gctUINT32 SurfaceWidth
);
/* Configure destination extension for full rotation. */
gceSTATUS
gco2D_SetTargetEx(
IN gco2D Engine,
IN gctUINT32 Address,
IN gctUINT32 Stride,
IN gceSURF_ROTATION Rotation,
IN gctUINT32 SurfaceWidth,
IN gctUINT32 SurfaceHeight
);
/* Calculate and program the stretch factors. */
gceSTATUS
gco2D_SetStretchFactors(
IN gco2D Engine,
IN gctUINT32 HorFactor,
IN gctUINT32 VerFactor
);
/* Calculate and program the stretch factors based on the rectangles. */
gceSTATUS
gco2D_SetStretchRectFactors(
IN gco2D Engine,
IN gcsRECT_PTR SrcRect,
IN gcsRECT_PTR DestRect
);
/* Create a new solid color gcoBRUSH object. */
gceSTATUS
gco2D_ConstructSingleColorBrush(
IN gco2D Engine,
IN gctUINT32 ColorConvert,
IN gctUINT32 Color,
IN gctUINT64 Mask,
gcoBRUSH * Brush
);
/* Create a new monochrome gcoBRUSH object. */
gceSTATUS
gco2D_ConstructMonochromeBrush(
IN gco2D Engine,
IN gctUINT32 OriginX,
IN gctUINT32 OriginY,
IN gctUINT32 ColorConvert,
IN gctUINT32 FgColor,
IN gctUINT32 BgColor,
IN gctUINT64 Bits,
IN gctUINT64 Mask,
gcoBRUSH * Brush
);
/* Create a color gcoBRUSH object. */
gceSTATUS
gco2D_ConstructColorBrush(
IN gco2D Engine,
IN gctUINT32 OriginX,
IN gctUINT32 OriginY,
IN gctPOINTER Address,
IN gceSURF_FORMAT Format,
IN gctUINT64 Mask,
gcoBRUSH * Brush
);
/* Clear one or more rectangular areas. */
gceSTATUS
gco2D_Clear(
IN gco2D Engine,
IN gctUINT32 RectCount,
IN gcsRECT_PTR Rect,
IN gctUINT32 Color32,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN gceSURF_FORMAT DestFormat
);
/* Draw one or more Bresenham lines. */
gceSTATUS
gco2D_Line(
IN gco2D Engine,
IN gctUINT32 LineCount,
IN gcsRECT_PTR Position,
IN gcoBRUSH Brush,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN gceSURF_FORMAT DestFormat
);
/* Draw one or more Bresenham lines based on the 32-bit color. */
gceSTATUS
gco2D_ColorLine(
IN gco2D Engine,
IN gctUINT32 LineCount,
IN gcsRECT_PTR Position,
IN gctUINT32 Color32,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN gceSURF_FORMAT DestFormat
);
/* Generic blit. */
gceSTATUS
gco2D_Blit(
IN gco2D Engine,
IN gctUINT32 RectCount,
IN gcsRECT_PTR Rect,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN gceSURF_FORMAT DestFormat
);
/* Batch blit. */
gceSTATUS
gco2D_BatchBlit(
IN gco2D Engine,
IN gctUINT32 RectCount,
IN gcsRECT_PTR SrcRect,
IN gcsRECT_PTR DestRect,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN gceSURF_FORMAT DestFormat
);
/* Stretch blit. */
gceSTATUS
gco2D_StretchBlit(
IN gco2D Engine,
IN gctUINT32 RectCount,
IN gcsRECT_PTR Rect,
IN gctUINT8 FgRop,
IN gctUINT8 BgRop,
IN gceSURF_FORMAT DestFormat
);
/* Monochrome blit. */
gceSTATUS
gco2D_MonoBlit(
IN gco2D Engine,
IN gctPOINTER StreamBits,
IN gcsPOINT_PTR StreamSize,
IN gcsRECT_PTR StreamRect,
IN gceSURF_MONOPACK SrcStreamPack,
IN gceSURF_MONOPACK DestStreamPack,
IN gcsRECT_PTR DestRect,
IN gctUINT32 FgRop,
IN gctUINT32 BgRop,
IN gceSURF_FORMAT DestFormat
);
/* Set kernel size. */
gceSTATUS
gco2D_SetKernelSize(
IN gco2D Engine,
IN gctUINT8 HorKernelSize,
IN gctUINT8 VerKernelSize
);
/* Set filter type. */
gceSTATUS
gco2D_SetFilterType(
IN gco2D Engine,
IN gceFILTER_TYPE FilterType
);
/* Set the filter kernel by user. */
gceSTATUS
gco2D_SetUserFilterKernel(
IN gco2D Engine,
IN gceFILTER_PASS_TYPE PassType,
IN gctUINT16_PTR KernelArray
);
/* Select the pass(es) to be done for user defined filter. */
gceSTATUS
gco2D_EnableUserFilterPasses(
IN gco2D Engine,
IN gctBOOL HorPass,
IN gctBOOL VerPass
);
/* Frees the temporary buffer allocated by filter blit operation. */
gceSTATUS
gco2D_FreeFilterBuffer(
IN gco2D Engine
);
/* Filter blit. */
gceSTATUS
gco2D_FilterBlit(
IN gco2D Engine,
IN gctUINT32 SrcAddress,
IN gctUINT SrcStride,
IN gctUINT32 SrcUAddress,
IN gctUINT SrcUStride,
IN gctUINT32 SrcVAddress,
IN gctUINT SrcVStride,
IN gceSURF_FORMAT SrcFormat,
IN gceSURF_ROTATION SrcRotation,
IN gctUINT32 SrcSurfaceWidth,
IN gcsRECT_PTR SrcRect,
IN gctUINT32 DestAddress,
IN gctUINT DestStride,
IN gceSURF_FORMAT DestFormat,
IN gceSURF_ROTATION DestRotation,
IN gctUINT32 DestSurfaceWidth,
IN gcsRECT_PTR DestRect,
IN gcsRECT_PTR DestSubRect
);
/* Filter blit extension for full rotation. */
gceSTATUS
gco2D_FilterBlitEx(
IN gco2D Engine,
IN gctUINT32 SrcAddress,
IN gctUINT SrcStride,
IN gctUINT32 SrcUAddress,
IN gctUINT SrcUStride,
IN gctUINT32 SrcVAddress,
IN gctUINT SrcVStride,
IN gceSURF_FORMAT SrcFormat,
IN gceSURF_ROTATION SrcRotation,
IN gctUINT32 SrcSurfaceWidth,
IN gctUINT32 SrcSurfaceHeight,
IN gcsRECT_PTR SrcRect,
IN gctUINT32 DestAddress,
IN gctUINT DestStride,
IN gceSURF_FORMAT DestFormat,
IN gceSURF_ROTATION DestRotation,
IN gctUINT32 DestSurfaceWidth,
IN gctUINT32 DestSurfaceHeight,
IN gcsRECT_PTR DestRect,
IN gcsRECT_PTR DestSubRect
);
/* Enable alpha blending engine in the hardware and disengage the ROP engine. */
gceSTATUS
gco2D_EnableAlphaBlend(
IN gco2D Engine,
IN gctUINT8 SrcGlobalAlphaValue,
IN gctUINT8 DstGlobalAlphaValue,
IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode,
IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode,
IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode,
IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode,
IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode,
IN gceSURF_BLEND_FACTOR_MODE DstFactorMode,
IN gceSURF_PIXEL_COLOR_MODE SrcColorMode,
IN gceSURF_PIXEL_COLOR_MODE DstColorMode
);
/* Enable alpha blending engine in the hardware. */
gceSTATUS
gco2D_EnableAlphaBlendAdvanced(
IN gco2D Engine,
IN gceSURF_PIXEL_ALPHA_MODE SrcAlphaMode,
IN gceSURF_PIXEL_ALPHA_MODE DstAlphaMode,
IN gceSURF_GLOBAL_ALPHA_MODE SrcGlobalAlphaMode,
IN gceSURF_GLOBAL_ALPHA_MODE DstGlobalAlphaMode,
IN gceSURF_BLEND_FACTOR_MODE SrcFactorMode,
IN gceSURF_BLEND_FACTOR_MODE DstFactorMode
);
/* Enable alpha blending engine with Porter Duff rule. */
gceSTATUS
gco2D_SetPorterDuffBlending(
IN gco2D Engine,
IN gce2D_PORTER_DUFF_RULE Rule
);
/* Disable alpha blending engine in the hardware and engage the ROP engine. */
gceSTATUS
gco2D_DisableAlphaBlend(
IN gco2D Engine
);
/* Retrieve the maximum number of 32-bit data chunks for a single DE command. */
gctUINT32
gco2D_GetMaximumDataCount(
void
);
/* Retrieve the maximum number of rectangles, that can be passed in a single DE command. */
gctUINT32
gco2D_GetMaximumRectCount(
void
);
/* Returns the pixel alignment of the surface. */
gceSTATUS
gco2D_GetPixelAlignment(
gceSURF_FORMAT Format,
gcsPOINT_PTR Alignment
);
/* Retrieve monochrome stream pack size. */
gceSTATUS
gco2D_GetPackSize(
IN gceSURF_MONOPACK StreamPack,
OUT gctUINT32 * PackWidth,
OUT gctUINT32 * PackHeight
);
/* Flush the 2D pipeline. */
gceSTATUS
gco2D_Flush(
IN gco2D Engine
);
/* Load 256-entry color table for INDEX8 source surfaces. */
gceSTATUS
gco2D_LoadPalette(
IN gco2D Engine,
IN gctUINT FirstIndex,
IN gctUINT IndexCount,
IN gctPOINTER ColorTable,
IN gctBOOL ColorConvert
);
/* Enable/disable 2D BitBlt mirrorring. */
gceSTATUS
gco2D_SetBitBlitMirror(
IN gco2D Engine,
IN gctBOOL HorizontalMirror,
IN gctBOOL VerticalMirror
);
/* Set the transparency for source, destination and pattern. */
gceSTATUS
gco2D_SetTransparencyAdvanced(
IN gco2D Engine,
IN gce2D_TRANSPARENCY SrcTransparency,
IN gce2D_TRANSPARENCY DstTransparency,
IN gce2D_TRANSPARENCY PatTransparency
);
/* Set the source color key. */
gceSTATUS
gco2D_SetSourceColorKeyAdvanced(
IN gco2D Engine,
IN gctUINT32 ColorKey
);
/* Set the source color key range. */
gceSTATUS
gco2D_SetSourceColorKeyRangeAdvanced(
IN gco2D Engine,
IN gctUINT32 ColorKeyLow,
IN gctUINT32 ColorKeyHigh
);
/* Set the target color key. */
gceSTATUS
gco2D_SetTargetColorKeyAdvanced(
IN gco2D Engine,
IN gctUINT32 ColorKey
);
/* Set the target color key range. */
gceSTATUS
gco2D_SetTargetColorKeyRangeAdvanced(
IN gco2D Engine,
IN gctUINT32 ColorKeyLow,
IN gctUINT32 ColorKeyHigh
);
/* Set the YUV color space mode. */
gceSTATUS
gco2D_SetYUVColorMode(
IN gco2D Engine,
IN gce2D_YUV_COLOR_MODE Mode
);
/* Setup the source global color value in ARGB8 format. */
gceSTATUS gco2D_SetSourceGlobalColorAdvanced(
IN gco2D Engine,
IN gctUINT32 Color32
);
/* Setup the target global color value in ARGB8 format. */
gceSTATUS gco2D_SetTargetGlobalColorAdvanced(
IN gco2D Engine,
IN gctUINT32 Color32
);
/* Setup the source and target pixel multiply modes. */
gceSTATUS
gco2D_SetPixelMultiplyModeAdvanced(
IN gco2D Engine,
IN gce2D_PIXEL_COLOR_MULTIPLY_MODE SrcPremultiplySrcAlpha,
IN gce2D_PIXEL_COLOR_MULTIPLY_MODE DstPremultiplyDstAlpha,
IN gce2D_GLOBAL_COLOR_MULTIPLY_MODE SrcPremultiplyGlobalMode,
IN gce2D_PIXEL_COLOR_MULTIPLY_MODE DstDemultiplyDstAlpha
);
/* Set the GPU clock cycles after which the idle engine will keep auto-flushing. */
gceSTATUS
gco2D_SetAutoFlushCycles(
IN gco2D Engine,
IN gctUINT32 Cycles
);
/* Read the profile registers available in the 2D engine and sets them in the profile.
The function will also reset the pixelsRendered counter every time.
*/
gceSTATUS
gco2D_ProfileEngine(
IN gco2D Engine,
OPTIONAL gcs2D_PROFILE_PTR Profile
);
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_raster_h_ */

View File

@@ -0,0 +1,544 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_types_h_
#define __gc_hal_types_h_
#include "gc_hal_options.h"
#ifdef _WIN32
#pragma warning(disable:4127) /* Conditional expression is constant (do { }
** while(0)). */
#pragma warning(disable:4100) /* Unreferenced formal parameter. */
#pragma warning(disable:4204) /* Non-constant aggregate initializer (C99). */
#pragma warning(disable:4131) /* Uses old-style declarator (for Bison and
** Flex generated files). */
#pragma warning(disable:4206) /* Translation unit is empty. */
#endif
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************\
** Platform macros.
*/
#if defined(__GNUC__)
# define gcdHAS_ELLIPSES 1 /* GCC always has it. */
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define gcdHAS_ELLIPSES 1 /* C99 has it. */
#elif defined(_MSC_VER) && (_MSC_VER >= 1500)
# define gcdHAS_ELLIPSES 1 /* MSVC 2007+ has it. */
#elif defined(UNDER_CE)
# define gcdHAS_ELLIPSES 0 /* Windows CE doesn't have it. */
#else
# error "gcdHAS_ELLIPSES: Platform could not be determined"
#endif
/******************************************************************************\
************************************ Keyword ***********************************
\******************************************************************************/
#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
# define gcmINLINE inline /* C99 keyword. */
#elif defined(__GNUC__)
# define gcmINLINE __inline__ /* GNU keyword. */
#elif defined(_MSC_VER) || defined(UNDER_CE)
# define gcmINLINE __inline /* Internal keyword. */
#else
# error "gcmINLINE: Platform could not be determined"
#endif
#ifndef gcdDEBUG
# if (defined(DBG) && DBG) || defined(DEBUG) || defined(_DEBUG)
# define gcdDEBUG 1
# else
# define gcdDEBUG 0
# endif
#endif
#ifdef _USRDLL
# ifdef _MSC_VER
# ifdef HAL_EXPORTS
# define HALAPI __declspec(dllexport)
# else
# define HALAPI __declspec(dllimport)
# endif
# define HALDECL __cdecl
# else
# ifdef HAL_EXPORTS
# define HALAPI
# else
# define HALAPI extern
# endif
# endif
#else
# define HALAPI
# define HALDECL
#endif
/******************************************************************************\
********************************** Common Types ********************************
\******************************************************************************/
#define gcvFALSE 0
#define gcvTRUE 1
#define gcvINFINITE ((gctUINT32) ~0U)
typedef int gctBOOL;
typedef gctBOOL * gctBOOL_PTR;
typedef int gctINT;
typedef signed char gctINT8;
typedef signed short gctINT16;
typedef signed int gctINT32;
typedef signed long long gctINT64;
typedef gctINT * gctINT_PTR;
typedef gctINT8 * gctINT8_PTR;
typedef gctINT16 * gctINT16_PTR;
typedef gctINT32 * gctINT32_PTR;
typedef gctINT64 * gctINT64_PTR;
typedef unsigned int gctUINT;
typedef unsigned char gctUINT8;
typedef unsigned short gctUINT16;
typedef unsigned int gctUINT32;
typedef unsigned long long gctUINT64;
typedef gctUINT * gctUINT_PTR;
typedef gctUINT8 * gctUINT8_PTR;
typedef gctUINT16 * gctUINT16_PTR;
typedef gctUINT32 * gctUINT32_PTR;
typedef gctUINT64 * gctUINT64_PTR;
typedef unsigned long gctSIZE_T;
typedef gctSIZE_T * gctSIZE_T_PTR;
#ifdef __cplusplus
# define gcvNULL 0
#else
# define gcvNULL ((void *) 0)
#endif
typedef float gctFLOAT;
typedef signed int gctFIXED_POINT;
typedef float * gctFLOAT_PTR;
typedef void * gctPHYS_ADDR;
typedef void * gctHANDLE;
typedef void * gctFILE;
typedef void * gctSIGNAL;
typedef void * gctWINDOW;
typedef void * gctIMAGE;
typedef void * gctPOINTER;
typedef const void * gctCONST_POINTER;
typedef char gctCHAR;
typedef char * gctSTRING;
typedef const char * gctCONST_STRING;
typedef struct _gcsCOUNT_STRING
{
gctSIZE_T Length;
gctCONST_STRING String;
}
gcsCOUNT_STRING;
/* Fixed point constants. */
#define gcvZERO_X ((gctFIXED_POINT) 0x00000000)
#define gcvHALF_X ((gctFIXED_POINT) 0x00008000)
#define gcvONE_X ((gctFIXED_POINT) 0x00010000)
#define gcvNEGONE_X ((gctFIXED_POINT) 0xFFFF0000)
#define gcvTWO_X ((gctFIXED_POINT) 0x00020000)
/******************************************************************************\
******************************* Fixed Point Math *******************************
\******************************************************************************/
#define gcmXMultiply(x1, x2) \
(gctFIXED_POINT) (((gctINT64) (x1) * (x2)) >> 16)
#define gcmXDivide(x1, x2) \
(gctFIXED_POINT) ((((gctINT64) (x1)) << 16) / (x2))
#define gcmXMultiplyDivide(x1, x2, x3) \
(gctFIXED_POINT) ((gctINT64) (x1) * (x2) / (x3))
/* 2D Engine profile. */
struct gcs2D_PROFILE
{
/* Cycle count.
32bit counter incremented every 2D clock cycle.
Wraps back to 0 when the counter overflows.
*/
gctUINT32 cycleCount;
/* Pixels rendered by the 2D engine.
Resets to 0 every time it is read. */
gctUINT32 pixelsRendered;
};
/* Macro to combine four characters into a Charcater Code. */
#define gcmCC(c1, c2, c3, c4) \
( \
(char) (c1) \
| \
((char) (c2) << 8) \
| \
((char) (c3) << 16) \
| \
((char) (c4) << 24) \
)
#define gcmPRINTABLE(c) ((((c) >= ' ') && ((c) <= '}')) ? (c) : ' ')
#define gcmCC_PRINT(cc) \
gcmPRINTABLE((char) ( (cc) & 0xFF)), \
gcmPRINTABLE((char) (((cc) >> 8) & 0xFF)), \
gcmPRINTABLE((char) (((cc) >> 16) & 0xFF)), \
gcmPRINTABLE((char) (((cc) >> 24) & 0xFF))
/******************************************************************************\
****************************** Function Parameters *****************************
\******************************************************************************/
#define IN
#define OUT
#define OPTIONAL
/******************************************************************************\
********************************* Status Codes *********************************
\******************************************************************************/
typedef enum _gceSTATUS
{
gcvSTATUS_OK = 0,
gcvSTATUS_FALSE = 0,
gcvSTATUS_TRUE = 1,
gcvSTATUS_NO_MORE_DATA = 2,
gcvSTATUS_CACHED = 3,
gcvSTATUS_MIPMAP_TOO_LARGE = 4,
gcvSTATUS_NAME_NOT_FOUND = 5,
gcvSTATUS_NOT_OUR_INTERRUPT = 6,
gcvSTATUS_MISMATCH = 7,
gcvSTATUS_MIPMAP_TOO_SMALL = 8,
gcvSTATUS_LARGER = 9,
gcvSTATUS_SMALLER = 10,
gcvSTATUS_CHIP_NOT_READY = 11,
gcvSTATUS_NEED_CONVERSION = 12,
gcvSTATUS_SKIP = 13,
gcvSTATUS_DATA_TOO_LARGE = 14,
gcvSTATUS_INVALID_CONFIG = 15,
gcvSTATUS_CHANGED = 16,
gcvSTATUS_INVALID_ARGUMENT = -1,
gcvSTATUS_INVALID_OBJECT = -2,
gcvSTATUS_OUT_OF_MEMORY = -3,
gcvSTATUS_MEMORY_LOCKED = -4,
gcvSTATUS_MEMORY_UNLOCKED = -5,
gcvSTATUS_HEAP_CORRUPTED = -6,
gcvSTATUS_GENERIC_IO = -7,
gcvSTATUS_INVALID_ADDRESS = -8,
gcvSTATUS_CONTEXT_LOSSED = -9,
gcvSTATUS_TOO_COMPLEX = -10,
gcvSTATUS_BUFFER_TOO_SMALL = -11,
gcvSTATUS_INTERFACE_ERROR = -12,
gcvSTATUS_NOT_SUPPORTED = -13,
gcvSTATUS_MORE_DATA = -14,
gcvSTATUS_TIMEOUT = -15,
gcvSTATUS_OUT_OF_RESOURCES = -16,
gcvSTATUS_INVALID_DATA = -17,
gcvSTATUS_INVALID_MIPMAP = -18,
gcvSTATUS_NOT_FOUND = -19,
gcvSTATUS_NOT_ALIGNED = -20,
gcvSTATUS_INVALID_REQUEST = -21,
gcvSTATUS_GPU_NOT_RESPONDING = -22,
/* Linker errors. */
gcvSTATUS_GLOBAL_TYPE_MISMATCH = -1000,
gcvSTATUS_TOO_MANY_ATTRIBUTES = -1001,
gcvSTATUS_TOO_MANY_UNIFORMS = -1002,
gcvSTATUS_TOO_MANY_VARYINGS = -1003,
gcvSTATUS_UNDECLARED_VARYING = -1004,
gcvSTATUS_VARYING_TYPE_MISMATCH = -1005,
gcvSTATUS_MISSING_MAIN = -1006,
gcvSTATUS_NAME_MISMATCH = -1007,
gcvSTATUS_INVALID_INDEX = -1008,
}
gceSTATUS;
/******************************************************************************\
********************************* Status Macros ********************************
\******************************************************************************/
#define gcmIS_ERROR(status) (status < 0)
#define gcmNO_ERROR(status) (status >= 0)
#define gcmIS_SUCCESS(status) (status == gcvSTATUS_OK)
/******************************************************************************\
********************************* Field Macros *********************************
\******************************************************************************/
#define __gcmSTART(reg_field) \
(0 ? reg_field)
#define __gcmEND(reg_field) \
(1 ? reg_field)
#define __gcmGETSIZE(reg_field) \
(__gcmEND(reg_field) - __gcmSTART(reg_field) + 1)
#define __gcmALIGN(data, reg_field) \
(((gctUINT32) (data)) << __gcmSTART(reg_field))
#define __gcmMASK(reg_field) \
((gctUINT32) ((__gcmGETSIZE(reg_field) == 32) \
? ~0 \
: (~(~0 << __gcmGETSIZE(reg_field)))))
/*******************************************************************************
**
** gcmFIELDMASK
**
** Get aligned field mask.
**
** ARGUMENTS:
**
** reg Name of register.
** field Name of field within register.
*/
#define gcmFIELDMASK(reg, field) \
( \
__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field) \
)
/*******************************************************************************
**
** gcmGETFIELD
**
** Extract the value of a field from specified data.
**
** ARGUMENTS:
**
** data Data value.
** reg Name of register.
** field Name of field within register.
*/
#define gcmGETFIELD(data, reg, field) \
( \
((((gctUINT32) (data)) >> __gcmSTART(reg##_##field)) \
& __gcmMASK(reg##_##field)) \
)
/*******************************************************************************
**
** gcmSETFIELD
**
** Set the value of a field within specified data.
**
** ARGUMENTS:
**
** data Data value.
** reg Name of register.
** field Name of field within register.
** value Value for field.
*/
#define gcmSETFIELD(data, reg, field, value) \
( \
(((gctUINT32) (data)) \
& ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
| __gcmALIGN((gctUINT32) (value) \
& __gcmMASK(reg##_##field), reg##_##field) \
)
/*******************************************************************************
**
** gcmSETFIELDVALUE
**
** Set the value of a field within specified data with a
** predefined value.
**
** ARGUMENTS:
**
** data Data value.
** reg Name of register.
** field Name of field within register.
** value Name of the value within the field.
*/
#define gcmSETFIELDVALUE(data, reg, field, value) \
( \
(((gctUINT32) (data)) \
& ~__gcmALIGN(__gcmMASK(reg##_##field), reg##_##field)) \
| __gcmALIGN(reg##_##field##_##value \
& __gcmMASK(reg##_##field), reg##_##field) \
)
/*******************************************************************************
**
** gcmSETMASKEDFIELD
**
** Set the value of a masked field with specified data.
**
** ARGUMENTS:
**
** reg Name of register.
** field Name of field within register.
** value Value for field.
*/
#define gcmSETMASKEDFIELD(reg, field, value) \
( \
gcmSETFIELD(~0, reg, field, value) & \
gcmSETFIELDVALUE(~0, reg, MASK_ ## field, ENABLED) \
)
/*******************************************************************************
**
** gcmVERIFYFIELDVALUE
**
** Verify if the value of a field within specified data equals a
** predefined value.
**
** ARGUMENTS:
**
** data Data value.
** reg Name of register.
** field Name of field within register.
** value Name of the value within the field.
*/
#define gcmVERIFYFIELDVALUE(data, reg, field, value) \
( \
(((gctUINT32) (data)) >> __gcmSTART(reg##_##field) & \
__gcmMASK(reg##_##field)) \
== \
(reg##_##field##_##value & __gcmMASK(reg##_##field)) \
)
/*******************************************************************************
** Bit field macros.
*/
#define __gcmSTARTBIT(Field) \
( 1 ? Field )
#define __gcmBITSIZE(Field) \
( 0 ? Field )
#define __gcmBITMASK(Field) \
( \
(1 << __gcmBITSIZE(Field)) - 1 \
)
#define gcmGETBITS(Value, Type, Field) \
( \
( ((Type) (Value)) >> __gcmSTARTBIT(Field) ) \
& \
__gcmBITMASK(Field) \
)
#define gcmSETBITS(Value, Type, Field, NewValue) \
( \
( ((Type) (Value)) \
& ~(__gcmBITMASK(Field) << __gcmSTARTBIT(Field)) \
) \
| \
( ( ((Type) (NewValue)) \
& __gcmBITMASK(Field) \
) << __gcmSTARTBIT(Field) \
) \
)
/******************************************************************************\
******************************** Min/Max Macros ********************************
\******************************************************************************/
#define gcmMIN(x, y) (((x) <= (y)) ? (x) : (y))
#define gcmMAX(x, y) (((x) >= (y)) ? (x) : (y))
#define gcmCLAMP(x, min, max) (((x) < (min)) ? (min) : \
((x) > (max)) ? (max) : (x))
#define gcmABS(x) (((x) < 0) ? -(x) : (x))
#define gcmNEG(x) (((x) < 0) ? (x) : -(x))
/*******************************************************************************
**
** gcmPTR2INT
**
** Convert a pointer to an integer value.
**
** ARGUMENTS:
**
** p Pointer value.
*/
#if defined(_WIN32) || (defined(__LP64__) && __LP64__)
# define gcmPTR2INT(p) \
( \
(gctUINT32) (gctUINT64) (p) \
)
#else
# define gcmPTR2INT(p) \
( \
(gctUINT32) (p) \
)
#endif
/*******************************************************************************
**
** gcmINT2PTR
**
** Convert an integer value into a pointer.
**
** ARGUMENTS:
**
** v Integer value.
*/
#define gcmINT2PTR(i) \
( \
(gctPOINTER) (i) \
)
/*******************************************************************************
**
** gcmOFFSETOF
**
** Compute the byte offset of a field inside a structure.
**
** ARGUMENTS:
**
** s Structure name.
** field Field name.
*/
#define gcmOFFSETOF(s, field) \
( \
gcmPTR2INT(& (((struct s *) 0)->field)) \
)
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_types_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,406 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_kernel_h_
#define __gc_hal_kernel_h_
#include "gc_hal.h"
#include "gc_hal_kernel_hardware.h"
#include "gc_hal_driver.h"
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************\
********************************** Structures **********************************
\******************************************************************************/
#if gcdSECURE_USER
typedef struct _gckLOGICAL_CACHE
{
gctHANDLE process;
gctPOINTER logical;
gctUINT32 dma;
gctUINT64 stamp;
}
gckLOGICAL_CACHE;
#endif
/* gckKERNEL object. */
struct _gckKERNEL
{
/* Object. */
gcsOBJECT object;
/* Pointer to gckOS object. */
gckOS os;
/* Pointer to gckHARDWARE object. */
gckHARDWARE hardware;
/* Pointer to gckCOMMAND object. */
gckCOMMAND command;
/* Pointer to gckEVENT object. */
gckEVENT event;
/* Pointer to context. */
gctPOINTER context;
/* Pointer to gckMMU object. */
gckMMU mmu;
/* Arom holding number of clients. */
gctPOINTER atomClients;
#if VIVANTE_PROFILER
/* Enable profiling */
gctBOOL profileEnable;
/* The profile file name */
gctCHAR profileFileName[gcdMAX_PROFILE_FILE_NAME];
#endif
#if gcdSECURE_USER
gckLOGICAL_CACHE cache[gcdSECURE_CACHE_SLOTS];
gctUINT cacheSlots;
gctUINT64 cacheTimeStamp;
#endif
};
#define gcdCOMMAND_QUEUES 2
/* gckCOMMAND object. */
struct _gckCOMMAND
{
/* Object. */
gcsOBJECT object;
/* Pointer to required object. */
gckKERNEL kernel;
gckOS os;
/* Number of bytes per page. */
gctSIZE_T pageSize;
/* Current pipe select. */
gctUINT32 pipeSelect;
/* Command queue running flag. */
gctBOOL running;
/* Idle flag and commit stamp. */
gctBOOL idle;
gctUINT64 commitStamp;
/* Command queue mutex. */
gctPOINTER mutexQueue;
/* Context switching mutex. */
gctPOINTER mutexContext;
/* Command queue power semaphore. */
gctPOINTER powerSemaphore;
/* Current command queue. */
struct _gcskCOMMAND_QUEUE
{
gctSIGNAL signal;
gctPHYS_ADDR physical;
gctPOINTER logical;
}
queues[gcdCOMMAND_QUEUES];
gctPHYS_ADDR physical;
gctPOINTER logical;
gctINT index;
gctUINT32 offset;
/* The command queue is new. */
gctBOOL newQueue;
gctBOOL submit;
/* Context counter used for unique ID. */
gctUINT64 contextCounter;
/* Current context ID. */
gctUINT64 currentContext;
/* Pointer to last WAIT command. */
gctPOINTER wait;
gctSIZE_T waitSize;
/* Command buffer alignment. */
gctSIZE_T alignment;
gctSIZE_T reservedHead;
gctSIZE_T reservedTail;
/* Commit counter. */
gctPOINTER atomCommit;
};
typedef struct _gcsEVENT * gcsEVENT_PTR;
/* Structure holding one event to be processed. */
typedef struct _gcsEVENT
{
/* Pointer to next event in queue. */
gcsEVENT_PTR next;
/* Event information. */
gcsHAL_INTERFACE event;
#ifdef __QNXNTO__
/* Kernel. */
gckKERNEL kernel;
#endif
}
gcsEVENT;
/* Structure holding a list of events to be processed by an interrupt. */
typedef struct _gcsEVENT_QUEUE
{
/* Time stamp. */
gctUINT64 stamp;
/* Source of the event. */
gceKERNEL_WHERE source;
/* Pointer to head of event queue. */
gcsEVENT_PTR head;
/* Pointer to tail of event queue. */
gcsEVENT_PTR tail;
/* Process ID owning the event queue. */
gctUINT32 processID;
}
gcsEVENT_QUEUE;
/* gckEVENT object. */
struct _gckEVENT
{
/* The object. */
gcsOBJECT object;
/* Pointer to required objects. */
gckOS os;
gckKERNEL kernel;
/* Time stamp. */
gctUINT64 stamp;
gctUINT64 lastCommitStamp;
/* Queue mutex. */
gctPOINTER mutexQueue;
/* Array of event queues. */
gcsEVENT_QUEUE queues[31];
gctUINT8 lastID;
/* Pending events. */
volatile gctUINT pending;
/* List of free event structures and its mutex. */
gcsEVENT_PTR freeList;
gctSIZE_T freeCount;
gctPOINTER freeMutex;
/* Events queued to be added to an event queue and its mutex. */
gcsEVENT_QUEUE list;
gctPOINTER listMutex;
};
/* gcuVIDMEM_NODE structure. */
typedef union _gcuVIDMEM_NODE
{
/* Allocated from gckVIDMEM. */
struct _gcsVIDMEM_NODE_VIDMEM
{
/* Owner of this node. */
gckVIDMEM memory;
/* Dual-linked list of nodes. */
gcuVIDMEM_NODE_PTR next;
gcuVIDMEM_NODE_PTR prev;
/* Dual linked list of free nodes. */
gcuVIDMEM_NODE_PTR nextFree;
gcuVIDMEM_NODE_PTR prevFree;
/* Information for this node. */
gctUINT32 offset;
gctSIZE_T bytes;
gctUINT32 alignment;
#ifdef __QNXNTO__
/* Client/server vaddr (mapped using mmap_join). */
gctPOINTER logical;
/* Unique handle of the caller process channel. */
gctHANDLE handle;
#endif
/* Locked counter. */
gctINT32 locked;
/* Memory pool. */
gcePOOL pool;
gctUINT32 physical;
}
VidMem;
/* Allocated from gckOS. */
struct _gcsVIDMEM_NODE_VIRTUAL
{
/* Pointer to gckKERNEL object. */
gckKERNEL kernel;
/* Information for this node. */
gctBOOL contiguous;
gctPHYS_ADDR physical;
gctSIZE_T bytes;
gctPOINTER logical;
/* Page table information. */
gctSIZE_T pageCount;
gctPOINTER pageTable;
gctUINT32 address;
/* Mutex. */
gctPOINTER mutex;
/* Locked counter. */
gctINT32 locked;
#ifdef __QNXNTO__
/* Single linked list of nodes. */
gcuVIDMEM_NODE_PTR next;
/* PID of the caller process channel. */
gctUINT32 userPID;
/* Unique handle of the caller process channel. */
gctHANDLE handle;
/* Unlock pending flag. */
gctBOOL unlockPending;
/* Free pending flag. */
gctBOOL freePending;
#else
/* Pending flag. */
gctBOOL pending;
#endif
}
Virtual;
}
gcuVIDMEM_NODE;
/* gckVIDMEM object. */
struct _gckVIDMEM
{
/* Object. */
gcsOBJECT object;
/* Pointer to gckOS object. */
gckOS os;
/* Information for this video memory heap. */
gctUINT32 baseAddress;
gctSIZE_T bytes;
gctSIZE_T freeBytes;
/* Mapping for each type of surface. */
gctINT mapping[gcvSURF_NUM_TYPES];
/* Sentinel nodes for up to 8 banks. */
gcuVIDMEM_NODE sentinel[8];
/* Allocation threshold. */
gctSIZE_T threshold;
/* The heap mutex. */
gctPOINTER mutex;
};
/* gckMMU object. */
struct _gckMMU
{
/* The object. */
gcsOBJECT object;
/* Pointer to gckOS object. */
gckOS os;
/* Pointer to gckHARDWARE object. */
gckHARDWARE hardware;
/* The page table mutex. */
gctPOINTER pageTableMutex;
/* Page table information. */
gctSIZE_T pageTableSize;
gctPHYS_ADDR pageTablePhysical;
gctUINT32_PTR pageTableLogical;
gctUINT32 pageTableEntries;
/* Free entries. */
gctUINT32 heapList;
gctBOOL freeNodes;
#ifdef __QNXNTO__
/* Single linked list of all allocated nodes. */
gctPOINTER nodeMutex;
gcuVIDMEM_NODE_PTR nodeList;
#endif
};
gceSTATUS
gckKERNEL_AttachProcess(
IN gckKERNEL Kernel,
IN gctBOOL Attach
);
#if gcdSECURE_USER
gceSTATUS
gckKERNEL_MapLogicalToPhysical(
IN gckKERNEL Kernel,
IN gctHANDLE Process,
IN OUT gctPOINTER * Data
);
#endif
gceSTATUS
gckHARDWARE_QueryIdle(
IN gckHARDWARE Hardware,
OUT gctBOOL_PTR IsIdle
);
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_kernel_h_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,928 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#include "gc_hal_kernel_precomp.h"
#define _GC_OBJ_ZONE gcvZONE_MMU
typedef enum _gceMMU_TYPE
{
gcvMMU_USED = 0,
gcvMMU_SINGLE,
gcvMMU_FREE,
}
gceMMU_TYPE;
static gceSTATUS
_Link(
IN gckMMU Mmu,
IN gctUINT32 Index,
IN gctUINT32 Next
)
{
if (Index >= Mmu->pageTableEntries)
{
/* Just move heap pointer. */
Mmu->heapList = Next;
}
else
{
/* Address page table. */
gctUINT32_PTR pageTable = Mmu->pageTableLogical;
/* Dispatch on node type. */
switch (pageTable[Index] & 0xFF)
{
case gcvMMU_SINGLE:
/* Set single index. */
pageTable[Index] = (Next << 8) | gcvMMU_SINGLE;
break;
case gcvMMU_FREE:
/* Set index. */
pageTable[Index + 1] = Next;
break;
default:
gcmkFATAL("MMU table correcupted at index %u!", Index);
return gcvSTATUS_HEAP_CORRUPTED;
}
}
/* Success. */
return gcvSTATUS_OK;
}
static gceSTATUS
_AddFree(
IN gckMMU Mmu,
IN gctUINT32 Index,
IN gctUINT32 Node,
IN gctUINT32 Count
)
{
gctUINT32_PTR pageTable = Mmu->pageTableLogical;
if (Count == 1)
{
/* Initialize a single page node. */
pageTable[Node] = (~0U << 8) | gcvMMU_SINGLE;
}
else
{
/* Initialize the node. */
pageTable[Node + 0] = (Count << 8) | gcvMMU_FREE;
pageTable[Node + 1] = ~0U;
}
/* Append the node. */
return _Link(Mmu, Index, Node);
}
static gceSTATUS
_Collect(
IN gckMMU Mmu
)
{
gctUINT32_PTR pageTable = Mmu->pageTableLogical;
gceSTATUS status;
gctUINT32 i, previous, start = 0, count = 0;
/* Flush the MMU cache. */
gcmkONERROR(
gckHARDWARE_FlushMMU(Mmu->hardware));
previous = Mmu->heapList = ~0U;
Mmu->freeNodes = gcvFALSE;
/* Walk the entire page table. */
for (i = 0; i < Mmu->pageTableEntries; ++i)
{
/* Dispatch based on type of page. */
switch (pageTable[i] & 0xFF)
{
case gcvMMU_USED:
/* Used page, so close any open node. */
if (count > 0)
{
/* Add the node. */
gcmkONERROR(_AddFree(Mmu, previous, start, count));
/* Reset the node. */
previous = start;
count = 0;
}
break;
case gcvMMU_SINGLE:
/* Single free node. */
if (count++ == 0)
{
/* Start a new node. */
start = i;
}
break;
case gcvMMU_FREE:
/* A free node. */
if (count == 0)
{
/* Start a new node. */
start = i;
}
/* Advance the count. */
count += pageTable[i] >> 8;
/* Advance the index into the page table. */
i += (pageTable[i] >> 8) - 1;
break;
default:
gcmkFATAL("MMU page table correcupted at index %u!", i);
return gcvSTATUS_HEAP_CORRUPTED;
}
}
/* See if we have an open node left. */
if (count > 0)
{
/* Add the node to the list. */
gcmkONERROR(_AddFree(Mmu, previous, start, count));
}
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_MMU,
"Performed a garbage collection of the MMU heap.");
/* Success. */
return gcvSTATUS_OK;
OnError:
/* Return the staus. */
return status;
}
/*******************************************************************************
**
** gckMMU_Construct
**
** Construct a new gckMMU object.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctSIZE_T MmuSize
** Number of bytes for the page table.
**
** OUTPUT:
**
** gckMMU * Mmu
** Pointer to a variable that receives the gckMMU object pointer.
*/
gceSTATUS
gckMMU_Construct(
IN gckKERNEL Kernel,
IN gctSIZE_T MmuSize,
OUT gckMMU * Mmu
)
{
gckOS os;
gckHARDWARE hardware;
gceSTATUS status;
gckMMU mmu = gcvNULL;
gctUINT32_PTR pageTable;
gcmkHEADER_ARG("Kernel=0x%x MmuSize=%lu", Kernel, MmuSize);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(MmuSize > 0);
gcmkVERIFY_ARGUMENT(Mmu != gcvNULL);
/* Extract the gckOS object pointer. */
os = Kernel->os;
gcmkVERIFY_OBJECT(os, gcvOBJ_OS);
/* Extract the gckHARDWARE object pointer. */
hardware = Kernel->hardware;
gcmkVERIFY_OBJECT(hardware, gcvOBJ_HARDWARE);
/* Allocate memory for the gckMMU object. */
gcmkONERROR(
gckOS_Allocate(os, sizeof(struct _gckMMU), (gctPOINTER *) &mmu));
/* Initialize the gckMMU object. */
mmu->object.type = gcvOBJ_MMU;
mmu->os = os;
mmu->hardware = hardware;
mmu->pageTableMutex = gcvNULL;
mmu->pageTableLogical = gcvNULL;
#ifdef __QNXNTO__
mmu->nodeList = gcvNULL;
mmu->nodeMutex = gcvNULL;
#endif
/* Create the page table mutex. */
gcmkONERROR(gckOS_CreateMutex(os, &mmu->pageTableMutex));
#ifdef __QNXNTO__
/* Create the node list mutex. */
gcmkONERROR(gckOS_CreateMutex(os, &mmu->nodeMutex));
#endif
/* Allocate the page table (not more than 256 kB). */
mmu->pageTableSize = gcmMIN(MmuSize, 256 << 10);
gcmkONERROR(
gckOS_AllocateContiguous(os,
gcvFALSE,
&mmu->pageTableSize,
&mmu->pageTablePhysical,
(gctPOINTER *) &mmu->pageTableLogical));
/* Compute number of entries in page table. */
mmu->pageTableEntries = mmu->pageTableSize / sizeof(gctUINT32);
/* Mark all pages as free. */
pageTable = mmu->pageTableLogical;
pageTable[0] = (mmu->pageTableEntries << 8) | gcvMMU_FREE;
pageTable[1] = ~0U;
mmu->heapList = 0;
mmu->freeNodes = gcvFALSE;
/* Set page table address. */
gcmkONERROR(
gckHARDWARE_SetMMU(hardware, (gctPOINTER) mmu->pageTableLogical));
/* Return the gckMMU object pointer. */
*Mmu = mmu;
/* Success. */
gcmkFOOTER_ARG("*Mmu=0x%x", *Mmu);
return gcvSTATUS_OK;
OnError:
/* Roll back. */
if (mmu != gcvNULL)
{
if (mmu->pageTableLogical != gcvNULL)
{
/* Free the page table. */
gcmkVERIFY_OK(
gckOS_FreeContiguous(os,
mmu->pageTablePhysical,
(gctPOINTER) mmu->pageTableLogical,
mmu->pageTableSize));
}
if (mmu->pageTableMutex != gcvNULL)
{
/* Delete the mutex. */
gcmkVERIFY_OK(
gckOS_DeleteMutex(os, mmu->pageTableMutex));
}
#ifdef __QNXNTO__
if (mmu->nodeMutex != gcvNULL)
{
/* Delete the mutex. */
gcmkVERIFY_OK(
gckOS_DeleteMutex(os, mmu->nodeMutex));
}
#endif
/* Mark the gckMMU object as unknown. */
mmu->object.type = gcvOBJ_UNKNOWN;
/* Free the allocates memory. */
gcmkVERIFY_OK(gckOS_Free(os, mmu));
}
/* Return the status. */
gcmkFOOTER();
return status;
}
/*******************************************************************************
**
** gckMMU_Destroy
**
** Destroy a gckMMU object.
**
** INPUT:
**
** gckMMU Mmu
** Pointer to an gckMMU object.
**
** OUTPUT:
**
** Nothing.
*/
gceSTATUS
gckMMU_Destroy(
IN gckMMU Mmu
)
{
#ifdef __QNXNTO__
gcuVIDMEM_NODE_PTR node, next;
#endif
gcmkHEADER_ARG("Mmu=0x%x", Mmu);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Mmu, gcvOBJ_MMU);
#ifdef __QNXNTO__
/* Free all associated virtual memory. */
for (node = Mmu->nodeList; node != gcvNULL; node = next)
{
next = node->Virtual.next;
gcmkVERIFY_OK(gckVIDMEM_Free(node, gcvNULL));
}
#endif
/* Free the page table. */
gcmkVERIFY_OK(
gckOS_FreeContiguous(Mmu->os,
Mmu->pageTablePhysical,
(gctPOINTER) Mmu->pageTableLogical,
Mmu->pageTableSize));
#ifdef __QNXNTO__
/* Delete the node list mutex. */
gcmkVERIFY_OK(gckOS_DeleteMutex(Mmu->os, Mmu->nodeMutex));
#endif
/* Delete the page table mutex. */
gcmkVERIFY_OK(gckOS_DeleteMutex(Mmu->os, Mmu->pageTableMutex));
/* Mark the gckMMU object as unknown. */
Mmu->object.type = gcvOBJ_UNKNOWN;
/* Free the gckMMU object. */
gcmkVERIFY_OK(gckOS_Free(Mmu->os, Mmu));
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckMMU_AllocatePages
**
** Allocate pages inside the page table.
**
** INPUT:
**
** gckMMU Mmu
** Pointer to an gckMMU object.
**
** gctSIZE_T PageCount
** Number of pages to allocate.
**
** OUTPUT:
**
** gctPOINTER * PageTable
** Pointer to a variable that receives the base address of the page
** table.
**
** gctUINT32 * Address
** Pointer to a variable that receives the hardware specific address.
*/
gceSTATUS
gckMMU_AllocatePages(
IN gckMMU Mmu,
IN gctSIZE_T PageCount,
OUT gctPOINTER * PageTable,
OUT gctUINT32 * Address
)
{
gceSTATUS status;
gctBOOL mutex = gcvFALSE;
gctUINT32 index = 0, previous = ~0U, left;
gctUINT32_PTR pageTable;
gctBOOL gotIt;
gctUINT32 address;
gcmkHEADER_ARG("Mmu=0x%x PageCount=%lu", Mmu, PageCount);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Mmu, gcvOBJ_MMU);
gcmkVERIFY_ARGUMENT(PageCount > 0);
gcmkVERIFY_ARGUMENT(PageTable != gcvNULL);
if (PageCount > Mmu->pageTableEntries)
{
/* Not enough pages avaiable. */
gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES);
}
/* Grab the mutex. */
gcmkONERROR(gckOS_AcquireMutex(Mmu->os, Mmu->pageTableMutex, gcvINFINITE));
mutex = gcvTRUE;
/* Cast pointer to page table. */
for (pageTable = Mmu->pageTableLogical, gotIt = gcvFALSE; !gotIt;)
{
/* Walk the heap list. */
for (index = Mmu->heapList; !gotIt && (index < Mmu->pageTableEntries);)
{
/* Check the node type. */
switch (pageTable[index] & 0xFF)
{
case gcvMMU_SINGLE:
/* Single odes are valid if we only need 1 page. */
if (PageCount == 1)
{
gotIt = gcvTRUE;
}
else
{
/* Move to next node. */
previous = index;
index = pageTable[index] >> 8;
}
break;
case gcvMMU_FREE:
/* Test if the node has enough space. */
if (PageCount <= (pageTable[index] >> 8))
{
gotIt = gcvTRUE;
}
else
{
/* Move to next node. */
previous = index;
index = pageTable[index + 1];
}
break;
default:
gcmkFATAL("MMU table correcupted at index %u!", index);
gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES);
}
}
/* Test if we are out of memory. */
if (index >= Mmu->pageTableEntries)
{
if (Mmu->freeNodes)
{
/* Time to move out the trash! */
gcmkONERROR(_Collect(Mmu));
}
else
{
/* Out of resources. */
gcmkONERROR(gcvSTATUS_OUT_OF_RESOURCES);
}
}
}
switch (pageTable[index] & 0xFF)
{
case gcvMMU_SINGLE:
/* Unlink single node from free list. */
gcmkONERROR(
_Link(Mmu, previous, pageTable[index] >> 8));
break;
case gcvMMU_FREE:
/* Check how many pages will be left. */
left = (pageTable[index] >> 8) - PageCount;
switch (left)
{
case 0:
/* The entire node is consumed, just unlink it. */
gcmkONERROR(
_Link(Mmu, previous, pageTable[index + 1]));
break;
case 1:
/* One page will remain. Convert the node to a single node and
** advance the index. */
pageTable[index] = (pageTable[index + 1] << 8) | gcvMMU_SINGLE;
index ++;
break;
default:
/* Enough pages remain for a new node. However, we will just adjust
** the size of the current node and advance the index. */
pageTable[index] = (left << 8) | gcvMMU_FREE;
index += left;
break;
}
break;
}
/* Mark node as used. */
pageTable[index] = gcvMMU_USED;
/* Return pointer to page table. */
*PageTable = &pageTable[index];
/* Build virtual address. */
gcmkONERROR(
gckHARDWARE_BuildVirtualAddress(Mmu->hardware, index, 0, &address));
if (Address != gcvNULL)
{
*Address = address;
}
/* Release the mutex. */
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->pageTableMutex));
/* Success. */
gcmkFOOTER_ARG("*PageTable=0x%x *Address=%08x",
*PageTable, gcmOPT_VALUE(Address));
return gcvSTATUS_OK;
OnError:
if (mutex)
{
/* Release the mutex. */
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->pageTableMutex));
}
/* Return the status. */
gcmkFOOTER();
return status;
}
/*******************************************************************************
**
** gckMMU_FreePages
**
** Free pages inside the page table.
**
** INPUT:
**
** gckMMU Mmu
** Pointer to an gckMMU object.
**
** gctPOINTER PageTable
** Base address of the page table to free.
**
** gctSIZE_T PageCount
** Number of pages to free.
**
** OUTPUT:
**
** Nothing.
*/
gceSTATUS
gckMMU_FreePages(
IN gckMMU Mmu,
IN gctPOINTER PageTable,
IN gctSIZE_T PageCount
)
{
gctUINT32_PTR pageTable;
gcmkHEADER_ARG("Mmu=0x%x PageTable=0x%x PageCount=%lu",
Mmu, PageTable, PageCount);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Mmu, gcvOBJ_MMU);
gcmkVERIFY_ARGUMENT(PageTable != gcvNULL);
gcmkVERIFY_ARGUMENT(PageCount > 0);
/* Convert the pointer. */
pageTable = (gctUINT32_PTR) PageTable;
if (PageCount == 1)
{
/* Single page node. */
pageTable[0] = (~0U << 8) | gcvMMU_SINGLE;
}
else
{
/* Mark the node as free. */
pageTable[0] = (PageCount << 8) | gcvMMU_FREE;
pageTable[1] = ~0U;
}
/* We have free nodes. */
Mmu->freeNodes = gcvTRUE;
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
}
#ifdef __QNXNTO__
gceSTATUS
gckMMU_InsertNode(
IN gckMMU Mmu,
IN gcuVIDMEM_NODE_PTR Node)
{
gceSTATUS status;
gctBOOL mutex = gcvFALSE;
gcmkHEADER_ARG("Mmu=0x%x Node=0x%x", Mmu, Node);
gcmkVERIFY_OBJECT(Mmu, gcvOBJ_MMU);
gcmkONERROR(gckOS_AcquireMutex(Mmu->os, Mmu->nodeMutex, gcvINFINITE));
mutex = gcvTRUE;
Node->Virtual.next = Mmu->nodeList;
Mmu->nodeList = Node;
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->nodeMutex));
gcmkFOOTER();
return gcvSTATUS_OK;
OnError:
if (mutex)
{
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->nodeMutex));
}
gcmkFOOTER();
return status;
}
gceSTATUS
gckMMU_RemoveNode(
IN gckMMU Mmu,
IN gcuVIDMEM_NODE_PTR Node)
{
gceSTATUS status;
gctBOOL mutex = gcvFALSE;
gcuVIDMEM_NODE_PTR *iter;
gcmkHEADER_ARG("Mmu=0x%x Node=0x%x", Mmu, Node);
gcmkVERIFY_OBJECT(Mmu, gcvOBJ_MMU);
gcmkONERROR(gckOS_AcquireMutex(Mmu->os, Mmu->nodeMutex, gcvINFINITE));
mutex = gcvTRUE;
for (iter = &Mmu->nodeList; *iter; iter = &(*iter)->Virtual.next)
{
if (*iter == Node)
{
*iter = Node->Virtual.next;
break;
}
}
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->nodeMutex));
gcmkFOOTER();
return gcvSTATUS_OK;
OnError:
if (mutex)
{
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->nodeMutex));
}
gcmkFOOTER();
return status;
}
gceSTATUS
gckMMU_FreeHandleMemory(
IN gckMMU Mmu,
IN gctHANDLE Handle
)
{
gceSTATUS status;
gctBOOL acquired = gcvFALSE;
gcuVIDMEM_NODE_PTR curr, next;
gcmkHEADER_ARG("Mmu=0x%x Handle=0x%x", Mmu, Handle);
gcmkVERIFY_OBJECT(Mmu, gcvOBJ_MMU);
gcmkONERROR(gckOS_AcquireMutex(Mmu->os, Mmu->nodeMutex, gcvINFINITE));
acquired = gcvTRUE;
for (curr = Mmu->nodeList; curr != gcvNULL; curr = next)
{
next = curr->Virtual.next;
if (curr->Virtual.handle == Handle)
{
while (curr->Virtual.locked > 0 || curr->Virtual.unlockPending)
{
gcmkONERROR(gckVIDMEM_Unlock(curr, gcvSURF_TYPE_UNKNOWN, gcvNULL, gcvNULL));
}
gcmkVERIFY_OK(gckVIDMEM_Free(curr, gcvNULL));
}
}
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->nodeMutex));
gcmkFOOTER();
return gcvSTATUS_OK;
OnError:
if (acquired)
{
gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->nodeMutex));
}
gcmkFOOTER();
return status;
}
#endif
/******************************************************************************
****************************** T E S T C O D E ******************************
******************************************************************************/
#if defined gcdHAL_TEST
#include <stdlib.h>
#define gcmRANDOM(n) (rand() % n)
typedef struct
{
gctSIZE_T pageCount;
gctUINT32_PTR pageTable;
}
gcsMMU_TEST;
gceSTATUS
gckMMU_Test(
IN gckMMU Mmu,
IN gctSIZE_T Vectors,
IN gctINT MaxSize
)
{
const gctINT nodeCount = MaxSize / 4;
gcsMMU_TEST * nodes = gcvNULL;
gceSTATUS status, failure = gcvSTATUS_OK;
gctSIZE_T i, count;
gctUINT32_PTR pageTable;
gctINT index;
/* Allocate the node array. */
gcmkONERROR(
gckOS_Allocate(Mmu->os,
nodeCount * gcmSIZEOF(gcsMMU_TEST),
(gctPOINTER *) &nodes));
/* Mark all nodes as free. */
gcmkONERROR(
gckOS_ZeroMemory(nodes, nodeCount * gcmSIZEOF(gcsMMU_TEST)));
/* Loop through all vectors. */
while (Vectors-- > 0)
{
/* Get a random index. */
index = gcmRANDOM(nodeCount);
/* Test if we need to allocate pages. */
if (nodes[index].pageCount == 0)
{
/* Generate a random page count. */
do
{
count = gcmRANDOM(MaxSize);
}
while (count == 0);
/* Allocate pages. */
status = gckMMU_AllocatePages(Mmu,
count,
(gctPOINTER *) &pageTable,
gcvNULL);
if (gcmIS_SUCCESS(status))
{
/* Mark node as allocated. */
nodes[index].pageCount = count;
nodes[index].pageTable = pageTable;
/* Put signature in the page table. */
for (i = 0; i < count; ++i)
{
pageTable[i] = (index << 8) | gcvMMU_USED;
}
}
else
{
gcmkTRACE(gcvLEVEL_WARNING,
"gckMMU_Test: Failed to allocate %u pages",
count);
}
}
else
{
/* Verify the page table. */
pageTable = nodes[index].pageTable;
for (i = 0; i < nodes[index].pageCount; ++i)
{
if (pageTable[i] != ((index << 8) | gcvMMU_USED))
{
gcmkFATAL("gckMMU_Test: Corruption detected at page %u",
index);
failure = gcvSTATUS_HEAP_CORRUPTED;
}
}
/* Free the pages. */
status = gckMMU_FreePages(Mmu, pageTable, nodes[index].pageCount);
if (gcmIS_ERROR(status))
{
gcmkFATAL("gckMMU_Test: Cannot free %u pages at 0x%x (index=%u)",
nodes[index].pageCount, pageTable, index);
failure = status;
}
/* Mark the node as free. */
nodes[index].pageCount = 0;
}
}
/* Walk the entire array of nodes. */
for (index = 0; index < nodeCount; ++index)
{
/* Test if we need to free pages. */
if (nodes[index].pageCount != 0)
{
/* Verify the page table. */
pageTable = nodes[index].pageTable;
for (i = 0; i < nodes[index].pageCount; ++i)
{
if (pageTable[i] != ((index << 8) | gcvMMU_USED))
{
gcmkFATAL("gckMMU_Test: Corruption detected at page %u",
index);
failure = gcvSTATUS_HEAP_CORRUPTED;
}
}
/* Free the pages. */
status = gckMMU_FreePages(Mmu, pageTable, nodes[index].pageCount);
if (gcmIS_ERROR(status))
{
gcmkFATAL("gckMMU_Test: Cannot free %u pages at 0x%x (index=%u)",
nodes[index].pageCount, pageTable, index);
failure = status;
}
}
}
/* Perform garbage collection. */
gcmkONERROR(_Collect(Mmu));
/* Verify we did not loose any nodes. */
if ((Mmu->heapList != 0)
|| ((Mmu->pageTableLogical[0] & 0xFF) != gcvMMU_FREE)
|| (Mmu->pageTableEntries != (Mmu->pageTableLogical[0] >> 8))
)
{
gcmkFATAL("gckMMU_Test: Detected leaking in the page table.");
failure = gcvSTATUS_HEAP_CORRUPTED;
}
OnError:
/* Free the array of nodes. */
if (nodes != gcvNULL)
{
gcmkVERIFY_OK(gckOS_Free(Mmu->os, nodes));
}
/* Return test status. */
return failure;
}
#endif

View File

@@ -0,0 +1,32 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_kernel_precomp_h_
#define __gc_hal_kernel_precomp_h_
#include "gc_hal.h"
#include "gc_hal_driver.h"
#include "gc_hal_kernel.h"
#endif /* __gc_hal_kernel_precomp_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
##############################################################################
#
# Copyright (C) 2005 - 2010 by Vivante Corp.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the license, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
##############################################################################
#
# Linux build file for architecture dependent kernel HAL layer.
#
#
################################################################################
# Include common definitions.
include $(AQROOT)/makefile.linux.def
################################################################################
# Define a shortcut for the main target.
STATIC = 1
TARGET_NAME = libhalkernel.a
################################################################################
# Supply additional include directories.
INCLUDE += -I$(AQROOT)/hal/inc
INCLUDE += -I$(AQROOT)/hal/user
INCLUDE += -I$(AQARCH)/hal/kernel
CFLAGS += $(INCLUDE) -Werror -ansi
################################################################################
# Describe object files.
OBJECTS = $(OBJ_DIR)/gc_hal_kernel_command.o \
$(OBJ_DIR)/gc_hal_kernel_event.o \
$(OBJ_DIR)/gc_hal_kernel_heap.o \
$(OBJ_DIR)/gc_hal_kernel.o \
$(OBJ_DIR)/gc_hal_kernel_mmu.o \
$(OBJ_DIR)/gc_hal_kernel_video_memory.o
include $(AQROOT)/common.target

View File

@@ -0,0 +1,47 @@
##############################################################################
#
# Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
#
# The material in this file is confidential and contains trade secrets
# of Vivante Corporation. This is proprietary information owned by
# Vivante Corporation. No part of this work may be disclosed,
# reproduced, copied, transmitted, or used in any way for any purpose,
# without the express written permission of Vivante Corporation.
#
##############################################################################
#
# Auto-generated file on 10/12/2010. Do not edit!!!
#
##############################################################################
#
# Linux build file for the user level HAL libraries.
#
################################################################################
# Define make command.
MAKE = make --makefile=makefile.linux
################################################################################
# Define build directories.
HAL_USER_DRV_ARCH := $(AQARCH)/hal/user
ifeq ($(QNX), 1)
HAL_USER_DRV_OS := $(AQROOT)/hal/os/qnx/user
else
HAL_USER_DRV_OS := $(AQROOT)/hal/os/linux/user
endif
HAL_USER_DRV_MAIN := $(AQROOT)/hal/user
$(HAL_USER_DRV_MAIN): $(HAL_USER_DRV_ARCH) $(HAL_USER_DRV_OS)
MODULES := $(HAL_USER_DRV_ARCH) $(HAL_USER_DRV_OS) $(HAL_USER_DRV_MAIN)
MAIN_MODULE = $(HAL_USER_DRV_MAIN)
include $(AQROOT)/common.node

View File

@@ -0,0 +1,540 @@
##############################################################################
#
# Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
#
# The material in this file is confidential and contains trade secrets
# of Vivante Corporation. This is proprietary information owned by
# Vivante Corporation. No part of this work may be disclosed,
# reproduced, copied, transmitted, or used in any way for any purpose,
# without the express written permission of Vivante Corporation.
#
##############################################################################
#
# Auto-generated file on 10/12/2010. Do not edit!!!
#
##############################################################################
"$(DEFFILE)" : $(AQROOT)\hal\os\libGAL.def.mak
@copy << "$(DEFFILE)"
;
; !! Do not edit this file - it is automatically generated !!
;
LIBRARY libGAL
EXPORTS
;gcoOS
gcoOS_SetDebugLevel
gcoOS_SetDebugZone
gcoOS_SetDebugFile
gcoOS_SetDebugZones
gcoOS_SetDebugLevelZone
gcoOS_SetDebugShaderFiles
gcoOS_DebugFatal
gcoOS_DebugTrace
gcoOS_DebugTraceZone
gcoOS_Print
gcoOS_DebugBreak
gcoOS_Verify
gcoOS_Construct
gcoOS_Destroy
gcoOS_QueryVideoMemory
gcoOS_Allocate
gcoOS_Free
gcoOS_AllocateNonPagedMemory
gcoOS_FreeNonPagedMemory
gcoOS_AllocateContiguous
gcoOS_FreeContiguous
gcoOS_CreateMutex
gcoOS_DeleteMutex
gcoOS_AcquireMutex
gcoOS_ReleaseMutex
gcoOS_CreateSignal
gcoOS_DestroySignal
gcoOS_Signal
gcoOS_WaitSignal
gcoOS_DeviceControl
gcoOS_Open
gcoOS_Close
gcoOS_Read
gcoOS_Write
gcoOS_Seek
gcoOS_SetPos
gcoOS_GetPos
gcoOS_MemCopy
gcoOS_ZeroMemory
gcoOS_MemFill
gcoOS_StrLen
gcoOS_StrFindReverse
gcoOS_StrCopySafe
gcoOS_StrCatSafe
gcoOS_StrCmp
gcoOS_StrNCmp
gcoOS_StrToFloat
gcoOS_StrToInt
gcoOS_MemCmp
gcoOS_PrintStrSafe
gcoOS_PrintStrVSafe
gcoOS_MapUserMemory
gcoOS_UnmapUserMemory
gcoOS_StrDup
gcoOS_LoadLibrary
gcoOS_FreeLibrary
gcoOS_GetProcAddress
gcoOS_Delay
gcoOS_GetCurrentProcessID
gcoOS_AtomConstruct
gcoOS_AtomDestroy
gcoOS_AtomIncrement
gcoOS_AtomDecrement
gcoOS_GetTicks
gcoOS_GetTime
gcoOS_GetCPUTime
gcoOS_GetMemoryUsage
gcoOS_GetBaseAddress
gcoOS_ReadRegister
gcoOS_WriteRegister
!IFNDEF VIVANTE_NO_3D
; gcsMEM
gcfMEM_InitFSMemPool
gcfMEM_FreeFSMemPool
gcfMEM_FSMemPoolGetANode
gcfMEM_FSMemPoolFreeANode
gcfMEM_FSMemPoolFreeAList
gcfMEM_InitAFSMemPool
gcfMEM_FreeAFSMemPool
gcfMEM_AFSMemPoolGetANode
gcfMEM_AFSMemPoolFreeANode
!ENDIF
; gcoHAL
gcoHAL_Construct
gcoHAL_Destroy
gcoHAL_IsFeatureAvailable
gcoHAL_QueryChipIdentity
gcoHAL_Call
gcoHAL_QueryVideoMemory
gcoHAL_MapMemory
gcoHAL_UnmapMemory
gcoHAL_ScheduleUnmapMemory
gcoHAL_ScheduleUnmapUserMemory
gcoHAL_Commit
gcoHAL_QueryTiled
gcoHAL_Get2DEngine
gcoHAL_Get3DEngine
gcoHAL_GetVGEngine
gcoHAL_GetDump
gcoHAL_ScheduleEvent
!IFNDEF VIVANTE_NO_3D
gcoHAL_QueryTargetCaps
gcoHAL_SetDepthOnly
gcoHAL_QueryShaderCaps
gcoHAL_QueryTextureCaps
gcoHAL_QueryStreamCaps
!ENDIF
gcoHAL_ProfileStart
gcoHAL_ProfileEnd
gcoHAL_Compact
gcoHAL_SetPowerManagementState
gcoHAL_QueryPowerManagementState
gcoHAL_DestroySurface
; gcoDUMP
gcoDUMP_Construct
gcoDUMP_Destroy
gcoDUMP_Control
gcoDUMP_IsEnabled
gcoDUMP_AddSurface
gcoDUMP_FrameBegin
gcoDUMP_FrameEnd
gcoDUMP_DumpData
gcoDUMP_Delete
gcfDump
; gcoSURF
gcoSURF_Construct
gcoSURF_Destroy
gcoSURF_MapUserSurface
gcoSURF_GetSize
gcoSURF_GetAlignedSize
gcoSURF_GetFormat
gcoSURF_Lock
gcoSURF_Unlock
gcoSURF_Fill
gcoSURF_Blend
gcoSURF_SetClipping
gcoSURF_Clear2D
gcoSURF_Line
gcoSURF_Blit
gcoSURF_MonoBlit
gcoSURF_FilterBlit
gcoSURF_EnableAlphaBlend
gcoSURF_DisableAlphaBlend
gcoSURF_CopyPixels
gcoSURF_ReadPixel
gcoSURF_WritePixel
gcoSURF_QueryFormat
gcoSURF_Flush
gcoSURF_SetColorType
gcoSURF_GetColorType
gcoSURF_SetRotation
gcoSURF_ConstructWrapper
gcoSURF_SetBuffer
gcoSURF_SetWindow
gcoSURF_ReferenceSurface
gcoSURF_SetOrientation
gcoSURF_QueryOrientation
gcoSURF_QueryReferenceCount
!IFNDEF VIVANTE_NO_3D
gcoSURF_IsTileStatusSupported
gcoSURF_EnableTileStatus
gcoSURF_DisableTileStatus
gcoSURF_SetSamples
gcoSURF_GetSamples
gcoSURF_Copy
gcoSURF_Clear
gcoSURF_ClearRect
gcoSURF_Resample
gcoSURF_Resolve
gcoSURF_ResolveRect
depr_gcoSURF_Resolve
depr_gcoSURF_ResolveRect
gcoSURF_SetResolvability
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcoINDEX
gcoINDEX_Construct
gcoINDEX_Destroy
gcoINDEX_Lock
gcoINDEX_Unlock
gcoINDEX_Load
gcoINDEX_Bind
gcoINDEX_BindOffset
gcoINDEX_Free
gcoINDEX_Upload
gcoINDEX_UploadOffset
gcoINDEX_QueryCaps
gcoINDEX_GetIndexRange
gcoINDEX_SetDynamic
gcoINDEX_UploadDynamic
!ENDIF
; gco2D
gco2D_Construct
gco2D_Destroy
gco2D_SetBrushLimit
gco2D_FlushBrush
gco2D_LoadSolidBrush
gco2D_SetMonochromeSource
gco2D_SetColorSource
gco2D_SetColorSourceEx
gco2D_SetColorSourceAdvanced
gco2D_SetMaskedSource
gco2D_SetMaskedSourceEx
gco2D_SetSource
gco2D_SetClipping
gco2D_SetTarget
gco2D_SetTargetEx
gco2D_SetStretchFactors
gco2D_SetStretchRectFactors
gco2D_ConstructSingleColorBrush
gco2D_ConstructMonochromeBrush
gco2D_ConstructColorBrush
gco2D_Clear
gco2D_Line
gco2D_ColorLine
gco2D_Blit
gco2D_BatchBlit
gco2D_StretchBlit
gco2D_MonoBlit
gco2D_SetKernelSize
gco2D_SetFilterType
gco2D_SetUserFilterKernel
gco2D_EnableUserFilterPasses
gco2D_FreeFilterBuffer
gco2D_FilterBlit
gco2D_FilterBlitEx
gco2D_EnableAlphaBlend
gco2D_EnableAlphaBlendAdvanced
gco2D_SetPorterDuffBlending
gco2D_DisableAlphaBlend
gco2D_GetPackSize
gco2D_Flush
gco2D_LoadPalette
gco2D_SetBitBlitMirror
gco2D_SetTransparencyAdvanced
gco2D_SetSourceColorKeyAdvanced
gco2D_SetSourceColorKeyRangeAdvanced
gco2D_SetTargetColorKeyAdvanced
gco2D_SetTargetColorKeyRangeAdvanced
gco2D_SetYUVColorMode
gco2D_SetSourceGlobalColorAdvanced
gco2D_SetTargetGlobalColorAdvanced
gco2D_SetPixelMultiplyModeAdvanced
gco2D_SetAutoFlushCycles
gco2D_ProfileEngine
gco2D_GetMaximumDataCount
!IFNDEF VIVANTE_NO_3D
gco3D_Construct
gco3D_Destroy
gco3D_SetAPI
gco3D_SetTarget
gco3D_SetDepth
gco3D_SetViewport
gco3D_SetScissors
gco3D_SetClearColor
gco3D_SetClearColorX
gco3D_SetClearColorF
gco3D_SetClearDepthX
gco3D_SetClearDepthF
gco3D_SetClearStencil
gco3D_Clear
gco3D_ClearRect
gco3D_ClearTileStatus
gco3D_ClearHzTileStatus
gco3D_SetShading
gco3D_EnableBlending
gco3D_SetBlendFunction
gco3D_SetBlendMode
gco3D_SetBlendColor
gco3D_SetBlendColorX
gco3D_SetBlendColorF
gco3D_SetCulling
gco3D_SetPointSizeEnable
gco3D_SetPointSprite
gco3D_SetFill
gco3D_SetDepthCompare
gco3D_EnableDepthWrite
gco3D_SetDepthRangeX
gco3D_SetDepthMode
gco3D_SetDepthRangeF
gco3D_SetLastPixelEnable
gco3D_SetDepthScaleBiasX
gco3D_SetDepthScaleBiasF
gco3D_EnableDither
gco3D_SetColorWrite
gco3D_SetEarlyDepth
gco3D_SetDepthOnly
gco3D_SetStencilMode
gco3D_SetStencilMask
gco3D_SetStencilWriteMask
gco3D_SetStencilReference
gco3D_SetStencilCompare
gco3D_SetStencilPass
gco3D_SetStencilFail
gco3D_SetStencilDepthFail
gco3D_SetAlphaTest
gco3D_SetAlphaCompare
gco3D_SetAlphaReference
gco3D_SetAlphaReferenceX
gco3D_SetAlphaReferenceF
gco3D_SetAntiAliasLine
gco3D_SetAALineTexSlot
gco3D_SetAALineWidth
gco3D_DrawPrimitives
gco3D_DrawPrimitivesOffset
gco3D_DrawIndexedPrimitives
gco3D_DrawIndexedPrimitivesOffset
gco3D_SetAntiAlias
gco3D_WriteBuffer
gco3D_SetFragmentConfiguration
gco3D_EnableTextureStage
gco3D_SetTextureColorMask
gco3D_SetTextureAlphaMask
gco3D_SetFragmentColorX
gco3D_SetFragmentColorF
gco3D_SetFogColorX
gco3D_SetFogColorF
gco3D_SetTetxureColorX
gco3D_SetTetxureColorF
gco3D_SetColorTextureFunction
gco3D_SetAlphaTextureFunction
gco3D_Semaphore
gco3D_SetCentroids
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcoTEXTURE
gcoTEXTURE_Construct
gcoTEXTURE_ConstructSized
gcoTEXTURE_Destroy
gcoTEXTURE_Upload
gcoTEXTURE_UploadSub
gcoTEXTURE_UploadCompressed
gcoTEXTURE_GetMipMap
gcoTEXTURE_GetMipMapFace
gcoTEXTURE_AddMipMap
gcoTEXTURE_AddMipMapFromClient
gcoTEXTURE_AddMipMapFromSurface
gcoTEXTURE_SetEndianHint
gcoTEXTURE_SetAddressingMode
gcoTEXTURE_SetBorderColor
gcoTEXTURE_SetBorderColorX
gcoTEXTURE_SetBorderColorF
gcoTEXTURE_SetMinFilter
gcoTEXTURE_SetMagFilter
gcoTEXTURE_SetMipFilter
gcoTEXTURE_SetLODBiasX
gcoTEXTURE_SetLODBiasF
gcoTEXTURE_SetLODMinX
gcoTEXTURE_SetLODMinF
gcoTEXTURE_SetLODMaxX
gcoTEXTURE_SetLODMaxF
gcoTEXTURE_Bind
gcoTEXTURE_Flush
gcoTEXTURE_QueryCaps
gcoTEXTURE_GetClosestFormat
gcoTEXTURE_Disable
gcoTEXTURE_RenderIntoMipMap
gcoTEXTURE_IsRenderable
gcoTEXTURE_IsComplete
!ENDIF
; gcsRECT
gcsRECT_Height
gcsRECT_Width
gcsRECT_Set
!IFNDEF VIVANTE_NO_3D
; gcoHARDWARE
gcoHARDWARE_QueryTextureCaps
gcoHARDWARE_QueryShaderCaps
gcoHARDWARE_QueryIndexCaps
gcoHARDWARE_QueryStreamCaps
!ENDIF
; gcoBRUSH
gcoBRUSH_Destroy
!IFNDEF VIVANTE_NO_3D
; gcSHADER
gcOptimizeShader
gcLinkShaders
gcLoadShaders
gcSaveProgram
gcSHADER_Construct
gcSHADER_Destroy
gcSHADER_AddUniform
gcSHADER_AddSource
gcSHADER_AddSourceAttributeIndexed
gcSHADER_AddSourceUniformIndexed
gcSHADER_AddSourceSamplerIndexed
gcSHADER_AddOpcodeIndexed
gcSHADER_AddSourceIndexed
gcSHADER_AddAttribute
gcSHADER_AddOutput
gcSHADER_AddOutputIndexed
gcSHADER_AddSourceAttribute
gcSHADER_AddSourceConstant
gcSHADER_AddSourceUniform
gcSHADER_AddLabel
gcSHADER_AddOpcode
gcSHADER_AddOpcode2
gcSHADER_AddOpcodeConditional
gcSHADER_AddVariable
gcSHADER_Pack
gcSHADER_Load
gcSHADER_Save
gcSHADER_GetUniform
gcSHADER_GetUniformCount
gcSHADER_GetAttribute
gcSHADER_GetAttributeCount
gcSHADER_GetPositionAttribute
gcSHADER_GetVariable
gcSHADER_GetVariableCount
gcSHADER_AddFunction
gcSHADER_BeginFunction
gcSHADER_EndFunction
gcSHADER_SetOptimizationOption
gcSHADER_GetPositionAttribute
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcATTRIBUTE
gcATTRIBUTE_GetName
gcATTRIBUTE_GetType
gcATTRIBUTE_IsEnabled
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcFUNCTION
gcFUNCTION_AddArgument
gcFUNCTION_GetArgument
gcFUNCTION_GetLabel
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcUNIFORM
gcUNIFORM_GetName
gcUNIFORM_GetType
gcUNIFORM_GetSampler
gcUNIFORM_SetValue
gcUNIFORM_SetValueX
gcUNIFORM_SetValueF
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcoSTREAM
gcoSTREAM_Construct
gcoSTREAM_Destroy
gcoSTREAM_Upload
gcoSTREAM_SetStride
gcoSTREAM_Lock
gcoSTREAM_Unlock
gcoSTREAM_Reserve
gcoSTREAM_Flush
gcoSTREAM_SetDynamic
gcoSTREAM_UploadDynamic
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcoVERTEX
gcoVERTEX_Construct
gcoVERTEX_Destroy
gcoVERTEX_Reset
gcoVERTEX_EnableAttribute
gcoVERTEX_DisableAttribute
gcoVERTEX_Bind
!ENDIF
!IFNDEF VIVANTE_NO_3D
; gcoBUFFER
gcoBUFFER_Construct
gcoBUFFER_Destroy
gcoBUFFER_Reserve
gcoBUFFER_Write
gcoBUFFER_Commit
!ENDIF
!IFNDEF VIVANTE_NO_PROFILER
; gcoPROFILER
;gcoPROFILER_Initialize
;gcoPROFILER_Destroy
;gcoPROFILER_EndFrame
;gcoPROFILER_ShaderFS
;gcoPROFILER_ShaderVS
!ENDIF
; gcoMATH
gcoMATH_Log2in5dot5
gcoMATH_Sine
gcoMATH_Cosine
gcoMATH_Floor
gcoMATH_Ceiling
gcoMATH_SquareRoot
gcoMATH_Log2
gcoMATH_Power
gcoMATH_Modulo
gcoMATH_ArcCosine
gcoMATH_Absolute
gcoMATH_Exp
gcoMATH_UInt2Float
gcoMATH_Float2UInt
gcoMATH_Multiply
<<

View File

@@ -0,0 +1,449 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#include "gc_hal_kernel_linux.h"
#include "linux/spinlock.h"
#include <stdarg.h>
/*
gcdBUFFERED_OUTPUT
When set to non-zero, all output is collected into a buffer with the
specified size. Once the buffer gets full, or the token "$$FLUSH$$" has
been received, the debug buffer will be printed to the console.
*/
#define gcdBUFFERED_OUTPUT 0
/******************************************************************************\
******************************** Debug Variables *******************************
\******************************************************************************/
static gceSTATUS _lastError = gcvSTATUS_OK;
static gctUINT32 _debugLevel = gcvLEVEL_WARNING;
static gctUINT32 _debugZones = gcvZONE_ALL;
static gctINT _indent = 0;
static spinlock_t _lock = SPIN_LOCK_UNLOCKED;
static void
OutputDebugString(
IN gctCONST_STRING String
)
{
#if gcdBUFFERED_OUTPUT
static gctCHAR outputBuffer[gcdBUFFERED_OUTPUT];
static gctINT outputBufferIndex = 0;
gctINT n, i;
n = (String != gcvNULL) ? strlen(String) + 1 : 0;
if ((n == 0) || (outputBufferIndex + n > gcmSIZEOF(outputBuffer)))
{
for (i = 0; i < outputBufferIndex; i += strlen(outputBuffer + i) + 1)
{
printk(outputBuffer + i);
}
outputBufferIndex = 0;
}
if (n > 0)
{
memcpy(outputBuffer + outputBufferIndex, String, n);
outputBufferIndex += n;
}
#else
if (String != gcvNULL)
{
printk(String);
}
#endif
}
static void
_Print(
IN gctCONST_STRING Message,
IN va_list Arguments
)
{
char buffer[1024];
int i, n;
if (strcmp(Message, "$$FLUSH$$") == 0)
{
spin_lock(&_lock);
{
OutputDebugString(gcvNULL);
}
spin_unlock(&_lock);
return;
}
if (strncmp(Message, "--", 2) == 0)
{
if (_indent == 0)
{
printk("ERROR: _indent=0\n");
}
_indent -= 2;
}
for (i = 0; i < _indent; ++i)
{
buffer[i] = ' ';
}
/* Print message to buffer. */
n = vsnprintf(buffer + i, sizeof(buffer) - i, Message, Arguments);
if ((n <= 0) || (buffer[i + n - 1] != '\n'))
{
/* Append new-line. */
strncat(buffer, "\n", sizeof(buffer));
}
/* Output to debugger. */
spin_lock(&_lock);
{
OutputDebugString(buffer);
}
spin_unlock(&_lock);
if (strncmp(Message, "++", 2) == 0)
{
_indent += 2;
}
}
/******************************************************************************\
********************************* Debug Macros *********************************
\******************************************************************************/
#define _DEBUGPRINT(Message) \
{ \
va_list arguments; \
\
va_start(arguments, Message); \
_Print(Message, arguments); \
va_end(arguments); \
}
/******************************************************************************\
********************************** Debug Code **********************************
\******************************************************************************/
/*******************************************************************************
**
** gckOS_Print
**
** Send a message to the debugger.
**
** INPUT:
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_Print(
IN gctCONST_STRING Message,
...
)
{
_DEBUGPRINT(Message);
}
/*******************************************************************************
**
** gckOS_DebugTrace
**
** Send a leveled message to the debugger.
**
** INPUT:
**
** gctUINT32 Level
** Debug level of message.
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugTrace(
IN gctUINT32 Level,
IN gctCONST_STRING Message,
...
)
{
if (Level > _debugLevel)
{
return;
}
_DEBUGPRINT(Message);
}
/*******************************************************************************
**
** gckOS_DebugTraceZone
**
** Send a leveled and zoned message to the debugger.
**
** INPUT:
**
** gctUINT32 Level
** Debug level for message.
**
** gctUINT32 Zone
** Debug zone for message.
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugTraceZone(
IN gctUINT32 Level,
IN gctUINT32 Zone,
IN gctCONST_STRING Message,
...
)
{
if ((Level > _debugLevel) || !(Zone & _debugZones))
{
return;
}
_DEBUGPRINT(Message);
}
/*******************************************************************************
**
** gckOS_DebugBreak
**
** Break into the debugger.
**
** INPUT:
**
** Nothing.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugBreak(
void
)
{
gckOS_DebugTrace(gcvLEVEL_ERROR, "gckOS_DebugBreak");
}
/*******************************************************************************
**
** gckOS_DebugFatal
**
** Send a message to the debugger and break into the debugger.
**
** INPUT:
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugFatal(
IN gctCONST_STRING Message,
...
)
{
_DEBUGPRINT(Message);
/* Break into the debugger. */
gckOS_DebugBreak();
}
/*******************************************************************************
**
** gckOS_SetDebugLevel
**
** Set the debug level.
**
** INPUT:
**
** gctUINT32 Level
** New debug level.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugLevel(
IN gctUINT32 Level
)
{
_debugLevel = Level;
}
/*******************************************************************************
**
** gckOS_SetDebugZone
**
** Set the debug zone.
**
** INPUT:
**
** gctUINT32 Zone
** New debug zone.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugZone(
IN gctUINT32 Zone
)
{
_debugZones = Zone;
}
/*******************************************************************************
**
** gckOS_SetDebugLevelZone
**
** Set the debug level and zone.
**
** INPUT:
**
** gctUINT32 Level
** New debug level.
**
** gctUINT32 Zone
** New debug zone.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugLevelZone(
IN gctUINT32 Level,
IN gctUINT32 Zone
)
{
_debugLevel = Level;
_debugZones = Zone;
}
/*******************************************************************************
**
** gckOS_SetDebugZones
**
** Enable or disable debug zones.
**
** INPUT:
**
** gctUINT32 Zones
** Debug zones to enable or disable.
**
** gctBOOL Enable
** Set to gcvTRUE to enable the zones (or the Zones with the current
** zones) or gcvFALSE to disable the specified Zones.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugZones(
IN gctUINT32 Zones,
IN gctBOOL Enable
)
{
if (Enable)
{
/* Enable the zones. */
_debugZones |= Zones;
}
else
{
/* Disable the zones. */
_debugZones &= ~Zones;
}
}
/*******************************************************************************
**
** gckOS_Verify
**
** Called to verify the result of a function call.
**
** INPUT:
**
** gceSTATUS Status
** Function call result.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_Verify(
IN gceSTATUS Status
)
{
_lastError = Status;
}

View File

@@ -0,0 +1,836 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#include "gc_hal_kernel_linux.h"
#include <linux/pagemap.h>
#include <linux/seq_file.h>
#include <linux/mm.h>
#include <linux/mman.h>
#define _GC_OBJ_ZONE gcvZONE_DEVICE
#ifdef FLAREON
static struct dove_gpio_irq_handler gc500_handle;
#endif
/******************************************************************************\
******************************** gckGALDEVICE Code *******************************
\******************************************************************************/
gceSTATUS
gckGALDEVICE_AllocateMemory(
IN gckGALDEVICE Device,
IN gctSIZE_T Bytes,
OUT gctPOINTER *Logical,
OUT gctPHYS_ADDR *Physical,
OUT gctUINT32 *PhysAddr
)
{
gceSTATUS status;
gcmkVERIFY_ARGUMENT(Device != NULL);
gcmkVERIFY_ARGUMENT(Logical != NULL);
gcmkVERIFY_ARGUMENT(Physical != NULL);
gcmkVERIFY_ARGUMENT(PhysAddr != NULL);
status = gckOS_AllocateContiguous(Device->os,
gcvFALSE,
&Bytes,
Physical,
Logical);
if (gcmIS_ERROR(status))
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"gckGALDEVICE_AllocateMemory: error status->0x%x",
status);
return status;
}
*PhysAddr = ((PLINUX_MDL)*Physical)->dmaHandle - Device->baseAddress;
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"gckGALDEVICE_AllocateMemory: phys_addr->0x%x phsical->0x%x Logical->0x%x",
(gctUINT32)*Physical,
(gctUINT32)*PhysAddr,
(gctUINT32)*Logical);
/* Success. */
return gcvSTATUS_OK;
}
gceSTATUS
gckGALDEVICE_FreeMemory(
IN gckGALDEVICE Device,
IN gctPOINTER Logical,
IN gctPHYS_ADDR Physical)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
return gckOS_FreeContiguous(Device->os,
Physical,
Logical,
((PLINUX_MDL)Physical)->numPages*PAGE_SIZE);
}
irqreturn_t isrRoutine(int irq, void *ctxt)
{
gckGALDEVICE device = (gckGALDEVICE) ctxt;
int handled = 0;
/* Call kernel interrupt notification. */
if (gckKERNEL_Notify(device->kernel,
gcvNOTIFY_INTERRUPT,
gcvTRUE) == gcvSTATUS_OK)
{
device->dataReady = gcvTRUE;
up(&device->sema);
handled = 1;
}
return IRQ_RETVAL(handled);
}
int threadRoutine(void *ctxt)
{
gckGALDEVICE device = (gckGALDEVICE) ctxt;
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"Starting isr Thread with extension->%p",
device);
for (;;)
{
static int down;
down = down_interruptible(&device->sema);
device->dataReady = gcvFALSE;
if (device->killThread == gcvTRUE)
{
/* The daemon exits. */
while (!kthread_should_stop())
{
gckOS_Delay(device->os, 1);
}
return 0;
}
else
{
gckKERNEL_Notify(device->kernel, gcvNOTIFY_INTERRUPT, gcvFALSE);
}
}
}
/*******************************************************************************
**
** gckGALDEVICE_Setup_ISR
**
** Start the ISR routine.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** gcvSTATUS_OK
** Setup successfully.
** gcvSTATUS_GENERIC_IO
** Setup failed.
*/
gceSTATUS
gckGALDEVICE_Setup_ISR(
IN gckGALDEVICE Device
)
{
gctINT ret;
gcmkVERIFY_ARGUMENT(Device != NULL);
if (Device->irqLine == 0)
{
return gcvSTATUS_GENERIC_IO;
}
/* Hook up the isr based on the irq line. */
#ifdef FLAREON
gc500_handle.dev_name = "galcore interrupt service";
gc500_handle.dev_id = Device;
gc500_handle.handler = isrRoutine;
gc500_handle.intr_gen = GPIO_INTR_LEVEL_TRIGGER;
gc500_handle.intr_trig = GPIO_TRIG_HIGH_LEVEL;
ret = dove_gpio_request (DOVE_GPIO0_7, &gc500_handle);
#else
ret = request_irq(Device->irqLine,
isrRoutine,
IRQF_DISABLED,
"galcore interrupt service",
Device);
#endif
if (ret != 0) {
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Setup_ISR: "
"Could not register irq line->%d",
Device->irqLine);
Device->isrInitialized = gcvFALSE;
return gcvSTATUS_GENERIC_IO;
}
Device->isrInitialized = gcvTRUE;
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Setup_ISR: "
"Setup the irq line->%d",
Device->irqLine);
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Release_ISR
**
** Release the irq line.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Release_ISR(
IN gckGALDEVICE Device
)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
/* release the irq */
if (Device->isrInitialized)
{
#ifdef FLAREON
dove_gpio_free (DOVE_GPIO0_7, "galcore interrupt service");
#else
free_irq(Device->irqLine, Device);
#endif
}
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Start_Thread
**
** Start the daemon thread.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** gcvSTATUS_OK
** Start successfully.
** gcvSTATUS_GENERIC_IO
** Start failed.
*/
gceSTATUS
gckGALDEVICE_Start_Thread(
IN gckGALDEVICE Device
)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
/* start the kernel thread */
Device->threadCtxt = kthread_run(threadRoutine,
Device,
"galcore daemon thread");
Device->threadInitialized = gcvTRUE;
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Start_Thread: "
"Start the daemon thread.");
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Stop_Thread
**
** Stop the gal device, including the following actions: stop the daemon
** thread, release the irq.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Stop_Thread(
gckGALDEVICE Device
)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
/* stop the thread */
if (Device->threadInitialized)
{
Device->killThread = gcvTRUE;
up(&Device->sema);
kthread_stop(Device->threadCtxt);
}
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Start
**
** Start the gal device, including the following actions: setup the isr routine
** and start the daemoni thread.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** gcvSTATUS_OK
** Start successfully.
*/
gceSTATUS
gckGALDEVICE_Start(
IN gckGALDEVICE Device
)
{
/* start the daemon thread */
gcmkVERIFY_OK(gckGALDEVICE_Start_Thread(Device));
/* setup the isr routine */
gcmkVERIFY_OK(gckGALDEVICE_Setup_ISR(Device));
/* Switch to SUSPEND power state. */
gcmkVERIFY_OK(
gckHARDWARE_SetPowerManagementState(Device->kernel->hardware,
gcvPOWER_SUSPEND_ATPOWERON));
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Stop
**
** Stop the gal device, including the following actions: stop the daemon
** thread, release the irq.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Stop(
gckGALDEVICE Device
)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
/* Switch to ON power state. */
gcmkVERIFY_OK(
gckHARDWARE_SetPowerManagementState(Device->kernel->hardware,
gcvPOWER_ON));
if (Device->isrInitialized)
{
gckGALDEVICE_Release_ISR(Device);
}
if (Device->threadInitialized)
{
gckGALDEVICE_Stop_Thread(Device);
}
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Construct
**
** Constructor.
**
** INPUT:
**
** OUTPUT:
**
** gckGALDEVICE * Device
** Pointer to a variable receiving the gckGALDEVICE object pointer on
** success.
*/
gceSTATUS
gckGALDEVICE_Construct(
IN gctINT IrqLine,
IN gctUINT32 RegisterMemBase,
IN gctSIZE_T RegisterMemSize,
IN gctUINT32 ContiguousBase,
IN gctSIZE_T ContiguousSize,
IN gctSIZE_T BankSize,
IN gctINT FastClear,
IN gctINT Compression,
IN gctUINT32 BaseAddress,
IN gctINT Signal,
OUT gckGALDEVICE *Device
)
{
gctUINT32 internalBaseAddress = 0, internalAlignment = 0;
gctUINT32 externalBaseAddress = 0, externalAlignment = 0;
gctUINT32 horizontalTileSize, verticalTileSize;
gctUINT32 physAddr;
gctUINT32 physical;
gckGALDEVICE device;
gceSTATUS status;
gcmkTRACE(gcvLEVEL_VERBOSE, "[galcore] Enter gckGALDEVICE_Construct");
/* Allocate device structure. */
device = kmalloc(sizeof(struct _gckGALDEVICE), GFP_KERNEL);
if (!device)
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Can't allocate memory.");
return gcvSTATUS_OUT_OF_MEMORY;
}
memset(device, 0, sizeof(struct _gckGALDEVICE));
physical = RegisterMemBase;
/* Set up register memory region */
if (physical != 0)
{
/* Request a region. */
request_mem_region(RegisterMemBase, RegisterMemSize, "galcore register region");
device->registerBase = (gctPOINTER) ioremap_nocache(RegisterMemBase,
RegisterMemSize);
if (!device->registerBase)
{
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Unable to map location->0x%lX for size->%ld",
RegisterMemBase,
RegisterMemSize);
return gcvSTATUS_OUT_OF_RESOURCES;
}
physical += RegisterMemSize;
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: "
"RegisterBase after mapping Address->0x%x is 0x%x",
(gctUINT32)RegisterMemBase,
(gctUINT32)device->registerBase);
}
/* construct the gckOS object */
device->baseAddress = BaseAddress;
gcmkVERIFY_OK(gckOS_Construct(device, &device->os));
/* construct the gckKERNEL object. */
gcmkVERIFY_OK(gckKERNEL_Construct(device->os, device, &device->kernel));
gcmkVERIFY_OK(gckHARDWARE_SetFastClear(device->kernel->hardware,
FastClear,
Compression));
/* query the ceiling of the system memory */
gcmkVERIFY_OK(gckHARDWARE_QuerySystemMemory(device->kernel->hardware,
&device->systemMemorySize,
&device->systemMemoryBaseAddress));
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: "
"Will be trying to allocate contiguous memory of 0x%x bytes",
(gctUINT32)device->systemMemoryBaseAddress);
#if COMMAND_PROCESSOR_VERSION == 1
/* start the command queue */
gcmkVERIFY_OK(gckCOMMAND_Start(device->kernel->command));
#endif
/* initialize the thread daemon */
sema_init(&device->sema, 0);
device->threadInitialized = gcvFALSE;
device->killThread = gcvFALSE;
/* initialize the isr */
device->isrInitialized = gcvFALSE;
device->dataReady = gcvFALSE;
device->irqLine = IrqLine;
device->signal = Signal;
/* query the amount of video memory */
gcmkVERIFY_OK(gckHARDWARE_QueryMemory(device->kernel->hardware,
&device->internalSize,
&internalBaseAddress,
&internalAlignment,
&device->externalSize,
&externalBaseAddress,
&externalAlignment,
&horizontalTileSize,
&verticalTileSize));
/* set up the internal memory region */
if (device->internalSize > 0)
{
gceSTATUS status = gckVIDMEM_Construct(device->os,
internalBaseAddress,
device->internalSize,
internalAlignment,
0,
&device->internalVidMem);
if (gcmIS_ERROR(status))
{
/* error, remove internal heap */
device->internalSize = 0;
}
else
{
/* map internal memory */
device->internalPhysical = (gctPHYS_ADDR)physical;
device->internalLogical = (gctPOINTER)ioremap_nocache(
physical, device->internalSize);
gcmkASSERT(device->internalLogical != NULL);
physical += device->internalSize;
}
}
if (device->externalSize > 0)
{
/* create the external memory heap */
gceSTATUS status = gckVIDMEM_Construct(device->os,
externalBaseAddress,
device->externalSize,
externalAlignment,
0,
&device->externalVidMem);
if (gcmIS_ERROR(status))
{
/* error, remove internal heap */
device->externalSize = 0;
}
else
{
/* map internal memory */
device->externalPhysical = (gctPHYS_ADDR)physical;
device->externalLogical = (gctPOINTER)ioremap_nocache(
physical, device->externalSize);
gcmkASSERT(device->externalLogical != NULL);
physical += device->externalSize;
}
}
/* set up the contiguous memory */
device->contiguousSize = ContiguousSize;
if (ContiguousBase == 0)
{
status = gcvSTATUS_OUT_OF_MEMORY;
while (device->contiguousSize > 0)
{
gcmkTRACE_ZONE(
gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Will be trying to allocate contiguous memory of %ld bytes",
device->contiguousSize
);
/* allocate contiguous memory */
status = gckGALDEVICE_AllocateMemory(
device,
device->contiguousSize,
&device->contiguousBase,
&device->contiguousPhysical,
&physAddr
);
if (gcmIS_SUCCESS(status))
{
gcmkTRACE_ZONE(
gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Contiguous allocated size->0x%08X Virt->0x%08lX physAddr->0x%08X",
device->contiguousSize,
device->contiguousBase,
physAddr
);
status = gckVIDMEM_Construct(
device->os,
physAddr | device->systemMemoryBaseAddress,
device->contiguousSize,
64,
BankSize,
&device->contiguousVidMem
);
if (gcmIS_SUCCESS(status))
{
device->contiguousMapped = gcvFALSE;
/* success, abort loop */
gcmkTRACE_ZONE(
gcvLEVEL_INFO, gcvZONE_DRIVER,
"Using %u bytes of contiguous memory.",
device->contiguousSize
);
break;
}
gcmkVERIFY_OK(gckGALDEVICE_FreeMemory(
device,
device->contiguousBase,
device->contiguousPhysical
));
device->contiguousBase = NULL;
}
if (device->contiguousSize <= (4 << 20))
{
device->contiguousSize = 0;
}
else
{
device->contiguousSize -= (4 << 20);
}
}
}
else
{
/* Create the contiguous memory heap. */
status = gckVIDMEM_Construct(
device->os,
(ContiguousBase - device->baseAddress) | device->systemMemoryBaseAddress,
ContiguousSize,
64,
BankSize,
&device->contiguousVidMem
);
if (gcmIS_ERROR(status))
{
/* Error, roll back. */
device->contiguousVidMem = gcvNULL;
device->contiguousSize = 0;
}
else
{
/* Map the contiguous memory. */
request_mem_region(
ContiguousBase,
ContiguousSize,
"galcore managed memory"
);
device->contiguousPhysical = (gctPHYS_ADDR) ContiguousBase;
device->contiguousSize = ContiguousSize;
device->contiguousBase = (gctPOINTER) ioremap_nocache(ContiguousBase, ContiguousSize);
device->contiguousMapped = gcvTRUE;
if (device->contiguousBase == gcvNULL)
{
/* Error, roll back. */
gcmkVERIFY_OK(gckVIDMEM_Destroy(device->contiguousVidMem));
device->contiguousVidMem = gcvNULL;
device->contiguousSize = 0;
status = gcvSTATUS_OUT_OF_RESOURCES;
}
}
}
*Device = device;
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Initialized device->%p contiguous->%lu @ %p (0x%08X)",
device,
device->contiguousSize,
device->contiguousBase,
device->contiguousPhysical);
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Destroy
**
** Class destructor.
**
** INPUT:
**
** Nothing.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Destroy(
gckGALDEVICE Device)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
gcmkTRACE(gcvLEVEL_VERBOSE, "[ENTER] gckGALDEVICE_Destroy");
/* Destroy the gckKERNEL object. */
gcmkVERIFY_OK(gckKERNEL_Destroy(Device->kernel));
if (Device->internalVidMem != gcvNULL)
{
/* destroy the internal heap */
gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->internalVidMem));
/* unmap the internal memory */
iounmap(Device->internalLogical);
}
if (Device->externalVidMem != gcvNULL)
{
/* destroy the internal heap */
gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->externalVidMem));
/* unmap the external memory */
iounmap(Device->externalLogical);
}
if (Device->contiguousVidMem != gcvNULL)
{
/* Destroy the contiguous heap */
gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->contiguousVidMem));
if (Device->contiguousMapped)
{
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Destroy: "
"Unmapping contiguous memory->0x%08lX",
Device->contiguousBase);
iounmap(Device->contiguousBase);
}
else
{
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Destroy: "
"Freeing contiguous memory->0x%08lX",
Device->contiguousBase);
gcmkVERIFY_OK(gckGALDEVICE_FreeMemory(Device,
Device->contiguousBase,
Device->contiguousPhysical));
}
}
if (Device->registerBase)
{
iounmap(Device->registerBase);
}
/* Destroy the gckOS object. */
gcmkVERIFY_OK(gckOS_Destroy(Device->os));
kfree(Device);
gcmkTRACE(gcvLEVEL_VERBOSE, "[galcore] Leave gckGALDEVICE_Destroy");
return gcvSTATUS_OK;
}

View File

@@ -0,0 +1,148 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_kernel_device_h_
#define __gc_hal_kernel_device_h_
#define gcdkUSE_MEMORY_RECORD 1
#ifdef ANDROID
#define gcdkREPORT_VIDMEM_LEAK 0
#else
#define gcdkREPORT_VIDMEM_LEAK 1
#endif
/******************************************************************************\
******************************* gckGALDEVICE Structure *******************************
\******************************************************************************/
typedef struct _gckGALDEVICE
{
/* Objects. */
gckOS os;
gckKERNEL kernel;
/* Attributes. */
gctSIZE_T internalSize;
gctPHYS_ADDR internalPhysical;
gctPOINTER internalLogical;
gckVIDMEM internalVidMem;
gctSIZE_T externalSize;
gctPHYS_ADDR externalPhysical;
gctPOINTER externalLogical;
gckVIDMEM externalVidMem;
gckVIDMEM contiguousVidMem;
gctPOINTER contiguousBase;
gctPHYS_ADDR contiguousPhysical;
gctSIZE_T contiguousSize;
gctBOOL contiguousMapped;
gctPOINTER contiguousMappedUser;
gctSIZE_T systemMemorySize;
gctUINT32 systemMemoryBaseAddress;
gctPOINTER registerBase;
gctSIZE_T registerSize;
gctUINT32 baseAddress;
/* IRQ management. */
gctINT irqLine;
gctBOOL isrInitialized;
gctBOOL dataReady;
/* Thread management. */
struct task_struct *threadCtxt;
struct semaphore sema;
gctBOOL threadInitialized;
gctBOOL killThread;
/* Signal management. */
gctINT signal;
}
* gckGALDEVICE;
#if gcdkUSE_MEMORY_RECORD
typedef struct MEMORY_RECORD
{
gcuVIDMEM_NODE_PTR node;
struct MEMORY_RECORD * prev;
struct MEMORY_RECORD * next;
}
MEMORY_RECORD, * MEMORY_RECORD_PTR;
#endif
typedef struct _gcsHAL_PRIVATE_DATA
{
gckGALDEVICE device;
gctPOINTER mappedMemory;
gctPOINTER contiguousLogical;
#if gcdkUSE_MEMORY_RECORD
MEMORY_RECORD memoryRecordList;
#endif
}
gcsHAL_PRIVATE_DATA, * gcsHAL_PRIVATE_DATA_PTR;
gceSTATUS gckGALDEVICE_Setup_ISR(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Release_ISR(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Start_Thread(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Stop_Thread(
gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Start(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Stop(
gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Construct(
IN gctINT IrqLine,
IN gctUINT32 RegisterMemBase,
IN gctSIZE_T RegisterMemSize,
IN gctUINT32 ContiguousBase,
IN gctSIZE_T ContiguousSize,
IN gctSIZE_T BankSize,
IN gctINT FastClear,
IN gctINT Compression,
IN gctUINT32 BaseAddress,
IN gctINT Signal,
OUT gckGALDEVICE *Device
);
gceSTATUS gckGALDEVICE_Destroy(
IN gckGALDEVICE Device
);
#endif /* __gc_hal_kernel_device_h_ */

View File

@@ -0,0 +1,804 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#include <linux/device.h>
#include <linux/miscdevice.h>
#include "gc_hal_kernel_linux.h"
#include "gc_hal_driver.h"
#include "gc_hal_user_context.h"
#if USE_PLATFORM_DRIVER
#include <linux/platform_device.h>
#endif
MODULE_DESCRIPTION("Vivante Graphics Driver");
MODULE_LICENSE("GPL");
struct class *gpuClass;
static gckGALDEVICE galDevice;
static int major = 199;
module_param(major, int, 0644);
int irqLine = 0;
module_param(irqLine, int, 0644);
long registerMemBase = 0x80000000;
module_param(registerMemBase, long, 0644);
ulong registerMemSize = 256 << 10;
module_param(registerMemSize, ulong, 0644);
long contiguousSize = 4 << 20;
module_param(contiguousSize, long, 0644);
ulong contiguousBase = 0;
module_param(contiguousBase, ulong, 0644);
long bankSize = 32 << 20;
module_param(bankSize, long, 0644);
int fastClear = -1;
module_param(fastClear, int, 0644);
int compression = -1;
module_param(compression, int, 0644);
int signal = 48;
module_param(signal, int, 0644);
ulong baseAddress = 0;
module_param(baseAddress, ulong, 0644);
int showArgs = 0;
module_param(showArgs, int, 0644);
static int drv_open(struct inode *inode, struct file *filp);
static int drv_release(struct inode *inode, struct file *filp);
static int drv_ioctl(struct inode *inode, struct file *filp,
unsigned int ioctlCode, unsigned long arg);
static int drv_mmap(struct file * filp, struct vm_area_struct * vma);
struct file_operations driver_fops =
{
.open = drv_open,
.release = drv_release,
.ioctl = drv_ioctl,
.mmap = drv_mmap,
};
int drv_open(struct inode *inode, struct file* filp)
{
gcsHAL_PRIVATE_DATA_PTR private;
gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER,
"Entering drv_open\n");
private = kmalloc(sizeof(gcsHAL_PRIVATE_DATA), GFP_KERNEL);
if (private == gcvNULL)
{
return -ENOTTY;
}
private->device = galDevice;
private->mappedMemory = gcvNULL;
private->contiguousLogical = gcvNULL;
#if gcdkUSE_MEMORY_RECORD
private->memoryRecordList.prev = &private->memoryRecordList;
private->memoryRecordList.next = &private->memoryRecordList;
#endif
/* A process gets attached. */
gcmkVERIFY_OK(
gckKERNEL_AttachProcess(galDevice->kernel, gcvTRUE));
if (!galDevice->contiguousMapped)
{
gcmkVERIFY_OK(gckOS_MapMemory(galDevice->os,
galDevice->contiguousPhysical,
galDevice->contiguousSize,
&private->contiguousLogical));
}
filp->private_data = private;
return 0;
}
extern void
OnProcessExit(
IN gckOS Os,
IN gckKERNEL Kernel
);
int drv_release(struct inode* inode, struct file* filp)
{
gcsHAL_PRIVATE_DATA_PTR private;
gckGALDEVICE device;
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"Entering drv_close\n");
private = filp->private_data;
gcmkASSERT(private != gcvNULL);
device = private->device;
#if gcdkUSE_MEMORY_RECORD
FreeAllMemoryRecord(galDevice->os, &private->memoryRecordList);
#ifdef ANDROID
gcmkVERIFY_OK(gckOS_Delay(galDevice->os, 1000));
#else
gcmkVERIFY_OK(gckCOMMAND_Stall(device->kernel->command));
#endif
#endif
if (!device->contiguousMapped)
{
if (private->contiguousLogical != gcvNULL)
{
gcmkVERIFY_OK(gckOS_UnmapMemory(galDevice->os,
galDevice->contiguousPhysical,
galDevice->contiguousSize,
private->contiguousLogical));
}
}
/* A process gets detached. */
gcmkVERIFY_OK(
gckKERNEL_AttachProcess(galDevice->kernel, gcvFALSE));
kfree(private);
filp->private_data = NULL;
return 0;
}
int drv_ioctl(struct inode *inode,
struct file *filp,
unsigned int ioctlCode,
unsigned long arg)
{
gcsHAL_INTERFACE iface;
gctUINT32 copyLen;
DRIVER_ARGS drvArgs;
gckGALDEVICE device;
gceSTATUS status;
gcsHAL_PRIVATE_DATA_PTR private;
private = filp->private_data;
if (private == gcvNULL)
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] drv_ioctl: private_data is NULL\n");
return -ENOTTY;
}
device = private->device;
if (device == gcvNULL)
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] drv_ioctl: device is NULL\n");
return -ENOTTY;
}
if (ioctlCode != IOCTL_GCHAL_INTERFACE
&& ioctlCode != IOCTL_GCHAL_KERNEL_INTERFACE)
{
/* Unknown command. Fail the I/O. */
return -ENOTTY;
}
/* Get the drvArgs to begin with. */
copyLen = copy_from_user(&drvArgs,
(void *) arg,
sizeof(DRIVER_ARGS));
if (copyLen != 0)
{
/* The input buffer is not big enough. So fail the I/O. */
return -ENOTTY;
}
/* Now bring in the gcsHAL_INTERFACE structure. */
if ((drvArgs.InputBufferSize != sizeof(gcsHAL_INTERFACE))
|| (drvArgs.OutputBufferSize != sizeof(gcsHAL_INTERFACE))
)
{
return -ENOTTY;
}
copyLen = copy_from_user(&iface,
drvArgs.InputBuffer,
sizeof(gcsHAL_INTERFACE));
if (copyLen != 0)
{
/* The input buffer is not big enough. So fail the I/O. */
return -ENOTTY;
}
#if gcdkUSE_MEMORY_RECORD
if (iface.command == gcvHAL_EVENT_COMMIT)
{
MEMORY_RECORD_PTR mr;
gcsQUEUE_PTR queue = iface.u.Event.queue;
while (queue != gcvNULL)
{
gcsQUEUE_PTR record, next;
/* Map record into kernel memory. */
gcmkERR_BREAK(gckOS_MapUserPointer(device->os,
queue,
gcmSIZEOF(gcsQUEUE),
(gctPOINTER *) &record));
switch (record->iface.command)
{
case gcvHAL_FREE_VIDEO_MEMORY:
mr = FindMemoryRecord(device->os,
&private->memoryRecordList,
record->iface.u.FreeVideoMemory.node);
if (mr != gcvNULL)
{
DestoryMemoryRecord(device->os, mr);
}
else
{
printk("*ERROR* Invalid video memory (%p) for free\n",
record->iface.u.FreeVideoMemory.node);
}
break;
default:
break;
}
/* Next record in the queue. */
next = record->next;
/* Unmap record from kernel memory. */
gcmkERR_BREAK(gckOS_UnmapUserPointer(device->os,
queue,
gcmSIZEOF(gcsQUEUE),
(gctPOINTER *) record));
queue = next;
}
}
#endif
status = gckKERNEL_Dispatch(device->kernel,
(ioctlCode == IOCTL_GCHAL_INTERFACE) , &iface);
if (gcmIS_ERROR(status))
{
gcmkTRACE_ZONE(gcvLEVEL_WARNING, gcvZONE_DRIVER,
"[galcore] gckKERNEL_Dispatch returned %d.\n",
status);
}
else if (gcmIS_ERROR(iface.status))
{
gcmkTRACE_ZONE(gcvLEVEL_WARNING, gcvZONE_DRIVER,
"[galcore] IOCTL %d returned %d.\n",
iface.command,
iface.status);
}
/* See if this was a LOCK_VIDEO_MEMORY command. */
else if (iface.command == gcvHAL_LOCK_VIDEO_MEMORY)
{
/* Special case for mapped memory. */
if (private->mappedMemory != gcvNULL
&& iface.u.LockVideoMemory.node->VidMem.memory->object.type
== gcvOBJ_VIDMEM)
{
/* Compute offset into mapped memory. */
gctUINT32 offset = (gctUINT8 *) iface.u.LockVideoMemory.memory
- (gctUINT8 *) device->contiguousBase;
/* Compute offset into user-mapped region. */
iface.u.LockVideoMemory.memory =
(gctUINT8 *) private->mappedMemory + offset;
}
}
#if gcdkUSE_MEMORY_RECORD
else if (iface.command == gcvHAL_ALLOCATE_VIDEO_MEMORY)
{
CreateMemoryRecord(device->os,
&private->memoryRecordList,
iface.u.AllocateVideoMemory.node);
}
else if (iface.command == gcvHAL_ALLOCATE_LINEAR_VIDEO_MEMORY)
{
CreateMemoryRecord(device->os,
&private->memoryRecordList,
iface.u.AllocateLinearVideoMemory.node);
}
else if (iface.command == gcvHAL_FREE_VIDEO_MEMORY)
{
MEMORY_RECORD_PTR mr;
mr = FindMemoryRecord(device->os,
&private->memoryRecordList,
iface.u.FreeVideoMemory.node);
if (mr != gcvNULL)
{
DestoryMemoryRecord(device->os, mr);
}
else
{
printk("*ERROR* Invalid video memory for free\n");
}
}
#endif
/* Copy data back to the user. */
copyLen = copy_to_user(drvArgs.OutputBuffer,
&iface,
sizeof(gcsHAL_INTERFACE));
if (copyLen != 0)
{
/* The output buffer is not big enough. So fail the I/O. */
return -ENOTTY;
}
return 0;
}
static int drv_mmap(struct file * filp, struct vm_area_struct * vma)
{
gcsHAL_PRIVATE_DATA_PTR private = filp->private_data;
gckGALDEVICE device;
int ret;
unsigned long size = vma->vm_end - vma->vm_start;
if (private == gcvNULL)
{
return -ENOTTY;
}
device = private->device;
if (device == gcvNULL)
{
return -ENOTTY;
}
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND;
vma->vm_pgoff = 0;
if (device->contiguousMapped)
{
ret = io_remap_pfn_range(vma,
vma->vm_start,
(gctUINT32) device->contiguousPhysical >> PAGE_SHIFT,
size,
vma->vm_page_prot);
private->mappedMemory = (ret == 0) ? (gctPOINTER) vma->vm_start : gcvNULL;
return ret;
}
else
{
return -ENOTTY;
}
}
static struct miscdevice miscdev = {
.name = "galcore",
.fops = &driver_fops,
.minor = MISC_DYNAMIC_MINOR,
};
#if !USE_PLATFORM_DRIVER
static int __init drv_init(void)
#else
static int drv_init(void)
#endif
{
int ret;
gckGALDEVICE device;
#if ENABLE_GPU_CLOCK_BY_DRIVER && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
struct clk * clk = NULL;
#endif
gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER,
"Entering drv_init\n");
#if ENABLE_GPU_CLOCK_BY_DRIVER && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
clk = clk_get(NULL, "GCCLK");
if (IS_ERR(clk))
{
int retval = PTR_ERR(clk);
printk("clk get error: %d\n", retval);
return -ENODEV;
}
/* APMU_GC_156M, APMU_GC_624M, APMU_GC_PLL2, APMU_GC_PLL2_DIV2 currently */
if (clk_set_rate(clk, 624000000))
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] Can't set core clock.");
return -EAGAIN;
}
clk_enable(clk);
#endif
if (showArgs)
{
printk("galcore options:\n");
printk(" irqLine = %d\n", irqLine);
printk(" registerMemBase = 0x%08lX\n", registerMemBase);
printk(" contiguousSize = %ld\n", contiguousSize);
printk(" contiguousBase = 0x%08lX\n", contiguousBase);
printk(" bankSize = 0x%08lX\n", bankSize);
printk(" fastClear = %d\n", fastClear);
printk(" compression = %d\n", compression);
printk(" signal = %d\n", signal);
printk(" baseAddress = 0x%08lX\n", baseAddress);
}
/* Create the GAL device. */
gcmkVERIFY_OK(gckGALDEVICE_Construct(irqLine,
registerMemBase,
registerMemSize,
contiguousBase,
contiguousSize,
bankSize,
fastClear,
compression,
baseAddress,
signal,
&device));
/* Start the GAL device. */
if (gcmIS_ERROR(gckGALDEVICE_Start(device)))
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] Can't start the gal device.\n");
/* Roll back. */
gckGALDEVICE_Stop(device);
gckGALDEVICE_Destroy(device);
return -1;
}
#if 1
ret = misc_register(&miscdev);
if (ret < 0)
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] Could not register misc.\n");
/* Roll back. */
gckGALDEVICE_Stop(device);
gckGALDEVICE_Destroy(device);
return -1;
}
galDevice = device;
#else
/* Register the character device. */
ret = register_chrdev(major, DRV_NAME, &driver_fops);
if (ret < 0)
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] Could not allocate major number for mmap.\n");
/* Roll back. */
gckGALDEVICE_Stop(device);
gckGALDEVICE_Destroy(device);
return -1;
}
else
{
if (major == 0)
{
major = ret;
}
}
galDevice = device;
gpuClass = class_create(THIS_MODULE, "graphics_class");
if (IS_ERR(gpuClass)) {
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"Failed to create the class.\n");
return -1;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
device_create(gpuClass, NULL, MKDEV(major, 0), NULL, "galcore");
#else
device_create(gpuClass, NULL, MKDEV(major, 0), "galcore");
#endif
#endif
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] irqLine->%ld, contiguousSize->%lu, memBase->0x%lX\n",
irqLine,
contiguousSize,
registerMemBase);
gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER,
"[galcore] driver registered successfully.\n");
return 0;
}
#if !USE_PLATFORM_DRIVER
static void __exit drv_exit(void)
#else
static void drv_exit(void)
#endif
{
#if ENABLE_GPU_CLOCK_BY_DRIVER && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
struct clk * clk = NULL;
#endif
gcmkTRACE_ZONE(gcvLEVEL_VERBOSE, gcvZONE_DRIVER,
"[galcore] Entering drv_exit\n");
#if 1
misc_deregister(&miscdev);
#else
device_destroy(gpuClass, MKDEV(major, 0));
class_destroy(gpuClass);
unregister_chrdev(major, DRV_NAME);
#endif
gckGALDEVICE_Stop(galDevice);
gckGALDEVICE_Destroy(galDevice);
#if ENABLE_GPU_CLOCK_BY_DRIVER && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
clk = clk_get(NULL, "GCCLK");
clk_disable(clk);
#endif
}
#if !USE_PLATFORM_DRIVER
module_init(drv_init);
module_exit(drv_exit);
#else
#ifdef CONFIG_DOVE_GPU
#define DEVICE_NAME "dove_gpu"
#else
#define DEVICE_NAME "galcore"
#endif
static int __devinit gpu_probe(struct platform_device *pdev)
{
int ret = -ENODEV;
struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_IRQ,"gpu_irq");
if (!res) {
printk(KERN_ERR "%s: No irq line supplied.\n",__FUNCTION__);
goto gpu_probe_fail;
}
irqLine = res->start;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,"gpu_base");
if (!res) {
printk(KERN_ERR "%s: No register base supplied.\n",__FUNCTION__);
goto gpu_probe_fail;
}
registerMemBase = res->start;
registerMemSize = res->end - res->start;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,"gpu_mem");
if (!res) {
printk(KERN_ERR "%s: No memory base supplied.\n",__FUNCTION__);
goto gpu_probe_fail;
}
contiguousBase = res->start;
contiguousSize = res->end-res->start;
ret = drv_init();
if(!ret) {
platform_set_drvdata(pdev,galDevice);
return ret;
}
gpu_probe_fail:
printk(KERN_INFO "Failed to register gpu driver.\n");
return ret;
}
static int __devinit gpu_remove(struct platform_device *pdev)
{
drv_exit();
return 0;
}
static int __devinit gpu_suspend(struct platform_device *dev, pm_message_t state)
{
gceSTATUS status;
gckGALDEVICE device;
device = platform_get_drvdata(dev);
status = gckHARDWARE_SetPowerManagementState(device->kernel->hardware, gcvPOWER_OFF);
if (gcmIS_ERROR(status))
{
return -1;
}
return 0;
}
static int __devinit gpu_resume(struct platform_device *dev)
{
gceSTATUS status;
gckGALDEVICE device;
device = platform_get_drvdata(dev);
status = gckHARDWARE_SetPowerManagementState(device->kernel->hardware, gcvPOWER_ON);
if (gcmIS_ERROR(status))
{
return -1;
}
return 0;
}
static struct platform_driver gpu_driver = {
.probe = gpu_probe,
.remove = gpu_remove,
.suspend = gpu_suspend,
.resume = gpu_resume,
.driver = {
.name = DEVICE_NAME,
}
};
#if 0
#ifndef CONFIG_DOVE_GPU
static struct resource gpu_resources[] = {
{
.name = "gpu_irq",
.flags = IORESOURCE_IRQ,
},
{
.name = "gpu_base",
.flags = IORESOURCE_MEM,
},
{
.name = "gpu_mem",
.flags = IORESOURCE_MEM,
},
};
static struct platform_device * gpu_device;
#endif
#endif
static int __init gpu_init(void)
{
int ret = 0;
#if 0 //add by dkm
#ifndef CONFIG_DOVE_GPU
gpu_resources[0].start = gpu_resources[0].end = irqLine;
gpu_resources[1].start = registerMemBase;
gpu_resources[1].end = registerMemBase + registerMemSize;
gpu_resources[2].start = contiguousBase;
gpu_resources[2].end = contiguousBase + contiguousSize;
/* Allocate device */
gpu_device = platform_device_alloc(DEVICE_NAME, -1);
if (!gpu_device)
{
printk(KERN_ERR "galcore: platform_device_alloc failed.\n");
ret = -ENOMEM;
goto out;
}
/* Insert resource */
ret = platform_device_add_resources(gpu_device, gpu_resources, 3);
if (ret)
{
printk(KERN_ERR "galcore: platform_device_add_resources failed.\n");
goto put_dev;
}
/* Add device */
ret = platform_device_add(gpu_device);
if (ret)
{
printk(KERN_ERR "galcore: platform_device_add failed.\n");
goto del_dev;
}
#endif
#endif
ret = platform_driver_register(&gpu_driver);
if (!ret)
{
goto out;
}
#if 0 //add by dkm
#ifndef CONFIG_DOVE_GPU
del_dev:
platform_device_del(gpu_device);
put_dev:
platform_device_put(gpu_device);
#endif
#endif
out:
return ret;
}
static void __exit gpu_exit(void)
{
platform_driver_unregister(&gpu_driver);
#if 0 //add by dkm
#ifndef CONFIG_DOVE_GPU
platform_device_unregister(gpu_device);
#endif
#endif
}
module_init(gpu_init);
module_exit(gpu_exit);
#endif

View File

@@ -0,0 +1,411 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#include "gc_hal_kernel_linux.h"
#define _GC_OBJ_ZONE gcvZONE_KERNEL
/******************************************************************************\
******************************* gckKERNEL API Code ******************************
\******************************************************************************/
/*******************************************************************************
**
** gckKERNEL_QueryVideoMemory
**
** Query the amount of video memory.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** OUTPUT:
**
** gcsHAL_INTERFACE * Interface
** Pointer to an gcsHAL_INTERFACE structure that will be filled in with
** the memory information.
*/
gceSTATUS
gckKERNEL_QueryVideoMemory(
IN gckKERNEL Kernel,
OUT gcsHAL_INTERFACE * Interface
)
{
gckGALDEVICE device;
gcmkHEADER_ARG("Kernel=%p", Kernel);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Interface != NULL);
/* Extract the pointer to the gckGALDEVICE class. */
device = (gckGALDEVICE) Kernel->context;
/* Get internal memory size and physical address. */
Interface->u.QueryVideoMemory.internalSize = device->internalSize;
Interface->u.QueryVideoMemory.internalPhysical = device->internalPhysical;
/* Get external memory size and physical address. */
Interface->u.QueryVideoMemory.externalSize = device->externalSize;
Interface->u.QueryVideoMemory.externalPhysical = device->externalPhysical;
/* Get contiguous memory size and physical address. */
Interface->u.QueryVideoMemory.contiguousSize = device->contiguousSize;
Interface->u.QueryVideoMemory.contiguousPhysical = device->contiguousPhysical;
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckKERNEL_GetVideoMemoryPool
**
** Get the gckVIDMEM object belonging to the specified pool.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gcePOOL Pool
** Pool to query gckVIDMEM object for.
**
** OUTPUT:
**
** gckVIDMEM * VideoMemory
** Pointer to a variable that will hold the pointer to the gckVIDMEM
** object belonging to the requested pool.
*/
gceSTATUS
gckKERNEL_GetVideoMemoryPool(
IN gckKERNEL Kernel,
IN gcePOOL Pool,
OUT gckVIDMEM * VideoMemory
)
{
gckGALDEVICE device;
gckVIDMEM videoMemory;
gcmkHEADER_ARG("Kernel=%p Pool=%d", Kernel, Pool);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(VideoMemory != NULL);
/* Extract the pointer to the gckGALDEVICE class. */
device = (gckGALDEVICE) Kernel->context;
/* Dispatch on pool. */
switch (Pool)
{
case gcvPOOL_LOCAL_INTERNAL:
/* Internal memory. */
videoMemory = device->internalVidMem;
break;
case gcvPOOL_LOCAL_EXTERNAL:
/* External memory. */
videoMemory = device->externalVidMem;
break;
case gcvPOOL_SYSTEM:
/* System memory. */
videoMemory = device->contiguousVidMem;
break;
default:
/* Unknown pool. */
videoMemory = NULL;
}
/* Return pointer to the gckVIDMEM object. */
*VideoMemory = videoMemory;
/* Return status. */
gcmkFOOTER_ARG("*VideoMemory=%p", *VideoMemory);
return (videoMemory == NULL) ? gcvSTATUS_OUT_OF_MEMORY : gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckKERNEL_MapMemory
**
** Map video memory into the current process space.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctPHYS_ADDR Physical
** Physical address of video memory to map.
**
** gctSIZE_T Bytes
** Number of bytes to map.
**
** OUTPUT:
**
** gctPOINTER * Logical
** Pointer to a variable that will hold the base address of the mapped
** memory region.
*/
gceSTATUS
gckKERNEL_MapMemory(
IN gckKERNEL Kernel,
IN gctPHYS_ADDR Physical,
IN gctSIZE_T Bytes,
OUT gctPOINTER * Logical
)
{
return gckOS_MapMemory(Kernel->os, Physical, Bytes, Logical);
}
/*******************************************************************************
**
** gckKERNEL_UnmapMemory
**
** Unmap video memory from the current process space.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctPHYS_ADDR Physical
** Physical address of video memory to map.
**
** gctSIZE_T Bytes
** Number of bytes to map.
**
** gctPOINTER Logical
** Base address of the mapped memory region.
**
** OUTPUT:
**
** Nothing.
*/
gceSTATUS
gckKERNEL_UnmapMemory(
IN gckKERNEL Kernel,
IN gctPHYS_ADDR Physical,
IN gctSIZE_T Bytes,
IN gctPOINTER Logical
)
{
return gckOS_UnmapMemory(Kernel->os, Physical, Bytes, Logical);
}
/*******************************************************************************
**
** gckKERNEL_MapVideoMemory
**
** Get the logical address for a hardware specific memory address for the
** current process.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctBOOL InUserSpace
** gcvTRUE to map the memory into the user space.
**
** gctUINT32 Address
** Hardware specific memory address.
**
** OUTPUT:
**
** gctPOINTER * Logical
** Pointer to a variable that will hold the logical address of the
** specified memory address.
*/
gceSTATUS
gckKERNEL_MapVideoMemory(
IN gckKERNEL Kernel,
IN gctBOOL InUserSpace,
IN gctUINT32 Address,
OUT gctPOINTER * Logical
)
{
gckGALDEVICE device;
PLINUX_MDL mdl;
PLINUX_MDL_MAP mdlMap;
gcePOOL pool;
gctUINT32 offset, base;
gceSTATUS status;
gctPOINTER logical;
gcmkHEADER_ARG("Kernel=%p InUserSpace=%d Address=%08x",
Kernel, InUserSpace, Address);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Logical != NULL);
/* Extract the pointer to the gckGALDEVICE class. */
device = (gckGALDEVICE) Kernel->context;
/* Split the memory address into a pool type and offset. */
gcmkONERROR(
gckHARDWARE_SplitMemory(Kernel->hardware, Address, &pool, &offset));
/* Dispatch on pool. */
switch (pool)
{
case gcvPOOL_LOCAL_INTERNAL:
/* Internal memory. */
logical = device->internalLogical;
break;
case gcvPOOL_LOCAL_EXTERNAL:
/* External memory. */
logical = device->externalLogical;
break;
case gcvPOOL_SYSTEM:
/* System memory. */
if (device->contiguousMapped)
{
logical = device->contiguousBase;
}
else
{
mdl = (PLINUX_MDL) device->contiguousPhysical;
mdlMap = FindMdlMap(mdl, current->tgid);
gcmkASSERT(mdlMap);
logical = (gctPOINTER) mdlMap->vmaAddr;
}
gcmkVERIFY_OK(
gckHARDWARE_SplitMemory(Kernel->hardware,
device->contiguousVidMem->baseAddress,
&pool,
&base));
offset -= base;
break;
default:
/* Invalid memory pool. */
gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT);
}
/* Build logical address of specified address. */
*Logical = (gctPOINTER) ((gctUINT8_PTR) logical + offset);
/* Success. */
gcmkFOOTER_ARG("*Logical=%p", *Logical);
return gcvSTATUS_OK;
OnError:
/* Retunn the status. */
gcmkFOOTER();
return status;
}
/*******************************************************************************
**
** gckKERNEL_Notify
**
** This function iscalled by clients to notify the gckKERNRL object of an event.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gceNOTIFY Notification
** Notification event.
**
** OUTPUT:
**
** Nothing.
*/
gceSTATUS
gckKERNEL_Notify(
IN gckKERNEL Kernel,
IN gceNOTIFY Notification,
IN gctBOOL Data
)
{
gceSTATUS status;
gcmkHEADER_ARG("Kernel=%p Notification=%d Data=%d",
Kernel, Notification, Data);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
/* Dispatch on notifcation. */
switch (Notification)
{
case gcvNOTIFY_INTERRUPT:
/* Process the interrupt. */
#if COMMAND_PROCESSOR_VERSION > 1
status = gckINTERRUPT_Notify(Kernel->interrupt, Data);
#else
status = gckHARDWARE_Interrupt(Kernel->hardware, Data);
#endif
break;
default:
status = gcvSTATUS_OK;
break;
}
/* Success. */
gcmkFOOTER();
return status;
}
gceSTATUS
gckKERNEL_QuerySettings(
IN gckKERNEL Kernel,
OUT gcsKERNEL_SETTINGS * Settings
)
{
gckGALDEVICE device;
gcmkHEADER_ARG("Kernel=%p", Kernel);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Settings != gcvNULL);
/* Extract the pointer to the gckGALDEVICE class. */
device = (gckGALDEVICE) Kernel->context;
/* Fill in signal. */
Settings->signal = device->signal;
/* Success. */
gcmkFOOTER_ARG("Settings->signal=%d", Settings->signal);
return gcvSTATUS_OK;
}

View File

@@ -0,0 +1,89 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_kernel_linux_h_
#define __gc_hal_kernel_linux_h_
#include <linux/version.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/signal.h>
#ifdef FLAREON
# include <asm/arch-realview/dove_gpio_irq.h>
#endif
#include <linux/interrupt.h>
#include <linux/vmalloc.h>
#include <linux/dma-mapping.h>
#include <linux/kthread.h>
#ifdef MODVERSIONS
# include <linux/modversions.h>
#endif
#include <asm/io.h>
#include <asm/uaccess.h>
#if ENABLE_GPU_CLOCK_BY_DRIVER && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
#include <linux/clk.h>
#endif
#define NTSTRSAFE_NO_CCH_FUNCTIONS
#include "gc_hal.h"
#include "gc_hal_driver.h"
#include "gc_hal_kernel.h"
#include "gc_hal_kernel_device.h"
#include "gc_hal_kernel_os.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
#define FIND_TASK_BY_PID(x) pid_task(find_vpid(x), PIDTYPE_PID)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
#define FIND_TASK_BY_PID(x) find_task_by_vpid(x)
#else
#define FIND_TASK_BY_PID(x) find_task_by_pid(x)
#endif
#define _WIDE(string) L##string
#define WIDE(string) _WIDE(string)
#define countof(a) (sizeof(a) / sizeof(a[0]))
#define DRV_NAME "galcore"
#define GetPageCount(size, offset) ((((size) + ((offset) & ~PAGE_CACHE_MASK)) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
static inline gctINT
GetOrder(
IN gctINT numPages
)
{
gctINT order = 0;
while ((1 << order) < numPages) order++;
return order;
}
#endif /* __gc_hal_kernel_linux_h_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_kernel_os_h_
#define __gc_hal_kernel_os_h_
typedef struct _LINUX_MDL_MAP
{
gctINT pid;
gctPOINTER vmaAddr;
struct vm_area_struct * vma;
struct _LINUX_MDL_MAP * next;
}
LINUX_MDL_MAP, *PLINUX_MDL_MAP;
typedef struct _LINUX_MDL
{
gctINT pid;
char * addr;
#ifdef NO_DMA_COHERENT
gctPOINTER kaddr;
#endif /* NO_DMA_COHERENT */
gctINT numPages;
gctINT pagedMem;
gctBOOL contiguous;
dma_addr_t dmaHandle;
PLINUX_MDL_MAP maps;
struct _LINUX_MDL * prev;
struct _LINUX_MDL * next;
}
LINUX_MDL, *PLINUX_MDL;
extern PLINUX_MDL_MAP
FindMdlMap(
IN PLINUX_MDL Mdl,
IN gctINT PID
);
typedef struct _DRIVER_ARGS
{
gctPOINTER InputBuffer;
gctUINT32 InputBufferSize;
gctPOINTER OutputBuffer;
gctUINT32 OutputBufferSize;
}
DRIVER_ARGS;
/* Cleanup the signal table. */
gceSTATUS
gckOS_CleanProcessSignal(
gckOS Os,
gctHANDLE Process
);
#ifdef gcdkUSE_MEMORY_RECORD
MEMORY_RECORD_PTR
CreateMemoryRecord(
gckOS Os,
MEMORY_RECORD_PTR List,
gcuVIDMEM_NODE_PTR Node
);
void
DestoryMemoryRecord(
gckOS Os,
MEMORY_RECORD_PTR Mr
);
MEMORY_RECORD_PTR
FindMemoryRecord(
gckOS Os,
MEMORY_RECORD_PTR List,
gcuVIDMEM_NODE_PTR Node
);
void
FreeAllMemoryRecord(
gckOS Os,
MEMORY_RECORD_PTR List
);
#endif
#endif /* __gc_hal_kernel_os_h_ */

View File

@@ -0,0 +1,79 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
* Vivante Corporation. No part of this work may be disclosed,
* reproduced, copied, transmitted, or used in any way for any purpose,
* without the express written permission of Vivante Corporation.
*
*****************************************************************************
*
* Auto-generated file on 10/12/2010. Do not edit!!!
*
*****************************************************************************/
/*
* gc_hal_common_qnx.h
*
* Created on: Jul 7, 2010
* Author: tarang
*/
#ifndef GC_HAL_COMMON_QNX_H_
#define GC_HAL_COMMON_QNX_H_
/******************************************************************************\
******************************* QNX Control Codes ******************************
\******************************************************************************/
#ifndef _IOMGR_VIVANTE
#define _IOMGR_VIVANTE (_IOMGR_PRIVATE_BASE + 0x301)
#endif
/*******************************************************************************
** Signal management.
**
** Is much simpler in Neutrino versus Linux :-)
**
** Neutrino pulses are equivalent to RT signals (queued, small payload) except
** they are explicitly received on a channel. We therefore dedicate a thread
** to handle them.
**
** We don't use RT signals because:
** 1. They can be delivered on any thread.
** 2. We don't support SA_RESTART so blocking kernel calls can fail. It would be
** impossible to robustly handle this condition in all libraries.
**
** Only downside is that more information needs to be passed between client/server
** (signals require only PID, pulses require connection ID and receive ID).
*/
typedef struct _gcsSIGNAL
{
/* Pointer to gcoOS object. */
gcoOS os;
/* Signaled state. */
gctBOOL state;
/* Manual reset flag. */
gctBOOL manual;
/* Mutex. */
pthread_mutex_t mutex;
/* Condition. */
pthread_cond_t condition;
/* Number of signals pending in the command queue. */
gctINT pending;
/* Number of signals received. */
gctINT received;
}
gcsSIGNAL;
#endif /* GC_HAL_COMMON_QNX_H_ */

View File

@@ -0,0 +1,435 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
* Vivante Corporation. No part of this work may be disclosed,
* reproduced, copied, transmitted, or used in any way for any purpose,
* without the express written permission of Vivante Corporation.
*
*****************************************************************************
*
* Auto-generated file on 10/12/2010. Do not edit!!!
*
*****************************************************************************/
#include "gc_hal_kernel_qnx.h"
#include <stdarg.h>
/*
gcdBUFFERED_OUTPUT
When set to non-zero, all output is collected into a buffer with the
specified size. Once the buffer gets full, or the token "$$FLUSH$$" has
been received, the debug buffer will be printed to the console.
*/
#define gcdBUFFERED_OUTPUT 0
/******************************************************************************\
******************************** Debug Variables *******************************
\******************************************************************************/
static gceSTATUS _lastError = gcvSTATUS_OK;
static gctUINT32 _debugLevel = gcvLEVEL_ERROR;
static gctUINT32 _debugZones = gcvZONE_NONE;
static gctINT _indent = 0;
static void
OutputDebugString(
IN gctCONST_STRING String
)
{
#if gcdBUFFERED_OUTPUT
static gctCHAR outputBuffer[gcdBUFFERED_OUTPUT];
static gctINT outputBufferIndex = 0;
gctINT n, i;
n = (String != gcvNULL) ? strlen(String) + 1 : 0;
if ((n == 0) || (outputBufferIndex + n > gcmSIZEOF(outputBuffer)))
{
for (i = 0; i < outputBufferIndex; i += strlen(outputBuffer + i) + 1)
{
printf(outputBuffer + i);
}
outputBufferIndex = 0;
}
if (n > 0)
{
memcpy(outputBuffer + outputBufferIndex, String, n);
outputBufferIndex += n;
}
#else
if (String != gcvNULL)
{
printf(String);
}
#endif
}
static void
_Print(
IN gctCONST_STRING Message,
IN va_list Arguments
)
{
char buffer[1024];
int i, n;
if (strcmp(Message, "$$FLUSH$$") == 0)
{
OutputDebugString(gcvNULL);
return;
}
if (strncmp(Message, "--", 2) == 0)
{
if (_indent == 0)
{
printf("ERROR: _indent=0\n");
}
_indent -= 2;
}
for (i = 0; i < _indent; ++i)
{
buffer[i] = ' ';
}
/* Print message to buffer. */
n = vsnprintf(buffer + i, sizeof(buffer) - i, Message, Arguments);
if ((n <= 0) || (buffer[i + n - 1] != '\n'))
{
/* Append new-line. */
strncat(buffer, "\n", sizeof(buffer));
}
/* Output to debugger. */
OutputDebugString(buffer);
if (strncmp(Message, "++", 2) == 0)
{
_indent += 2;
}
}
/******************************************************************************\
********************************* Debug Macros *********************************
\******************************************************************************/
#define _DEBUGPRINT(Message) \
{ \
va_list arguments; \
\
va_start(arguments, Message); \
_Print(Message, arguments); \
va_end(arguments); \
}
/******************************************************************************\
********************************** Debug Code **********************************
\******************************************************************************/
/*******************************************************************************
**
** gckOS_Print
**
** Send a message to the debugger.
**
** INPUT:
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_Print(
IN gctCONST_STRING Message,
...
)
{
_DEBUGPRINT(Message);
}
/*******************************************************************************
**
** gckOS_DebugTrace
**
** Send a leveled message to the debugger.
**
** INPUT:
**
** gctUINT32 Level
** Debug level of message.
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugTrace(
IN gctUINT32 Level,
IN gctCONST_STRING Message,
...
)
{
if (Level > _debugLevel)
{
return;
}
_DEBUGPRINT(Message);
}
/*******************************************************************************
**
** gckOS_DebugTraceZone
**
** Send a leveled and zoned message to the debugger.
**
** INPUT:
**
** gctUINT32 Level
** Debug level for message.
**
** gctUINT32 Zone
** Debug zone for message.
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugTraceZone(
IN gctUINT32 Level,
IN gctUINT32 Zone,
IN gctCONST_STRING Message,
...
)
{
if ((Level > _debugLevel) || !(Zone & _debugZones))
{
return;
}
_DEBUGPRINT(Message);
}
/*******************************************************************************
**
** gckOS_DebugBreak
**
** Break into the debugger.
**
** INPUT:
**
** Nothing.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugBreak(
void
)
{
gckOS_DebugTrace(gcvLEVEL_ERROR, "gckOS_DebugBreak");
}
/*******************************************************************************
**
** gckOS_DebugFatal
**
** Send a message to the debugger and break into the debugger.
**
** INPUT:
**
** gctCONST_STRING Message
** Pointer to message.
**
** ...
** Optional arguments.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_DebugFatal(
IN gctCONST_STRING Message,
...
)
{
_DEBUGPRINT(Message);
/* Break into the debugger. */
gckOS_DebugBreak();
}
/*******************************************************************************
**
** gckOS_SetDebugLevel
**
** Set the debug level.
**
** INPUT:
**
** gctUINT32 Level
** New debug level.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugLevel(
IN gctUINT32 Level
)
{
_debugLevel = Level;
}
/*******************************************************************************
**
** gckOS_SetDebugZone
**
** Set the debug zone.
**
** INPUT:
**
** gctUINT32 Zone
** New debug zone.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugZone(
IN gctUINT32 Zone
)
{
_debugZones = Zone;
}
/*******************************************************************************
**
** gckOS_SetDebugLevelZone
**
** Set the debug level and zone.
**
** INPUT:
**
** gctUINT32 Level
** New debug level.
**
** gctUINT32 Zone
** New debug zone.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugLevelZone(
IN gctUINT32 Level,
IN gctUINT32 Zone
)
{
_debugLevel = Level;
_debugZones = Zone;
}
/*******************************************************************************
**
** gckOS_SetDebugZones
**
** Enable or disable debug zones.
**
** INPUT:
**
** gctUINT32 Zones
** Debug zones to enable or disable.
**
** gctBOOL Enable
** Set to gcvTRUE to enable the zones (or the Zones with the current
** zones) or gcvFALSE to disable the specified Zones.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_SetDebugZones(
IN gctUINT32 Zones,
IN gctBOOL Enable
)
{
if (Enable)
{
/* Enable the zones. */
_debugZones |= Zones;
}
else
{
/* Disable the zones. */
_debugZones &= ~Zones;
}
}
/*******************************************************************************
**
** gckOS_Verify
**
** Called to verify the result of a function call.
**
** INPUT:
**
** gceSTATUS Status
** Function call result.
**
** OUTPUT:
**
** Nothing.
*/
void
gckOS_Verify(
IN gceSTATUS Status
)
{
_lastError = Status;
}

View File

@@ -0,0 +1,812 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
* Vivante Corporation. No part of this work may be disclosed,
* reproduced, copied, transmitted, or used in any way for any purpose,
* without the express written permission of Vivante Corporation.
*
*****************************************************************************
*
* Auto-generated file on 10/12/2010. Do not edit!!!
*
*****************************************************************************/
#include "gc_hal_kernel_qnx.h"
#include <sys/mman.h>
#include <sys/siginfo.h>
#define _GC_OBJ_ZONE gcvZONE_DEVICE
/******************************************************************************\
******************************** gckGALDEVICE Code *******************************
\******************************************************************************/
gceSTATUS
gckGALDEVICE_AllocateMemory(
IN gckGALDEVICE Device,
IN gctSIZE_T Bytes,
OUT gctPOINTER *Logical,
OUT gctPHYS_ADDR *Physical,
OUT gctUINT32 *PhysAddr
)
{
gceSTATUS status;
gcmkVERIFY_ARGUMENT(Device != NULL);
gcmkVERIFY_ARGUMENT(Logical != NULL);
gcmkVERIFY_ARGUMENT(Physical != NULL);
gcmkVERIFY_ARGUMENT(PhysAddr != NULL);
status = gckOS_AllocateContiguous(Device->os,
gcvFALSE,
&Bytes,
Physical,
Logical);
if (gcmIS_ERROR(status))
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"gckGALDEVICE_AllocateMemory: error status->0x%x",
status);
return status;
}
*PhysAddr = (gctUINT32)(*(off_t*) Physical) - Device->baseAddress;
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"gckGALDEVICE_AllocateMemory: phys_addr->0x%x phsical->0x%x Logical->0x%x",
(gctUINT32)*Physical,
(gctUINT32)*PhysAddr,
(gctUINT32)*Logical);
/* Success. */
return gcvSTATUS_OK;
}
gceSTATUS
gckGALDEVICE_FreeMemory(
IN gckGALDEVICE Device,
IN gctPOINTER Logical,
IN gctPHYS_ADDR Physical)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
return gckOS_FreeContiguous(Device->os,
Physical,
Logical,
0);
}
/* TODO. fix global sigevent to be part of device. */
struct sigevent irqEvent;
const struct sigevent* isrRoutine(void* arg, int id)
{
gckGALDEVICE device = (gckGALDEVICE)arg;
/* Call kernel interrupt notification. */
if (gckKERNEL_Notify(device->kernel,
gcvNOTIFY_INTERRUPT,
gcvTRUE) == gcvSTATUS_OK)
{
InterruptUnmask(device->irqLine, device->irqId);
return &irqEvent;
}
return gcvNULL;
}
static void* threadRoutine(void *ctxt)
{
gckGALDEVICE device = (gckGALDEVICE) ctxt;
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"Starting ISR Thread with irq:%d\n",
device->irqLine);
SIGEV_INTR_INIT(&irqEvent);
/* Obtain I/O privileges */
ThreadCtl( _NTO_TCTL_IO, 0 );
device->irqId = InterruptAttach(device->irqLine,
isrRoutine,
(void*)device,
gcmSIZEOF(struct _gckGALDEVICE),
0);
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"irqId:%d\n",
device->irqId);
if (device->irqId < 0) {
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Setup_ISR: "
"Could not register irq line->%d\n",
device->irqLine);
device->isrInitialized = gcvFALSE;
return (void *)1;
}
printf("[Interrupt] Attached irqLine %d with id %d.\n",
device->irqLine, device->irqId);
device->isrInitialized = gcvTRUE;
while (1)
{
if (InterruptWait(0, NULL) == -1)
{
printf("[Interrupt] IST exiting\n");
/* Either something is wrong or the thread got canceled */
InterruptUnmask(device->irqLine, device->irqId);
pthread_exit(NULL);
}
gckKERNEL_Notify(device->kernel, gcvNOTIFY_INTERRUPT, gcvFALSE);
}
return (void *)0;
}
/*******************************************************************************
**
** gckGALDEVICE_Setup_ISR
**
** Start the ISR routine.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** gcvSTATUS_OK
** Setup successfully.
** gcvSTATUS_GENERIC_IO
** Setup failed.
*/
gceSTATUS
gckGALDEVICE_Setup_ISR(
IN gckGALDEVICE Device
)
{
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Release_ISR
**
** Release the irq line.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Release_ISR(
IN gckGALDEVICE Device
)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
return gcvSTATUS_OK;
}
int
gsl_free_interrupts()
{
return 0;
}
/*******************************************************************************
**
** gckGALDEVICE_Start_Thread
**
** Start the daemon thread.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** gcvSTATUS_OK
** Start successfully.
** gcvSTATUS_GENERIC_IO
** Start failed.
*/
gceSTATUS
gckGALDEVICE_Start_Thread(
IN gckGALDEVICE Device
)
{
pthread_attr_t attr;
struct sched_param sched;
gctINT ret;
gcmkVERIFY_ARGUMENT(Device != NULL);
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Start_Thread: Creating threadRoutine\n");
pthread_attr_init(&attr);
pthread_attr_getschedparam(&attr, &sched);
sched.sched_priority += 10;
pthread_attr_setschedparam(&attr, &sched);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
/* Start the interrupt service thread */
if ((ret = pthread_create(&Device->threadCtxt, &attr, threadRoutine, Device)) != 0)
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Start_Thread: Failed with code %d\n",
ret);
return gcvSTATUS_OUT_OF_RESOURCES;
}
pthread_setname_np(Device->threadCtxt, "galcore-IST");
Device->threadInitialized = gcvTRUE;
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Start_Thread: "
"Start the daemon thread.\n");
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Stop_Thread
**
** Stop the gal device, including the following actions: stop the daemon
** thread, release the irq.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Stop_Thread(
gckGALDEVICE Device
)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
/* stop the thread */
if (Device->threadInitialized)
{
InterruptDetach(Device->irqId);
Device->irqId = 0;
ConnectDetach(Device->coid);
Device->coid = 0;
ChannelDestroy(Device->chid);
Device->chid = 0;
pthread_cancel(Device->threadCtxt);
pthread_join(Device->threadCtxt, NULL);
Device->threadCtxt = 0;
Device->threadInitialized = gcvFALSE;
Device->isrInitialized = gcvFALSE;
}
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Start
**
** Start the gal device, including the following actions: setup the isr routine
** and start the daemon thread.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** gcvSTATUS_OK
** Start successfully.
*/
gceSTATUS
gckGALDEVICE_Start(
IN gckGALDEVICE Device
)
{
gceSTATUS ret;
/* Start the daemon thread. */
gcmkVERIFY_OK((ret = gckGALDEVICE_Start_Thread(Device)));
return ret;
}
/*******************************************************************************
**
** gckGALDEVICE_Stop
**
** Stop the gal device, including the following actions: stop the daemon
** thread, release the irq.
**
** INPUT:
**
** gckGALDEVICE Device
** Pointer to an gckGALDEVICE object.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Stop(
gckGALDEVICE Device
)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
if (Device->threadInitialized)
{
gckGALDEVICE_Stop_Thread(Device);
}
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckGALDEVICE_Construct
**
** Constructor.
**
** INPUT:
**
** OUTPUT:
**
** gckGALDEVICE * Device
** Pointer to a variable receiving the gckGALDEVICE object pointer on
** success.
*/
gceSTATUS
gckGALDEVICE_Construct(
IN gctINT IrqLine,
IN gctUINT32 RegisterMemBase,
IN gctSIZE_T RegisterMemSize,
IN gctUINT32 ContiguousBase,
IN gctSIZE_T ContiguousSize,
IN gctSIZE_T BankSize,
IN gctINT FastClear,
IN gctINT Compression,
IN gctUINT32 BaseAddress,
OUT gckGALDEVICE *Device
)
{
gctUINT32 internalBaseAddress, internalAlignment;
gctUINT32 externalBaseAddress, externalAlignment;
gctUINT32 horizontalTileSize, verticalTileSize;
gctUINT32 physAddr;
gctUINT32 physical;
gckGALDEVICE device;
gceSTATUS status;
gcmkTRACE(gcvLEVEL_VERBOSE, "[galcore] Enter gckGALDEVICE_Construct\n");
/* Allocate device structure. */
device = calloc(1, sizeof(struct _gckGALDEVICE));
if (!device)
{
gcmkTRACE_ZONE(gcvLEVEL_ERROR, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Can't allocate memory.\n");
return gcvSTATUS_OUT_OF_MEMORY;
}
physical = RegisterMemBase;
/* Set up register memory region */
if (physical != 0)
{
/* Request a region. */
device->registerBase = (gctPOINTER)mmap_device_io(RegisterMemSize, RegisterMemBase);
if ((uintptr_t)device->registerBase == MAP_DEVICE_FAILED)
{
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Unable to map location->0x%lX for size->%ld\n",
RegisterMemBase,
RegisterMemSize);
return gcvSTATUS_OUT_OF_RESOURCES;
}
physical += RegisterMemSize;
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: "
"RegisterBase after mapping Address->0x%x is 0x%x\n",
(gctUINT32)RegisterMemBase,
(gctUINT32)device->registerBase);
}
/* construct the gckOS object */
device->baseAddress = BaseAddress;
gcmkONERROR(
gckOS_Construct(device, &device->os));
/* construct the gckKERNEL object. */
gcmkONERROR(
gckKERNEL_Construct(device->os, device, &device->kernel));
gcmkONERROR(
gckHARDWARE_SetFastClear(device->kernel->hardware,
FastClear,
Compression));
/* query the ceiling of the system memory */
gcmkONERROR(
gckHARDWARE_QuerySystemMemory(device->kernel->hardware,
&device->systemMemorySize,
&device->systemMemoryBaseAddress));
gcmkTRACE_ZONE(gcvLEVEL_INFO,
gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: "
"Will be trying to allocate contiguous memory of 0x%x bytes\n",
(gctUINT32)device->systemMemoryBaseAddress);
#if COMMAND_PROCESSOR_VERSION == 1
/* start the command queue */
gcmkVERIFY_OK(gckCOMMAND_Start(device->kernel->command));
#endif
/* initialize the thread daemon */
memset(&device->isrLock, 0, sizeof(device->isrLock));
device->threadInitialized = gcvFALSE;
device->killThread = gcvFALSE;
/* initialize the isr */
device->isrInitialized = gcvFALSE;
device->dataReady = gcvFALSE;
device->irqLine = IrqLine;
/* query the amount of video memory */
gcmkVERIFY_OK(gckHARDWARE_QueryMemory(device->kernel->hardware,
&device->internalSize,
&internalBaseAddress,
&internalAlignment,
&device->externalSize,
&externalBaseAddress,
&externalAlignment,
&horizontalTileSize,
&verticalTileSize));
/* set up the internal memory region */
if (device->internalSize > 0)
{
gceSTATUS status = gckVIDMEM_Construct(device->os,
internalBaseAddress,
device->internalSize,
internalAlignment,
0,
&device->internalVidMem);
if (gcmIS_ERROR(status))
{
/* error, remove internal heap */
device->internalSize = 0;
}
else
{
/* map internal memory */
device->internalPhysical = (gctPHYS_ADDR)physical;
device->internalLogical = (gctPOINTER)mmap_device_io(device->internalSize, physical);
gcmkASSERT(device->internalLogical != NULL);
physical += device->internalSize;
}
}
if (device->externalSize > 0)
{
/* create the external memory heap */
gceSTATUS status = gckVIDMEM_Construct(device->os,
externalBaseAddress,
device->externalSize,
externalAlignment,
0,
&device->externalVidMem);
if (gcmIS_ERROR(status))
{
/* error, remove internal heap */
device->externalSize = 0;
}
else
{
/* map internal memory */
device->externalPhysical = (gctPHYS_ADDR)physical;
device->externalLogical = (gctPOINTER)mmap_device_io(device->externalSize, physical);
gcmkASSERT(device->externalLogical != NULL);
physical += device->externalSize;
}
}
/* set up the contiguous memory */
device->contiguousSize = ContiguousSize;
if (ContiguousBase == 0)
{
status = gcvSTATUS_OUT_OF_MEMORY;
while (device->contiguousSize > 0)
{
gcmkTRACE_ZONE(
gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Will be trying to allocate contiguous memory of %ld bytes\n",
device->contiguousSize
);
/* allocate contiguous memory */
status = gckGALDEVICE_AllocateMemory(
device,
device->contiguousSize,
&device->contiguousBase,
&device->contiguousPhysical,
&physAddr
);
if (gcmIS_SUCCESS(status))
{
gcmkTRACE_ZONE(
gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Contiguous allocated size->0x%08X Virt->0x%08lX physAddr->0x%08X\n",
device->contiguousSize,
device->contiguousBase,
physAddr
);
status = gckVIDMEM_Construct(
device->os,
physAddr | device->systemMemoryBaseAddress,
device->contiguousSize,
64,
BankSize,
&device->contiguousVidMem
);
if (gcmIS_SUCCESS(status))
{
device->contiguousMapped = gcvFALSE;
/* success, abort loop */
gcmkTRACE_ZONE(
gcvLEVEL_INFO, gcvZONE_DRIVER,
"Using %u bytes of contiguous memory.\n",
device->contiguousSize
);
break;
}
gcmkVERIFY_OK(gckGALDEVICE_FreeMemory(
device,
device->contiguousBase,
device->contiguousPhysical
));
device->contiguousBase = NULL;
}
device->contiguousSize -= (4 << 20);
}
}
else
{
/* Create the contiguous memory heap. */
status = gckVIDMEM_Construct(
device->os,
(ContiguousBase - device->baseAddress) | device->systemMemoryBaseAddress,
ContiguousSize,
64,
BankSize,
&device->contiguousVidMem
);
if (gcmIS_ERROR(status))
{
/* Error, roll back. */
device->contiguousVidMem = gcvNULL;
device->contiguousSize = 0;
}
else
{
/* Map the contiguous memory. */
device->contiguousPhysical = (gctPHYS_ADDR) ContiguousBase;
device->contiguousSize = ContiguousSize;
device->contiguousBase = (gctPOINTER) mmap_device_io(ContiguousSize, ContiguousBase);
device->contiguousMapped = gcvTRUE;
if (device->contiguousBase == gcvNULL)
{
/* Error, roll back. */
gcmkVERIFY_OK(gckVIDMEM_Destroy(device->contiguousVidMem));
device->contiguousVidMem = gcvNULL;
device->contiguousSize = 0;
status = gcvSTATUS_OUT_OF_RESOURCES;
}
}
}
*Device = device;
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Construct: Initialized device->0x%x contiguous->%lu @ 0x%x (0x%08X)\n",
device,
device->contiguousSize,
device->contiguousBase,
device->contiguousPhysical);
return gcvSTATUS_OK;
OnError:
/* Roll back. */
/* Destroy the gckKERNEL object. */
if ( Device != gcvNULL)
{
gcmkVERIFY_OK(gckGALDEVICE_Destroy(*Device));
}
/* Return the status. */
return status;
}
/*******************************************************************************
**
** gckGALDEVICE_Destroy
**
** Class destructor.
**
** INPUT:
**
** Nothing.
**
** OUTPUT:
**
** Nothing.
**
** RETURNS:
**
** Nothing.
*/
gceSTATUS
gckGALDEVICE_Destroy(
gckGALDEVICE Device)
{
gcmkVERIFY_ARGUMENT(Device != NULL);
gcmkTRACE(gcvLEVEL_VERBOSE, "[ENTER] gckGALDEVICE_Destroy\n");
/* Destroy the gckKERNEL object. */
gcmkVERIFY_OK(gckKERNEL_Destroy(Device->kernel));
if (Device->internalVidMem != gcvNULL)
{
/* destroy the internal heap */
gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->internalVidMem));
/* unmap the internal memory */
munmap_device_io((uintptr_t)Device->internalLogical, Device->internalSize);
}
if (Device->externalVidMem != gcvNULL)
{
/* destroy the internal heap */
gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->externalVidMem));
/* unmap the external memory */
munmap_device_io((uintptr_t)Device->externalLogical, Device->externalSize);
}
if (Device->contiguousVidMem != gcvNULL)
{
/* Destroy the contiguous heap */
gcmkVERIFY_OK(gckVIDMEM_Destroy(Device->contiguousVidMem));
if (Device->contiguousMapped)
{
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Destroy: "
"Unmapping contiguous memory->0x%08lX\n",
Device->contiguousBase);
munmap_device_io((uintptr_t)Device->contiguousBase, Device->contiguousSize);
}
else
{
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_DRIVER,
"[galcore] gckGALDEVICE_Destroy: "
"Freeing contiguous memory->0x%08lX\n",
Device->contiguousBase);
gcmkVERIFY_OK(gckGALDEVICE_FreeMemory(Device,
Device->contiguousBase,
Device->contiguousPhysical));
}
}
if (Device->registerBase)
{
munmap_device_io((uintptr_t)Device->registerBase, Device->registerSize);
}
/* Destroy the gckOS object. */
gcmkVERIFY_OK(gckOS_Destroy(Device->os));
free(Device);
gcmkTRACE(gcvLEVEL_VERBOSE, "[galcore] Leave gckGALDEVICE_Destroy\n");
return gcvSTATUS_OK;
}

View File

@@ -0,0 +1,123 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
* Vivante Corporation. No part of this work may be disclosed,
* reproduced, copied, transmitted, or used in any way for any purpose,
* without the express written permission of Vivante Corporation.
*
*****************************************************************************
*
* Auto-generated file on 10/12/2010. Do not edit!!!
*
*****************************************************************************/
#ifndef __gc_hal_kernel_device_h_
#define __gc_hal_kernel_device_h_
/******************************************************************************\
******************************* gckGALDEVICE Structure *******************************
\******************************************************************************/
#define GALCORE_INTERRUPT_PULSE 0x5D
typedef struct _gckGALDEVICE
{
/* Objects. */
gckOS os;
gckKERNEL kernel;
/* Attributes. */
gctSIZE_T internalSize;
gctPHYS_ADDR internalPhysical;
gctPOINTER internalLogical;
gckVIDMEM internalVidMem;
gctSIZE_T externalSize;
gctPHYS_ADDR externalPhysical;
gctPOINTER externalLogical;
gckVIDMEM externalVidMem;
gckVIDMEM contiguousVidMem;
gctPOINTER contiguousBase;
gctPHYS_ADDR contiguousPhysical;
gctSIZE_T contiguousSize;
gctBOOL contiguousMapped;
gctPOINTER contiguousMappedUser;
gctSIZE_T systemMemorySize;
gctUINT32 systemMemoryBaseAddress;
gctPOINTER registerBase;
gctSIZE_T registerSize;
gctUINT32 baseAddress;
/* IRQ management. */
gctINT irqLine;
gctINT irqId;
gctBOOL isrInitialized;
gctBOOL dataReady;
intrspin_t isrLock;
struct sigevent event;
int chid;
int coid;
/* Thread management. */
pthread_t threadCtxt;
gctBOOL threadInitialized;
gctBOOL killThread;
}
* gckGALDEVICE;
typedef struct _gcsHAL_PRIVATE_DATA
{
gckGALDEVICE device;
gctPOINTER mappedMemory;
gctPOINTER contiguousLogical;
}
gcsHAL_PRIVATE_DATA, * gcsHAL_PRIVATE_DATA_PTR;
gceSTATUS gckGALDEVICE_Setup_ISR(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Release_ISR(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Start_Thread(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Stop_Thread(
gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Start(
IN gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Stop(
gckGALDEVICE Device
);
gceSTATUS gckGALDEVICE_Construct(
IN gctINT IrqLine,
IN gctUINT32 RegisterMemBase,
IN gctSIZE_T RegisterMemSize,
IN gctUINT32 ContiguousBase,
IN gctSIZE_T ContiguousSize,
IN gctSIZE_T BankSize,
IN gctINT FastClear,
IN gctINT Compression,
IN gctUINT32 BaseAddress,
OUT gckGALDEVICE *Device
);
gceSTATUS gckGALDEVICE_Destroy(
IN gckGALDEVICE Device
);
#endif /* __gc_hal_kernel_device_h_ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,163 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
* Vivante Corporation. No part of this work may be disclosed,
* reproduced, copied, transmitted, or used in any way for any purpose,
* without the express written permission of Vivante Corporation.
*
*****************************************************************************
*
* Auto-generated file on 10/12/2010. Do not edit!!!
*
*****************************************************************************/
/*
* Os.h
*
* Created on: Feb 2, 2010
* Author: Tarang Vaish
*/
#ifndef __gc_hal_kernel_os_h_
#define __gc_hal_kernel_os_h_
typedef struct
{
io_msg_t iomsg;
gcsHAL_INTERFACE iface;
} gcsDRIVER_ARGS;
struct _gckPAGE_USAGE
{
gctUINT16 pageCount;
};
struct _gckSHM_POOL
{
gctHANDLE Handle;
gctINT32 fd;
gctUINT32 pid;
gctUINT32 freePage;
gctUINT32 pageCount;
gctUINT32 pageSize;
pthread_mutex_t mutex;
gctUINT32 Logical;
gctUINT32 Physical;
struct _gckPAGE_USAGE* pageUsage;
struct _gckSHM_POOL* nextPool;
};
typedef struct _gckSHM_POOL* gckSHM_POOL;
typedef struct _gckPAGE_USAGE* gckPAGE_USAGE;
gceSTATUS
drv_mempool_init();
void
drv_mempool_destroy();
void
drv_mempool_alloc_contiguous(
IN gctUINT32 Bytes,
OUT gctPHYS_ADDR * Physical,
OUT gctPOINTER * Logical
);
int
drv_mempool_free(
IN gctPOINTER Logical
);
gctUINT32
drv_mempool_get_baseAddress();
gctUINT32
drv_mempool_get_basePAddress();
gctUINT32
drv_mempool_get_page_size();
gctINT
drv_mempool_get_fileDescriptor();
gceSTATUS
drv_mempool_mem_offset(
IN gctPOINTER Logical,
OUT gctUINT32 * Address);
/* Shared memory pool functions. */
gckSHM_POOL drv_shmpool_create(
IN gctUINT32 Pid,
IN gctHANDLE Handle,
IN gctUINT32 PoolSize,
IN gctUINT32 PageSize);
void
drv_shmpool_destroy(
IN gckSHM_POOL ShmPool);
gckSHM_POOL
drv_shm_acquire_pool(
IN gctUINT32 Pid,
IN gctHANDLE Handle
);
gckSHM_POOL
drv_shm_acquire_pool2(
IN gctPOINTER Logical
);
gceSTATUS
drv_shm_remove_pool(
IN gctHANDLE Handle
);
gctUINT32
drv_shmpool_get_BaseAddress(
IN gckSHM_POOL ShmPool
);
gctUINT32
drv_shmpool_get_page_size(
IN gckSHM_POOL ShmPool
);
gceSTATUS
drv_shmpool_mem_offset(
IN gctPOINTER Logical,
OUT gctUINT32 * Address);
gctPOINTER
drv_shmpool_alloc_contiguous(
IN gctUINT32 Pid,
IN gctHANDLE Handle,
IN gctUINT32 Bytes
);
gctUINT32
drv_shmpool_free(
IN gctPOINTER Logical
);
void *
mmap64_join(pid_t pid, void *addr, size_t len, int prot, int flags, int fd, off64_t off);
int
mem_offset64_peer(pid_t pid, const uintptr_t addr, size_t len,
off64_t *offset, size_t *contig_len);
int
munmap_peer(pid_t pid, void *addr, size_t len);
void *
mmap64_peer(pid_t pid, void *addr, size_t len, int prot, int flags, int fd, off64_t off);
#endif /* __gc_hal_kernel_os_h_ */

View File

@@ -0,0 +1,401 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
* Vivante Corporation. No part of this work may be disclosed,
* reproduced, copied, transmitted, or used in any way for any purpose,
* without the express written permission of Vivante Corporation.
*
*****************************************************************************
*
* Auto-generated file on 10/12/2010. Do not edit!!!
*
*****************************************************************************/
#include "gc_hal_kernel_qnx.h"
#define _GC_OBJ_ZONE gcvZONE_KERNEL
/******************************************************************************\
******************************* gckKERNEL API Code ******************************
\******************************************************************************/
/*******************************************************************************
**
** gckKERNEL_QueryVideoMemory
**
** Query the amount of video memory.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** OUTPUT:
**
** gcsHAL_INTERFACE * Interface
** Pointer to an gcsHAL_INTERFACE structure that will be filled in with
** the memory information.
*/
gceSTATUS
gckKERNEL_QueryVideoMemory(
IN gckKERNEL Kernel,
OUT gcsHAL_INTERFACE * Interface
)
{
gckGALDEVICE device;
gcmkHEADER_ARG("Kernel=0x%x", Kernel);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Interface != NULL);
/* Extract the pointer to the gckGALDEVICE class. */
device = (gckGALDEVICE) Kernel->context;
/* Get internal memory size and physical address. */
Interface->u.QueryVideoMemory.internalSize = device->internalSize;
Interface->u.QueryVideoMemory.internalPhysical = device->internalPhysical;
/* Get external memory size and physical address. */
Interface->u.QueryVideoMemory.externalSize = device->externalSize;
Interface->u.QueryVideoMemory.externalPhysical = device->externalPhysical;
/* Get contiguous memory size and physical address. */
Interface->u.QueryVideoMemory.contiguousSize = device->contiguousSize;
Interface->u.QueryVideoMemory.contiguousPhysical = device->contiguousPhysical;
/* Success. */
gcmkFOOTER_NO();
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckKERNEL_GetVideoMemoryPool
**
** Get the gckVIDMEM object belonging to the specified pool.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gcePOOL Pool
** Pool to query gckVIDMEM object for.
**
** OUTPUT:
**
** gckVIDMEM * VideoMemory
** Pointer to a variable that will hold the pointer to the gckVIDMEM
** object belonging to the requested pool.
*/
gceSTATUS
gckKERNEL_GetVideoMemoryPool(
IN gckKERNEL Kernel,
IN gcePOOL Pool,
OUT gckVIDMEM * VideoMemory
)
{
gckGALDEVICE device;
gckVIDMEM videoMemory;
gcmkHEADER_ARG("Kernel=0x%x Pool=0x%x", Kernel, Pool);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(VideoMemory != NULL);
/* Extract the pointer to the gckGALDEVICE class. */
device = (gckGALDEVICE) Kernel->context;
/* Dispatch on pool. */
switch (Pool)
{
case gcvPOOL_LOCAL_INTERNAL:
/* Internal memory. */
videoMemory = device->internalVidMem;
break;
case gcvPOOL_LOCAL_EXTERNAL:
/* External memory. */
videoMemory = device->externalVidMem;
break;
case gcvPOOL_SYSTEM:
/* System memory. */
videoMemory = device->contiguousVidMem;
break;
default:
/* Unknown pool. */
videoMemory = NULL;
}
/* Return pointer to the gckVIDMEM object. */
*VideoMemory = videoMemory;
/* Return status. */
gcmkFOOTER_ARG("*VideoMemory=0x%x", *VideoMemory);
return (videoMemory == NULL) ? gcvSTATUS_OUT_OF_MEMORY : gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckKERNEL_MapMemory
**
** Map video memory into the current process space.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctPHYS_ADDR Physical
** Physical address of video memory to map.
**
** gctSIZE_T Bytes
** Number of bytes to map.
**
** OUTPUT:
**
** gctPOINTER * Logical
** Pointer to a variable that will hold the base address of the mapped
** memory region.
*/
gceSTATUS
gckKERNEL_MapMemory(
IN gckKERNEL Kernel,
IN gctPHYS_ADDR Physical,
IN gctSIZE_T Bytes,
OUT gctPOINTER * Logical
)
{
return gckOS_MapMemory(Kernel->os, Physical, Bytes, Logical);
}
/*******************************************************************************
**
** gckKERNEL_UnmapMemory
**
** Unmap video memory from the current process space.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctPHYS_ADDR Physical
** Physical address of video memory to map.
**
** gctSIZE_T Bytes
** Number of bytes to map.
**
** gctPOINTER Logical
** Base address of the mapped memory region.
**
** OUTPUT:
**
** Nothing.
*/
gceSTATUS
gckKERNEL_UnmapMemory(
IN gckKERNEL Kernel,
IN gctPHYS_ADDR Physical,
IN gctSIZE_T Bytes,
IN gctPOINTER Logical
)
{
return gckOS_UnmapMemory(Kernel->os, Physical, Bytes, Logical);
}
/*******************************************************************************
**
** gckKERNEL_MapVideoMemory
**
** Map video memory for the current process.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctBOOL InUserSpace
** gcvTRUE to map the memory into the user space.
**
** gctUINT32 Address
** Hardware specific memory address.
**
** gctUINT32 Pid
** Process ID of the current process.
**
** gctUINT32 Bytes
** Number of bytes to map.
**
** OUTPUT:
**
** gctPOINTER * Logical
** Pointer to a variable that will hold the logical address of the
** specified memory address.
*/
gceSTATUS
gckKERNEL_MapVideoMemory(
IN gckKERNEL Kernel,
IN gctBOOL InUserSpace,
IN gctUINT32 Address,
IN gctUINT32 Pid,
IN gctUINT32 Bytes,
OUT gctPOINTER * Logical
)
{
off64_t offset = (off64_t)Address - (off64_t)drv_mempool_get_basePAddress();
gcmkHEADER_ARG("Kernel=0x%x InUserSpace=%d Address=%08x",
Kernel, InUserSpace, Address);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
*Logical = (gctPOINTER)mmap64_peer(Pid, gcvNULL, Bytes,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NOINIT,
drv_mempool_get_fileDescriptor(), offset);
if (*Logical == MAP_FAILED) {
*Logical = NULL;
return gcvSTATUS_INVALID_ADDRESS;
}
/* Success. */
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckKERNEL_UnmapVideoMemory
**
** Unmap video memory for the current process.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gctUINT32 Address
** Hardware specific memory address.
**
** gctUINT32 Pid
** Process ID of the current process.
**
** gctUINT32 Bytes
** Number of bytes to map.
**
** OUTPUT:
**
** Nothing.
*/
gceSTATUS
gckKERNEL_UnmapVideoMemory(
IN gckKERNEL Kernel,
IN gctPOINTER Logical,
IN gctUINT32 Pid,
IN gctUINT32 Bytes
)
{
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
if (munmap_peer(Pid, Logical, Bytes) == -1)
{
return gcvSTATUS_INVALID_ADDRESS;
}
/* Success. */
return gcvSTATUS_OK;
}
/*******************************************************************************
**
** gckKERNEL_Notify
**
** This function is called by clients to notify the gckKERNEL object of an event.
**
** INPUT:
**
** gckKERNEL Kernel
** Pointer to an gckKERNEL object.
**
** gceNOTIFY Notification
** Notification event.
**
** OUTPUT:
**
** Nothing.
*/
gceSTATUS
gckKERNEL_Notify(
IN gckKERNEL Kernel,
IN gceNOTIFY Notification,
IN gctBOOL Data
)
{
gceSTATUS status;
gcmkHEADER_ARG("Kernel=0x%x Notification=%d Data=%d",
Kernel, Notification, Data);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
/* Dispatch on notifcation. */
switch (Notification)
{
case gcvNOTIFY_INTERRUPT:
/* Process the interrupt. */
#if COMMAND_PROCESSOR_VERSION > 1
status = gckINTERRUPT_Notify(Kernel->interrupt, Data);
#else
status = gckHARDWARE_Interrupt(Kernel->hardware, Data);
#endif
break;
default:
status = gcvSTATUS_OK;
break;
}
/* Success. */
gcmkFOOTER();
return status;
}
gceSTATUS
gckKERNEL_QuerySettings(
IN gckKERNEL Kernel,
OUT gcsKERNEL_SETTINGS * Settings
)
{
gckGALDEVICE device;
gcmkHEADER_ARG("Kernel=0x%x", Kernel);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Kernel, gcvOBJ_KERNEL);
gcmkVERIFY_ARGUMENT(Settings != gcvNULL);
/* Extract the pointer to the gckGALDEVICE class. */
device = (gckGALDEVICE) Kernel->context;
/* Fill in signal. */
Settings->signal = -1;
/* Success. */
gcmkFOOTER_ARG("Settings->signal=%d", Settings->signal);
return gcvSTATUS_OK;
}

View File

@@ -0,0 +1,58 @@
/****************************************************************************
*
* Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
*
* The material in this file is confidential and contains trade secrets
* of Vivante Corporation. This is proprietary information owned by
* Vivante Corporation. No part of this work may be disclosed,
* reproduced, copied, transmitted, or used in any way for any purpose,
* without the express written permission of Vivante Corporation.
*
*****************************************************************************
*
* Auto-generated file on 10/12/2010. Do not edit!!!
*
*****************************************************************************/
#ifndef __gc_hal_kernel_qnx_h_
#define __gc_hal_kernel_qnx_h_
#define _QNX_SOURCE
#include <errno.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/iofunc.h>
#include <sys/dispatch.h>
#include <sys/procmgr.h>
#include <sys/memmsg.h>
#include <fcntl.h>
#include <sys/syspage.h>
#include <hw/inout.h>
#include <atomic.h>
#define NTSTRSAFE_NO_CCH_FUNCTIONS
#include "gc_hal.h"
#include "gc_hal_driver.h"
#include "gc_hal_kernel.h"
#include "gc_hal_kernel_device.h"
#include "gc_hal_kernel_os.h"
#include "../inc/gc_hal_common_qnx.h"
#define _WIDE(string) L##string
#define WIDE(string) _WIDE(string)
#define countof(a) (sizeof(a) / sizeof(a[0]))
#ifndef GAL_DEV
#define GAL_DEV "/dev/galcore"
#endif
#endif /* __gc_hal_kernel_qnx_h_ */

View File

@@ -0,0 +1,78 @@
##############################################################################
#
# Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
#
# The material in this file is confidential and contains trade secrets
# of Vivante Corporation. This is proprietary information owned by
# Vivante Corporation. No part of this work may be disclosed,
# reproduced, copied, transmitted, or used in any way for any purpose,
# without the express written permission of Vivante Corporation.
#
##############################################################################
#
# Auto-generated file on 10/12/2010. Do not edit!!!
#
##############################################################################
#
# Qnx build file for kernel HAL layer.
#
################################################################################
# Include common definitions.
include $(AQROOT)/makefile.linux.def
################################################################################
# Define a shortcut for the main target.
#ifeq ($(STATIC_LINK),1)
STATIC = 1
#else
DYNAMIC = 1
#endif
PROGRAM := 1
#ifeq ($(STATIC), 1)
TARGET_NAME = galcore.a
#else
TARGET_NAME = galcore
#endif
################################################################################
# Installation directory
INSTALL_DIR := $(SDK_DIR)/drivers
################################################################################
# Supply additional include directories.
INCLUDE += -I$(AQROOT)/hal/inc
INCLUDE += -I$(AQROOT)/hal/user
INCLUDE += -I$(AQROOT)/hal/kernel
INCLUDE += -I$(AQARCH)/hal/kernel
INCLUDE += -I$(AQARCH)/hal/kernel
CFLAGS += $(INCLUDE)
CFLAGS += -fPIC
################################################################################
# Supply necessary libraries.
# Specify Vivante library paths.
LIBS += -L $(AQARCH)/hal/kernel/$(OBJ_DIR)
LIBS += -L $(AQROOT)/hal/kernel/$(OBJ_DIR)
LIBS += -l halarchkernel -l halkernel
################################################################################
# Describe object files.
OBJECTS = \
$(OBJ_DIR)/gc_hal_kernel_driver.o \
$(OBJ_DIR)/gc_hal_kernel_os.o \
$(OBJ_DIR)/gc_hal_kernel_qnx.o \
$(OBJ_DIR)/gc_hal_kernel_device.o \
$(OBJ_DIR)/gc_hal_kernel_debug.o \
include $(AQROOT)/common.target

View File

@@ -0,0 +1,40 @@
##############################################################################
#
# Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
#
# The material in this file is confidential and contains trade secrets
# of Vivante Corporation. This is proprietary information owned by
# Vivante Corporation. No part of this work may be disclosed,
# reproduced, copied, transmitted, or used in any way for any purpose,
# without the express written permission of Vivante Corporation.
#
##############################################################################
#
# Auto-generated file on 10/12/2010. Do not edit!!!
#
##############################################################################
#
# QNX build file for the kernel level HAL libraries.
#
################################################################################
# Define make command.
MAKE = make --makefile=makefile.linux
################################################################################
# Define build directories.
HAL_KERNEL_DRV_ARCH := $(AQARCH)/hal/kernel
HAL_KERNEL_DRV_OS := $(AQROOT)/hal/os/qnx/kernel
HAL_KERNEL_DRV_MAIN := $(AQROOT)/hal/kernel
$(HAL_KERNEL_DRV_OS): $(HAL_KERNEL_DRV_ARCH) $(HAL_KERNEL_DRV_MAIN)
MODULES := $(HAL_KERNEL_DRV_ARCH) $(HAL_KERNEL_DRV_OS) $(HAL_KERNEL_DRV_MAIN)
MAIN_MODULE = $(HAL_KERNEL_DRV_OS)
include $(AQROOT)/common.node

View File

@@ -0,0 +1,170 @@
/****************************************************************************
*
* Copyright (C) 2005 - 2010 by Vivante Corp.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef __gc_hal_user_context_h_
#define __gc_hal_user_context_h_
#ifdef __cplusplus
extern "C" {
#endif
/* gcoCONTEXT structure that hold the current context. */
struct _gcoCONTEXT
{
/* Object. */
gcsOBJECT object;
/* Pointer to gcoOS object. */
gcoOS os;
/* Pointer to gcoHARDWARE object. */
gcoHARDWARE hardware;
/* Context ID. */
gctUINT64 id;
/* State mapping. */
gctUINT32_PTR map;
gctSIZE_T stateCount;
/* State hinting. */
gctUINT8_PTR hint;
gctUINT8 hintValue;
gctSIZE_T hintCount;
/* Context buffer. */
gctUINT32_PTR buffer;
gctUINT32 pipe3DIndex;
gctUINT32 pipe2DIndex;
gctUINT32 linkIndex;
gctUINT32 inUseIndex;
gctSIZE_T bufferSize;
/* Context buffer used for commitment. */
gctSIZE_T bytes;
gctPHYS_ADDR physical;
gctPOINTER logical;
/* Pointer to final LINK command. */
gctPOINTER link;
/* Requested pipe select for context. */
gctUINT32 initialPipe;
gctUINT32 entryPipe;
gctUINT32 currentPipe;
/* Flag to specify whether PostCommit needs to be called. */
gctBOOL postCommit;
/* Busy flag. */
volatile gctBOOL * inUse;
/* Variables used for building state buffer. */
gctUINT32 lastAddress;
gctSIZE_T lastSize;
gctUINT32 lastIndex;
gctBOOL lastFixed;
/* Hint array. */
gctUINT32_PTR hintArray;
gctUINT32_PTR hintIndex;
};
struct _gcoCMDBUF
{
/* The object. */
gcsOBJECT object;
/* Pointer to gcoOS object. */
gcoOS os;
/* Pointer to gcoHARDWARE object. */
gcoHARDWARE hardware;
/* Physical address of command buffer. */
gctPHYS_ADDR physical;
/* Logical address of command buffer. */
gctPOINTER logical;
/* Number of bytes in command buffer. */
gctSIZE_T bytes;
/* Start offset into the command buffer. */
gctUINT32 startOffset;
/* Current offset into the command buffer. */
gctUINT32 offset;
/* Number of free bytes in command buffer. */
gctSIZE_T free;
#if gcdSECURE_USER
/* Table of offsets that define the physical addresses to be mapped. */
gctUINT32_PTR hintTable;
/* Current index into map table. */
gctUINT32_PTR hintIndex;
/* Commit index for map table. */
gctUINT32_PTR hintCommit;
#endif
};
typedef struct _gcsQUEUE * gcsQUEUE_PTR;
typedef struct _gcsQUEUE
{
/* Pointer to next gcsQUEUE structure. */
gcsQUEUE_PTR next;
#ifdef __QNXNTO__
/* Size of this object. */
gctSIZE_T bytes;
#endif
/* Event information. */
gcsHAL_INTERFACE iface;
}
gcsQUEUE;
/* Event queue. */
struct _gcoQUEUE
{
/* The object. */
gcsOBJECT object;
/* Pointer to gcoOS object. */
gcoOS os;
/* Pointer to current event queue. */
gcsQUEUE_PTR head;
gcsQUEUE_PTR tail;
};
#ifdef __cplusplus
}
#endif
#endif /* __gc_hal_user_context_h_ */