mirror of
https://github.com/genesi/linux-legacy.git
synced 2026-07-08 17:56:11 +00:00
gpu driver: remove most of the remaining "abstraction" for OS mutex and so on
* mutex, events, sleeps, process id unabstracted * defines for function types (inline, extern) unabstracted * defines for debug assert change name (KOS_ASSERT -> DEBUG_ASSERT) and left disabled * driver now warns, if logging is enabled, that interruptible mutex locks are interrupted (which never happens in reality but it fixes a warning) * remove fine grained locking "feature" since it's not enabled (and Qualcomm's public driver does not even implement it) * refine mutex initialization where it's still present - don't try and allocate mutex structures where they're always used, just make them parts of the structure (struct mutex * -> struct mutex) * whitespace police
This commit is contained in:
@@ -3,10 +3,7 @@ EXTRA_CFLAGS := \
|
||||
-I$(obj)/include \
|
||||
-I$(obj)/include/api \
|
||||
-I$(obj)/include/ucode \
|
||||
-I$(obj)/platform/hal/linux \
|
||||
-I$(obj)/os/include \
|
||||
-I$(obj)/os/kernel/include \
|
||||
-I$(obj)/os/user/include
|
||||
-I$(obj)/platform/hal/linux
|
||||
|
||||
obj-$(CONFIG_MXC_AMD_GPU) += gpu.o
|
||||
gpu-objs += common/gsl_cmdstream.o \
|
||||
@@ -28,7 +25,6 @@ gpu-objs += common/gsl_cmdstream.o \
|
||||
platform/hal/linux/gsl_hal.o \
|
||||
platform/hal/linux/gsl_kmod_cleanup.o \
|
||||
platform/hal/linux/misc.o \
|
||||
os/kernel/src/linux/kos_lib.o
|
||||
|
||||
|
||||
ifdef CONFIG_MXC_AMD_GPU_LOGGING
|
||||
|
||||
@@ -16,59 +16,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/sched.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
#include "gsl_cmdstream.h"
|
||||
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
#define GSL_CMDSTREAM_MUTEX_CREATE() device->cmdstream_mutex = kos_mutex_create("gsl_cmdstream"); \
|
||||
if (!device->cmdstream_mutex) return (GSL_FAILURE);
|
||||
#define GSL_CMDSTREAM_MUTEX_LOCK() kos_mutex_lock(device->cmdstream_mutex)
|
||||
#define GSL_CMDSTREAM_MUTEX_UNLOCK() kos_mutex_unlock(device->cmdstream_mutex)
|
||||
#define GSL_CMDSTREAM_MUTEX_FREE() kos_mutex_free(device->cmdstream_mutex); device->cmdstream_mutex = 0;
|
||||
#else
|
||||
#define GSL_CMDSTREAM_MUTEX_CREATE()
|
||||
#define GSL_CMDSTREAM_MUTEX_LOCK()
|
||||
#define GSL_CMDSTREAM_MUTEX_UNLOCK()
|
||||
#define GSL_CMDSTREAM_MUTEX_FREE()
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int
|
||||
kgsl_cmdstream_init(gsl_device_t *device)
|
||||
int kgsl_cmdstream_init(gsl_device_t *device)
|
||||
{
|
||||
GSL_CMDSTREAM_MUTEX_CREATE();
|
||||
|
||||
return GSL_SUCCESS;
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
kgsl_cmdstream_close(gsl_device_t *device)
|
||||
int kgsl_cmdstream_close(gsl_device_t *device)
|
||||
{
|
||||
GSL_CMDSTREAM_MUTEX_FREE();
|
||||
|
||||
return GSL_SUCCESS;
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
gsl_timestamp_t
|
||||
kgsl_cmdstream_readtimestamp0(gsl_deviceid_t device_id, gsl_timestamp_type_t type)
|
||||
gsl_timestamp_t kgsl_cmdstream_readtimestamp0(gsl_deviceid_t device_id, gsl_timestamp_type_t type)
|
||||
{
|
||||
gsl_timestamp_t timestamp = -1;
|
||||
gsl_device_t* device = &gsl_driver.device[device_id-1];
|
||||
kgsl_log_write( KGSL_LOG_GROUP_COMMAND | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> gsl_timestamp_t kgsl_cmdstream_readtimestamp(gsl_deviceid_t device_id=%D gsl_timestamp_type_t type=%d)\n", device_id, type );
|
||||
#if (defined(GSL_BLD_G12) && defined(IRQTHREAD_POLL))
|
||||
kos_event_signal(device->irqthread_event);
|
||||
complete_all(&device->irqthread_event);
|
||||
#endif
|
||||
if (type == GSL_TIMESTAMP_CONSUMED)
|
||||
{
|
||||
@@ -86,54 +60,63 @@ kgsl_cmdstream_readtimestamp0(gsl_deviceid_t device_id, gsl_timestamp_type_t typ
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API gsl_timestamp_t
|
||||
gsl_timestamp_t
|
||||
kgsl_cmdstream_readtimestamp(gsl_deviceid_t device_id, gsl_timestamp_type_t type)
|
||||
{
|
||||
gsl_timestamp_t timestamp = -1;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
timestamp = kgsl_cmdstream_readtimestamp0(device_id, type);
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_cmdstream_issueibcmds(gsl_deviceid_t device_id, int drawctxt_index, gpuaddr_t ibaddr, int sizedwords, gsl_timestamp_t *timestamp, unsigned int flags)
|
||||
{
|
||||
gsl_device_t* device = &gsl_driver.device[device_id-1];
|
||||
int status = GSL_FAILURE;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
|
||||
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
kgsl_device_active(device);
|
||||
|
||||
|
||||
if (device->ftbl.cmdstream_issueibcmds)
|
||||
{
|
||||
status = device->ftbl.cmdstream_issueibcmds(device, drawctxt_index, ibaddr, sizedwords, timestamp, flags);
|
||||
}
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_add_timestamp(gsl_deviceid_t device_id, gsl_timestamp_t *timestamp)
|
||||
{
|
||||
gsl_device_t* device = &gsl_driver.device[device_id-1];
|
||||
int status = GSL_FAILURE;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
if (device->ftbl.device_addtimestamp)
|
||||
{
|
||||
status = device->ftbl.device_addtimestamp(device, timestamp);
|
||||
}
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API
|
||||
int kgsl_cmdstream_waittimestamp(gsl_deviceid_t device_id, gsl_timestamp_t timestamp, unsigned int timeout)
|
||||
{
|
||||
gsl_device_t* device = &gsl_driver.device[device_id-1];
|
||||
@@ -154,12 +137,9 @@ kgsl_cmdstream_memqueue_drain(gsl_device_t *device)
|
||||
gsl_timestamp_t timestamp, ts_processed;
|
||||
gsl_memqueue_t *memqueue = &device->memqueue;
|
||||
|
||||
GSL_CMDSTREAM_MUTEX_LOCK();
|
||||
|
||||
// check head
|
||||
if (memqueue->head == NULL)
|
||||
{
|
||||
GSL_CMDSTREAM_MUTEX_UNLOCK();
|
||||
return;
|
||||
}
|
||||
// get current EOP timestamp
|
||||
@@ -168,7 +148,6 @@ kgsl_cmdstream_memqueue_drain(gsl_device_t *device)
|
||||
// check head timestamp
|
||||
if (!(((ts_processed - timestamp) >= 0) || ((ts_processed - timestamp) < -GSL_TIMESTAMP_EPSILON)))
|
||||
{
|
||||
GSL_CMDSTREAM_MUTEX_UNLOCK();
|
||||
return;
|
||||
}
|
||||
memnode = memqueue->head;
|
||||
@@ -203,7 +182,6 @@ kgsl_cmdstream_memqueue_drain(gsl_device_t *device)
|
||||
kfree(memnode);
|
||||
}
|
||||
|
||||
GSL_CMDSTREAM_MUTEX_UNLOCK();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -216,23 +194,20 @@ kgsl_cmdstream_freememontimestamp(gsl_deviceid_t device_id, gsl_memdesc_t *memde
|
||||
gsl_memqueue_t *memqueue;
|
||||
(void)type; // unref. For now just use EOP timestamp
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
GSL_CMDSTREAM_MUTEX_LOCK();
|
||||
|
||||
memqueue = &device->memqueue;
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
memqueue = &device->memqueue;
|
||||
memnode = kmalloc(sizeof(gsl_memnode_t), GFP_KERNEL);
|
||||
|
||||
if (!memnode)
|
||||
{
|
||||
// other solution is to idle and free which given that the upper level driver probably wont check, probably a better idea
|
||||
GSL_CMDSTREAM_MUTEX_UNLOCK();
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
memnode->timestamp = timestamp;
|
||||
memnode->pid = GSL_CALLER_PROCESSID_GET();
|
||||
memnode->pid = current->tgid;
|
||||
memnode->next = NULL;
|
||||
memcpy(&memnode->memdesc, memdesc, sizeof(gsl_memdesc_t));
|
||||
|
||||
@@ -244,13 +219,12 @@ kgsl_cmdstream_freememontimestamp(gsl_deviceid_t device_id, gsl_memdesc_t *memde
|
||||
}
|
||||
else
|
||||
{
|
||||
KOS_ASSERT(memqueue->head == NULL);
|
||||
DEBUG_ASSERT(memqueue->head == NULL);
|
||||
memqueue->head = memnode;
|
||||
memqueue->tail = memnode;
|
||||
}
|
||||
|
||||
GSL_CMDSTREAM_MUTEX_UNLOCK();
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -16,56 +16,31 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
|
||||
#ifdef GSL_BLD_G12
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
#define GSL_CMDWINDOW_TARGET_MASK 0x000000FF
|
||||
#define GSL_CMDWINDOW_ADDR_MASK 0x00FFFF00
|
||||
#define GSL_CMDWINDOW_TARGET_SHIFT 0
|
||||
#define GSL_CMDWINDOW_ADDR_SHIFT 8
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// macros
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
#define GSL_CMDWINDOW_MUTEX_CREATE() device->cmdwindow_mutex = kos_mutex_create("gsl_cmdwindow"); \
|
||||
if (!device->cmdwindow_mutex) return (GSL_FAILURE);
|
||||
#define GSL_CMDWINDOW_MUTEX_LOCK() kos_mutex_lock(device->cmdwindow_mutex)
|
||||
#define GSL_CMDWINDOW_MUTEX_UNLOCK() kos_mutex_unlock(device->cmdwindow_mutex)
|
||||
#define GSL_CMDWINDOW_MUTEX_FREE() kos_mutex_free(device->cmdwindow_mutex); device->cmdwindow_mutex = 0;
|
||||
#else
|
||||
#define GSL_CMDWINDOW_MUTEX_CREATE()
|
||||
#define GSL_CMDWINDOW_MUTEX_LOCK()
|
||||
#define GSL_CMDWINDOW_MUTEX_UNLOCK()
|
||||
#define GSL_CMDWINDOW_MUTEX_FREE()
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int
|
||||
kgsl_cmdwindow_init(gsl_device_t *device)
|
||||
{
|
||||
GSL_CMDWINDOW_MUTEX_CREATE();
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
int
|
||||
kgsl_cmdwindow_close(gsl_device_t *device)
|
||||
{
|
||||
GSL_CMDWINDOW_MUTEX_FREE();
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -119,11 +94,9 @@ kgsl_cmdwindow_write0(gsl_deviceid_t device_id, gsl_cmdwindow_t target, unsigned
|
||||
cmdwinaddr = ((target << GSL_CMDWINDOW_TARGET_SHIFT) & GSL_CMDWINDOW_TARGET_MASK);
|
||||
cmdwinaddr |= ((addr << GSL_CMDWINDOW_ADDR_SHIFT) & GSL_CMDWINDOW_ADDR_MASK);
|
||||
|
||||
GSL_CMDWINDOW_MUTEX_LOCK();
|
||||
|
||||
#ifndef GSL_NO_MMU
|
||||
// set mmu pagetable
|
||||
kgsl_mmu_setpagetable(device, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_mmu_setpagetable(device, current->tgid);
|
||||
#endif
|
||||
|
||||
// write command window address
|
||||
@@ -132,8 +105,6 @@ kgsl_cmdwindow_write0(gsl_deviceid_t device_id, gsl_cmdwindow_t target, unsigned
|
||||
// write data
|
||||
device->ftbl.device_regwrite(device, (cmdstream)>>2, data);
|
||||
|
||||
GSL_CMDWINDOW_MUTEX_UNLOCK();
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_COMMAND | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_cmdwindow_write. Return value %B\n", GSL_SUCCESS );
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
@@ -150,12 +121,12 @@ kgsl_cmdwindow_write0(gsl_deviceid_t device_id, gsl_cmdwindow_t target, unsigned
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_cmdwindow_write(gsl_deviceid_t device_id, gsl_cmdwindow_t target, unsigned int addr, unsigned int data)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
status = kgsl_cmdwindow_write0(device_id, target, addr, data);
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -18,19 +18,18 @@
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
#include "gsl_context.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_context_create(gsl_deviceid_t device_id, gsl_context_type_t type, unsigned int *drawctxt_id, gsl_flags_t flags)
|
||||
{
|
||||
gsl_device_t* device = &gsl_driver.device[device_id-1];
|
||||
int status;
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
if (device->ftbl.context_create)
|
||||
{
|
||||
@@ -41,20 +40,20 @@ kgsl_context_create(gsl_deviceid_t device_id, gsl_context_type_t type, unsigned
|
||||
status = GSL_FAILURE;
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_context_destroy(gsl_deviceid_t device_id, unsigned int drawctxt_id)
|
||||
{
|
||||
gsl_device_t* device = &gsl_driver.device[device_id-1];
|
||||
int status;
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
if (device->ftbl.context_destroy)
|
||||
{
|
||||
@@ -65,7 +64,7 @@ kgsl_context_destroy(gsl_deviceid_t device_id, unsigned int drawctxt_id)
|
||||
status = GSL_FAILURE;
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -868,14 +868,14 @@ static int kgsl_dumpx_handle_type3(unsigned int* hostaddr, int count)
|
||||
addr_stack[kgsl_dumpx_addr_count] = ibaddr;
|
||||
// just for sanity checking
|
||||
size_stack[kgsl_dumpx_addr_count++] = ibsize;
|
||||
KOS_ASSERT(kgsl_dumpx_addr_count < ADDRESS_STACK_SIZE);
|
||||
DEBUG_ASSERT(kgsl_dumpx_addr_count < ADDRESS_STACK_SIZE);
|
||||
|
||||
// recursively follow the indirect link and update swap if indirect buffer had resolve
|
||||
swap |= kgsl_dumpx_parse_ibs(ibaddr, ibsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
KOS_ASSERT(size_stack[i] == ibsize);
|
||||
DEBUG_ASSERT(size_stack[i] == ibsize);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -928,7 +928,7 @@ static int kgsl_dumpx_handle_type3(unsigned int* hostaddr, int count)
|
||||
if(iscopy && !swap)
|
||||
{
|
||||
// printf("resolve: %ix%i @ 0x%08x, format = 0x%08x\n", width, height, baseaddr, format);
|
||||
KOS_ASSERT(format < 15);
|
||||
DEBUG_ASSERT(format < 15);
|
||||
|
||||
// yes it was and we need to update color buffer config because this is the first bin
|
||||
// dumpx framebuffer base address, and dimensions
|
||||
@@ -963,8 +963,8 @@ int kgsl_dumpx_parse_ibs(gpuaddr_t gpuaddr, int sizedwords)
|
||||
|
||||
level++;
|
||||
|
||||
KOS_ASSERT(sizeof(unsigned int *) == sizeof(unsigned int));
|
||||
KOS_ASSERT(level <= 2);
|
||||
DEBUG_ASSERT(sizeof(unsigned int *) == sizeof(unsigned int));
|
||||
DEBUG_ASSERT(level <= 2);
|
||||
hostaddr = (unsigned int *)kgsl_sharedmem_convertaddr(gpuaddr, 0);
|
||||
|
||||
// dump the IB to test vector
|
||||
@@ -987,13 +987,13 @@ int kgsl_dumpx_parse_ibs(gpuaddr_t gpuaddr, int sizedwords)
|
||||
swap |= kgsl_dumpx_handle_type3(hostaddr, count);
|
||||
break; // type-3
|
||||
default:
|
||||
KOS_ASSERT(!"unknown packet type");
|
||||
DEBUG_ASSERT(!"unknown packet type");
|
||||
}
|
||||
|
||||
// jump to next packet
|
||||
dwords_left -= count;
|
||||
hostaddr += count;
|
||||
KOS_ASSERT(dwords_left >= 0 && "PM4 parsing error");
|
||||
DEBUG_ASSERT(dwords_left >= 0 && "PM4 parsing error");
|
||||
}
|
||||
|
||||
level--;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// inline functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_device_getfunctable(gsl_deviceid_t device_id, gsl_functable_t *ftbl)
|
||||
{
|
||||
switch (device_id)
|
||||
@@ -111,7 +111,7 @@ kgsl_device_init(gsl_device_t *device, gsl_deviceid_t device_id)
|
||||
KGSL_DEBUG(GSL_DBGFLAGS_DUMPX,
|
||||
{
|
||||
// dumpx needs this to be in EMEM0 aperture
|
||||
kgsl_sharedmem_free0(&device->memstore, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&device->memstore, current->tgid);
|
||||
status = kgsl_sharedmem_alloc0(device->id, GSL_MEMFLAGS_ALIGNPAGE, sizeof(gsl_devmemstore_t), &device->memstore);
|
||||
});
|
||||
|
||||
@@ -167,9 +167,9 @@ kgsl_device_close(gsl_device_t *device)
|
||||
kgsl_device_close is only called for last running caller process
|
||||
*/
|
||||
while (device->refcnt > 0) {
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
kgsl_device_stop(device->id);
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
}
|
||||
|
||||
// close cmdstream
|
||||
@@ -184,7 +184,7 @@ kgsl_device_close(gsl_device_t *device)
|
||||
if ((device->refcnt == 0) && device->memstore.hostptr
|
||||
&& !(gsl_driver.flags_debug & GSL_DBGFLAGS_DUMPX))
|
||||
{
|
||||
kgsl_sharedmem_free0(&device->memstore, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&device->memstore, current->tgid);
|
||||
}
|
||||
|
||||
wake_up_interruptible_all(&(device->timestamp_waitq));
|
||||
@@ -283,7 +283,7 @@ kgsl_device_detachcallback(gsl_device_t *device, unsigned int pid)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void *value, unsigned int sizebytes)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
@@ -292,7 +292,7 @@ kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_device_getproperty(gsl_deviceid_t device_id=%D, gsl_property_type_t type=%d, void *value=0x%08x, uint sizebytes=%u)\n", device_id, type, value, sizebytes );
|
||||
|
||||
KOS_ASSERT(value);
|
||||
DEBUG_ASSERT(value);
|
||||
|
||||
#ifndef _DEBUG
|
||||
(void) sizebytes; // unreferenced formal parameter
|
||||
@@ -304,7 +304,7 @@ kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
{
|
||||
gsl_shmemprop_t *shem = (gsl_shmemprop_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == sizeof(gsl_shmemprop_t));
|
||||
DEBUG_ASSERT(sizebytes == sizeof(gsl_shmemprop_t));
|
||||
|
||||
shem->numapertures = gsl_driver.shmem.numapertures;
|
||||
shem->aperture_mask = GSL_APERTURE_MASK;
|
||||
@@ -318,7 +318,7 @@ kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
int i;
|
||||
gsl_apertureprop_t *aperture = (gsl_apertureprop_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == (sizeof(gsl_apertureprop_t) * gsl_driver.shmem.numapertures));
|
||||
DEBUG_ASSERT(sizebytes == (sizeof(gsl_apertureprop_t) * gsl_driver.shmem.numapertures));
|
||||
|
||||
for (i = 0; i < gsl_driver.shmem.numapertures; i++)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
{
|
||||
gsl_shadowprop_t *shadowprop = (gsl_shadowprop_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == sizeof(gsl_shadowprop_t));
|
||||
DEBUG_ASSERT(sizebytes == sizeof(gsl_shadowprop_t));
|
||||
|
||||
memset(shadowprop, 0, sizeof(gsl_shadowprop_t));
|
||||
|
||||
@@ -376,7 +376,7 @@ kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_setproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void *value, unsigned int sizebytes)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
@@ -385,9 +385,9 @@ kgsl_device_setproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_device_setproperty(gsl_deviceid_t device_id=%D, gsl_property_type_t type=%d, void *value=0x%08x, uint sizebytes=%u)\n", device_id, type, value, sizebytes );
|
||||
|
||||
KOS_ASSERT(value);
|
||||
DEBUG_ASSERT(value);
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
device = &gsl_driver.device[device_id-1]; // device_id is 1 based
|
||||
|
||||
@@ -399,7 +399,7 @@ kgsl_device_setproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
}
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_setproperty. Return value %B\n", status );
|
||||
|
||||
@@ -408,7 +408,7 @@ kgsl_device_setproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
{
|
||||
int status = GSL_FAILURE_NOTINITIALIZED;
|
||||
@@ -418,15 +418,15 @@ kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_device_start(gsl_deviceid_t device_id=%D, gsl_flags_t flags=%d)\n", device_id, flags );
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
if ((GSL_DEVICE_G12 == device_id) && !(hal->has_z160)) {
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return GSL_FAILURE_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
if ((GSL_DEVICE_YAMATO == device_id) && !(hal->has_z430)) {
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return GSL_FAILURE_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
|
||||
if (!(device->flags & GSL_FLAGS_INITIALIZED))
|
||||
{
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_ERROR, "ERROR: Trying to start uninitialized device.\n" );
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_start. Return value %B\n", GSL_FAILURE );
|
||||
@@ -447,7 +447,7 @@ kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
|
||||
if (device->flags & GSL_FLAGS_STARTED)
|
||||
{
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_start. Return value %B\n", GSL_SUCCESS );
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
@@ -464,7 +464,7 @@ kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
status = device->ftbl.device_start(device, flags);
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_start. Return value %B\n", status );
|
||||
|
||||
@@ -473,7 +473,7 @@ kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_stop(gsl_deviceid_t device_id)
|
||||
{
|
||||
int status = GSL_FAILURE_NOTINITIALIZED;
|
||||
@@ -482,13 +482,13 @@ kgsl_device_stop(gsl_deviceid_t device_id)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_device_stop(gsl_deviceid_t device_id=%D)\n", device_id );
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
device = &gsl_driver.device[device_id-1]; // device_id is 1 based
|
||||
|
||||
if (device->flags & GSL_FLAGS_STARTED)
|
||||
{
|
||||
KOS_ASSERT(device->refcnt);
|
||||
DEBUG_ASSERT(device->refcnt);
|
||||
|
||||
device->refcnt--;
|
||||
|
||||
@@ -505,7 +505,7 @@ kgsl_device_stop(gsl_deviceid_t device_id)
|
||||
}
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_stop. Return value %B\n", status );
|
||||
|
||||
@@ -514,7 +514,7 @@ kgsl_device_stop(gsl_deviceid_t device_id)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_idle(gsl_deviceid_t device_id, unsigned int timeout)
|
||||
{
|
||||
int status = GSL_FAILURE_NOTINITIALIZED;
|
||||
@@ -523,7 +523,7 @@ kgsl_device_idle(gsl_deviceid_t device_id, unsigned int timeout)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_device_idle(gsl_deviceid_t device_id=%D, unsigned int timeout=%d)\n", device_id, timeout );
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
device = &gsl_driver.device[device_id-1]; // device_id is 1 based
|
||||
|
||||
@@ -534,7 +534,7 @@ kgsl_device_idle(gsl_deviceid_t device_id, unsigned int timeout)
|
||||
status = device->ftbl.device_idle(device, timeout);
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_idle. Return value %B\n", status );
|
||||
|
||||
@@ -543,7 +543,7 @@ kgsl_device_idle(gsl_deviceid_t device_id, unsigned int timeout)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_isidle(gsl_deviceid_t device_id)
|
||||
{
|
||||
gsl_timestamp_t retired = kgsl_cmdstream_readtimestamp0(device_id, GSL_TIMESTAMP_RETIRED);
|
||||
@@ -554,7 +554,7 @@ kgsl_device_isidle(gsl_deviceid_t device_id)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_regread(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned int *value)
|
||||
{
|
||||
int status = GSL_FAILURE_NOTINITIALIZED;
|
||||
@@ -567,19 +567,19 @@ kgsl_device_regread(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned
|
||||
"--> int kgsl_device_regread(gsl_deviceid_t device_id=%D, unsigned int offsetwords=%R, unsigned int *value=0x%08x)\n", device_id, offsetwords, value );
|
||||
#endif
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
device = &gsl_driver.device[device_id-1]; // device_id is 1 based
|
||||
|
||||
KOS_ASSERT(value);
|
||||
KOS_ASSERT(offsetwords < device->regspace.sizebytes);
|
||||
DEBUG_ASSERT(value);
|
||||
DEBUG_ASSERT(offsetwords < device->regspace.sizebytes);
|
||||
|
||||
if (device->ftbl.device_regread)
|
||||
{
|
||||
status = device->ftbl.device_regread(device, offsetwords, value);
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
#ifdef GSL_LOG
|
||||
if( offsetwords != mmRBBM_STATUS && offsetwords != mmCP_RB_RPTR )
|
||||
@@ -591,7 +591,7 @@ kgsl_device_regread(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_regwrite(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned int value)
|
||||
{
|
||||
int status = GSL_FAILURE_NOTINITIALIZED;
|
||||
@@ -600,18 +600,18 @@ kgsl_device_regwrite(gsl_deviceid_t device_id, unsigned int offsetwords, unsigne
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_device_regwrite(gsl_deviceid_t device_id=%D, unsigned int offsetwords=%R, uint value=0x%08x)\n", device_id, offsetwords, value );
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
device = &gsl_driver.device[device_id-1]; // device_id is 1 based
|
||||
|
||||
KOS_ASSERT(offsetwords < device->regspace.sizebytes);
|
||||
DEBUG_ASSERT(offsetwords < device->regspace.sizebytes);
|
||||
|
||||
if (device->ftbl.device_regwrite)
|
||||
{
|
||||
status = device->ftbl.device_regwrite(device, offsetwords, value);
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_regwrite. Return value %B\n", status );
|
||||
|
||||
@@ -620,7 +620,7 @@ kgsl_device_regwrite(gsl_deviceid_t device_id, unsigned int offsetwords, unsigne
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_device_waitirq(gsl_deviceid_t device_id, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout)
|
||||
{
|
||||
int status = GSL_FAILURE_NOTINITIALIZED;
|
||||
@@ -629,7 +629,7 @@ kgsl_device_waitirq(gsl_deviceid_t device_id, gsl_intrid_t intr_id, unsigned int
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_device_waitirq(gsl_deviceid_t device_id=%D, gsl_intrid_t intr_id=%d, unsigned int *count=0x%08x, unsigned int timout=0x%08x)\n", device_id, intr_id, count, timeout);
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
device = &gsl_driver.device[device_id-1]; // device_id is 1 based
|
||||
|
||||
@@ -638,7 +638,7 @@ kgsl_device_waitirq(gsl_deviceid_t device_id, gsl_intrid_t intr_id, unsigned int
|
||||
status = device->ftbl.device_waitirq(device, intr_id, count, timeout);
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DEVICE | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_device_waitirq. Return value %B\n", status );
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/sched.h>
|
||||
#include <asm/div64.h>
|
||||
|
||||
#include "gsl.h"
|
||||
@@ -109,23 +110,6 @@
|
||||
#define CONTEXT_SIZE (SHADER_OFFSET + 3 * SHADER_SHADOW_SIZE)
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// macros
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
#define GSL_CONTEXT_MUTEX_CREATE() device->drawctxt_mutex = kos_mutex_create("gsl_drawctxt"); \
|
||||
if (!device->drawctxt_mutex) {return (GSL_FAILURE);}
|
||||
#define GSL_CONTEXT_MUTEX_LOCK() kos_mutex_lock(device->drawctxt_mutex)
|
||||
#define GSL_CONTEXT_MUTEX_UNLOCK() kos_mutex_unlock(device->drawctxt_mutex)
|
||||
#define GSL_CONTEXT_MUTEX_FREE() kos_mutex_free(device->drawctxt_mutex); device->drawctxt_mutex = 0;
|
||||
#else
|
||||
#define GSL_CONTEXT_MUTEX_CREATE()
|
||||
#define GSL_CONTEXT_MUTEX_LOCK()
|
||||
#define GSL_CONTEXT_MUTEX_UNLOCK()
|
||||
#define GSL_CONTEXT_MUTEX_FREE()
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// temporary work structure
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -726,7 +710,7 @@ build_gmem2sys_cmds(gsl_drawctxt_t *drawctxt, ctx_t* ctx, gmem_shadow_t *shadow)
|
||||
// RB_COLOR_INFO Endian=none, Linear, Format=RGBA8888, Swap=0, Base=gmem_base
|
||||
if( ctx )
|
||||
{
|
||||
KOS_ASSERT((ctx->gmem_base & 0xFFF) == 0); // gmem base assumed 4K aligned.
|
||||
DEBUG_ASSERT((ctx->gmem_base & 0xFFF) == 0); // gmem base assumed 4K aligned.
|
||||
*cmds++ = (shadow->format << RB_COLOR_INFO__COLOR_FORMAT__SHIFT) | ctx->gmem_base;
|
||||
}
|
||||
else
|
||||
@@ -779,7 +763,7 @@ build_gmem2sys_cmds(gsl_drawctxt_t *drawctxt, ctx_t* ctx, gmem_shadow_t *shadow)
|
||||
*cmds++ = shadow->pitch >> 5; // RB_COPY_DEST_PITCH
|
||||
*cmds++ = 0x0003c008 | (shadow->format << RB_COPY_DEST_INFO__COPY_DEST_FORMAT__SHIFT); // Endian=none, Linear, Format=RGBA8888,Swap=0,!Dither,MaskWrite:R=G=B=A=1
|
||||
|
||||
KOS_ASSERT( (offset & 0xfffff000) == 0 ); // Make sure we stay in offsetx field.
|
||||
DEBUG_ASSERT( (offset & 0xfffff000) == 0 ); // Make sure we stay in offsetx field.
|
||||
*cmds++ = offset;
|
||||
}
|
||||
|
||||
@@ -1391,8 +1375,6 @@ create_gmem_shadow(gsl_device_t *device, gsl_drawctxt_t *drawctxt, ctx_t *ctx)
|
||||
int
|
||||
kgsl_drawctxt_init(gsl_device_t *device)
|
||||
{
|
||||
GSL_CONTEXT_MUTEX_CREATE();
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1404,8 +1386,6 @@ kgsl_drawctxt_init(gsl_device_t *device)
|
||||
int
|
||||
kgsl_drawctxt_close(gsl_device_t *device)
|
||||
{
|
||||
GSL_CONTEXT_MUTEX_FREE();
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1422,11 +1402,9 @@ kgsl_drawctxt_create(gsl_device_t* device, gsl_context_type_t type, unsigned int
|
||||
ctx_t ctx;
|
||||
|
||||
kgsl_device_active(device);
|
||||
|
||||
GSL_CONTEXT_MUTEX_LOCK();
|
||||
|
||||
if (device->drawctxt_count >= GSL_CONTEXT_MAX)
|
||||
{
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
@@ -1442,15 +1420,14 @@ kgsl_drawctxt_create(gsl_device_t* device, gsl_context_type_t type, unsigned int
|
||||
|
||||
if (index >= GSL_CONTEXT_MAX)
|
||||
{
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
return (GSL_FAILURE);
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
drawctxt = &device->drawctxt[index];
|
||||
|
||||
memset( &drawctxt->context_gmem_shadow, 0, sizeof( gmem_shadow_t ) );
|
||||
|
||||
drawctxt->pid = GSL_CALLER_PROCESSID_GET();
|
||||
drawctxt->pid = current->tgid;
|
||||
drawctxt->flags = CTXT_FLAGS_IN_USE;
|
||||
drawctxt->type = type;
|
||||
|
||||
@@ -1462,7 +1439,7 @@ kgsl_drawctxt_create(gsl_device_t* device, gsl_context_type_t type, unsigned int
|
||||
if (create_gpustate_shadow(device, drawctxt, &ctx) != GSL_SUCCESS)
|
||||
{
|
||||
kgsl_drawctxt_destroy(device, index);
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
@@ -1476,16 +1453,15 @@ kgsl_drawctxt_create(gsl_device_t* device, gsl_context_type_t type, unsigned int
|
||||
if (create_gmem_shadow(device, drawctxt, &ctx) != GSL_SUCCESS)
|
||||
{
|
||||
kgsl_drawctxt_destroy(device, index);
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
KOS_ASSERT(ctx.cmd - ctx.start <= CMD_BUFFER_LEN);
|
||||
DEBUG_ASSERT(ctx.cmd - ctx.start <= CMD_BUFFER_LEN);
|
||||
}
|
||||
|
||||
*drawctxt_id = index;
|
||||
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1499,8 +1475,6 @@ kgsl_drawctxt_destroy(gsl_device_t* device, unsigned int drawctxt_id)
|
||||
{
|
||||
gsl_drawctxt_t *drawctxt;
|
||||
|
||||
GSL_CONTEXT_MUTEX_LOCK();
|
||||
|
||||
drawctxt = &device->drawctxt[drawctxt_id];
|
||||
|
||||
if (drawctxt->flags != CTXT_FLAGS_NOT_IN_USE)
|
||||
@@ -1518,13 +1492,13 @@ kgsl_drawctxt_destroy(gsl_device_t* device, unsigned int drawctxt_id)
|
||||
|
||||
// destroy state shadow, if allocated
|
||||
if (drawctxt->flags & CTXT_FLAGS_STATE_SHADOW)
|
||||
kgsl_sharedmem_free0(&drawctxt->gpustate, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&drawctxt->gpustate, current->tgid);
|
||||
|
||||
|
||||
// destroy gmem shadow, if allocated
|
||||
if (drawctxt->context_gmem_shadow.gmemshadow.size > 0)
|
||||
{
|
||||
kgsl_sharedmem_free0(&drawctxt->context_gmem_shadow.gmemshadow, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&drawctxt->context_gmem_shadow.gmemshadow, current->tgid);
|
||||
drawctxt->context_gmem_shadow.gmemshadow.size = 0;
|
||||
}
|
||||
|
||||
@@ -1532,11 +1506,9 @@ kgsl_drawctxt_destroy(gsl_device_t* device, unsigned int drawctxt_id)
|
||||
drawctxt->pid = 0;
|
||||
|
||||
device->drawctxt_count--;
|
||||
KOS_ASSERT(device->drawctxt_count >= 0);
|
||||
DEBUG_ASSERT(device->drawctxt_count >= 0);
|
||||
}
|
||||
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -1562,15 +1534,14 @@ kgsl_drawctxt_destroy(gsl_device_t* device, unsigned int drawctxt_id)
|
||||
//
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API int kgsl_drawctxt_bind_gmem_shadow(gsl_deviceid_t device_id, unsigned int drawctxt_id, const gsl_rect_t* gmem_rect, unsigned int shadow_x, unsigned int shadow_y, const gsl_buffer_desc_t* shadow_buffer, unsigned int buffer_id)
|
||||
int kgsl_drawctxt_bind_gmem_shadow(gsl_deviceid_t device_id, unsigned int drawctxt_id, const gsl_rect_t* gmem_rect, unsigned int shadow_x, unsigned int shadow_y, const gsl_buffer_desc_t* shadow_buffer, unsigned int buffer_id)
|
||||
{
|
||||
gsl_device_t *device = &gsl_driver.device[device_id-1];
|
||||
gsl_drawctxt_t *drawctxt = &device->drawctxt[drawctxt_id];
|
||||
gmem_shadow_t *shadow = &drawctxt->user_gmem_shadow[buffer_id];
|
||||
unsigned int i;
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
GSL_CONTEXT_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
if( !shadow_buffer->enabled )
|
||||
{
|
||||
@@ -1580,20 +1551,20 @@ KGSL_API int kgsl_drawctxt_bind_gmem_shadow(gsl_deviceid_t device_id, unsigned i
|
||||
else
|
||||
{
|
||||
// Sanity checks
|
||||
KOS_ASSERT((gmem_rect->x % 2) == 0); // Needs to be a multiple of 2
|
||||
KOS_ASSERT((gmem_rect->y % 2) == 0); // Needs to be a multiple of 2
|
||||
KOS_ASSERT((gmem_rect->width % 2) == 0); // Needs to be a multiple of 2
|
||||
KOS_ASSERT((gmem_rect->height % 2) == 0); // Needs to be a multiple of 2
|
||||
KOS_ASSERT((gmem_rect->pitch % 32) == 0); // Needs to be a multiple of 32
|
||||
DEBUG_ASSERT((gmem_rect->x % 2) == 0); // Needs to be a multiple of 2
|
||||
DEBUG_ASSERT((gmem_rect->y % 2) == 0); // Needs to be a multiple of 2
|
||||
DEBUG_ASSERT((gmem_rect->width % 2) == 0); // Needs to be a multiple of 2
|
||||
DEBUG_ASSERT((gmem_rect->height % 2) == 0); // Needs to be a multiple of 2
|
||||
DEBUG_ASSERT((gmem_rect->pitch % 32) == 0); // Needs to be a multiple of 32
|
||||
|
||||
KOS_ASSERT((shadow_x % 2) == 0); // Needs to be a multiple of 2
|
||||
KOS_ASSERT((shadow_y % 2) == 0); // Needs to be a multiple of 2
|
||||
DEBUG_ASSERT((shadow_x % 2) == 0); // Needs to be a multiple of 2
|
||||
DEBUG_ASSERT((shadow_y % 2) == 0); // Needs to be a multiple of 2
|
||||
|
||||
KOS_ASSERT(shadow_buffer->format >= COLORX_4_4_4_4);
|
||||
KOS_ASSERT(shadow_buffer->format <= COLORX_32_32_32_32_FLOAT);
|
||||
KOS_ASSERT((shadow_buffer->pitch % 32) == 0); // Needs to be a multiple of 32
|
||||
KOS_ASSERT(buffer_id >= 0);
|
||||
KOS_ASSERT(buffer_id < GSL_MAX_GMEM_SHADOW_BUFFERS);
|
||||
DEBUG_ASSERT(shadow_buffer->format >= COLORX_4_4_4_4);
|
||||
DEBUG_ASSERT(shadow_buffer->format <= COLORX_32_32_32_32_FLOAT);
|
||||
DEBUG_ASSERT((shadow_buffer->pitch % 32) == 0); // Needs to be a multiple of 32
|
||||
DEBUG_ASSERT(buffer_id >= 0);
|
||||
DEBUG_ASSERT(buffer_id < GSL_MAX_GMEM_SHADOW_BUFFERS);
|
||||
|
||||
// Set up GMEM shadow regions
|
||||
memcpy( &shadow->gmemshadow, &shadow_buffer->data, sizeof( gsl_memdesc_t ) );
|
||||
@@ -1626,7 +1597,7 @@ KGSL_API int kgsl_drawctxt_bind_gmem_shadow(gsl_deviceid_t device_id, unsigned i
|
||||
// Release context GMEM shadow if found
|
||||
if (drawctxt->context_gmem_shadow.gmemshadow.size > 0)
|
||||
{
|
||||
kgsl_sharedmem_free0(&drawctxt->context_gmem_shadow.gmemshadow, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&drawctxt->context_gmem_shadow.gmemshadow, current->tgid);
|
||||
drawctxt->context_gmem_shadow.gmemshadow.size = 0;
|
||||
}
|
||||
}
|
||||
@@ -1641,8 +1612,7 @@ KGSL_API int kgsl_drawctxt_bind_gmem_shadow(gsl_deviceid_t device_id, unsigned i
|
||||
}
|
||||
}
|
||||
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
@@ -1779,8 +1749,6 @@ kgsl_drawctxt_destroyall(gsl_device_t *device)
|
||||
int i;
|
||||
gsl_drawctxt_t *drawctxt;
|
||||
|
||||
GSL_CONTEXT_MUTEX_LOCK();
|
||||
|
||||
for (i = 0; i < GSL_CONTEXT_MAX; i++)
|
||||
{
|
||||
drawctxt = &device->drawctxt[i];
|
||||
@@ -1789,24 +1757,22 @@ kgsl_drawctxt_destroyall(gsl_device_t *device)
|
||||
{
|
||||
// destroy state shadow, if allocated
|
||||
if (drawctxt->flags & CTXT_FLAGS_STATE_SHADOW)
|
||||
kgsl_sharedmem_free0(&drawctxt->gpustate, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&drawctxt->gpustate, current->tgid);
|
||||
|
||||
// destroy gmem shadow, if allocated
|
||||
if (drawctxt->context_gmem_shadow.gmemshadow.size > 0)
|
||||
{
|
||||
kgsl_sharedmem_free0(&drawctxt->context_gmem_shadow.gmemshadow, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&drawctxt->context_gmem_shadow.gmemshadow, current->tgid);
|
||||
drawctxt->context_gmem_shadow.gmemshadow.size = 0;
|
||||
}
|
||||
|
||||
drawctxt->flags = CTXT_FLAGS_NOT_IN_USE;
|
||||
|
||||
device->drawctxt_count--;
|
||||
KOS_ASSERT(device->drawctxt_count >= 0);
|
||||
DEBUG_ASSERT(device->drawctxt_count >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
GSL_CONTEXT_MUTEX_UNLOCK();
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
|
||||
@@ -57,8 +59,7 @@ kgsl_driver_init0(gsl_flags_t flags, gsl_flags_t flags_debug)
|
||||
| KGSL_LOG_THREAD_ID | KGSL_LOG_PROCESS_ID );
|
||||
#endif
|
||||
memset(&gsl_driver, 0, sizeof(gsl_driver_t));
|
||||
|
||||
GSL_API_MUTEX_CREATE();
|
||||
mutex_init(&gsl_driver.lock);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
@@ -79,7 +80,7 @@ kgsl_driver_init0(gsl_flags_t flags, gsl_flags_t flags_debug)
|
||||
|
||||
if (!(gsl_driver_initialized & GSL_FLAGS_INITIALIZED0))
|
||||
{
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
// init hal
|
||||
status = kgsl_hal_init();
|
||||
@@ -90,7 +91,7 @@ kgsl_driver_init0(gsl_flags_t flags, gsl_flags_t flags_debug)
|
||||
gsl_driver_initialized |= GSL_FLAGS_INITIALIZED0;
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
}
|
||||
|
||||
return (status);
|
||||
@@ -105,14 +106,10 @@ kgsl_driver_close0(gsl_flags_t flags)
|
||||
|
||||
if ((gsl_driver_initialized & GSL_FLAGS_INITIALIZED0) && (gsl_driver_initialized & flags))
|
||||
{
|
||||
GSL_API_MUTEX_LOCK();
|
||||
|
||||
// close hall
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
// close hal
|
||||
status = kgsl_hal_close();
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
|
||||
GSL_API_MUTEX_FREE();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
#ifdef GSL_LOG
|
||||
kgsl_log_finish();
|
||||
@@ -134,7 +131,7 @@ kgsl_driver_close0(gsl_flags_t flags)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_driver_init()
|
||||
{
|
||||
// only an external (platform specific device driver) component should call this
|
||||
@@ -144,7 +141,7 @@ kgsl_driver_init()
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_driver_close()
|
||||
{
|
||||
// only an external (platform specific device driver) component should call this
|
||||
@@ -154,7 +151,7 @@ kgsl_driver_close()
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_driver_entry(gsl_flags_t flags)
|
||||
{
|
||||
int status = GSL_FAILURE;
|
||||
@@ -168,9 +165,9 @@ kgsl_driver_entry(gsl_flags_t flags)
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DRIVER | KGSL_LOG_LEVEL_TRACE, "--> int kgsl_driver_entry( gsl_flags_t flags=%d )\n", flags );
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
pid = GSL_CALLER_PROCESSID_GET();
|
||||
pid = current->tgid;
|
||||
|
||||
// if caller process has not already opened access
|
||||
status = kgsl_driver_getcallerprocessindex(pid, &index);
|
||||
@@ -234,7 +231,7 @@ kgsl_driver_entry(gsl_flags_t flags)
|
||||
}
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DRIVER | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_driver_entry. Return value: %B\n", status );
|
||||
|
||||
@@ -249,7 +246,7 @@ kgsl_driver_exit0(unsigned int pid)
|
||||
int status = GSL_SUCCESS;
|
||||
int index, i;
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
if (gsl_driver_initialized & GSL_FLAGS_INITIALIZED)
|
||||
{
|
||||
@@ -290,7 +287,7 @@ kgsl_driver_exit0(unsigned int pid)
|
||||
}
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
if (!(gsl_driver_initialized & GSL_FLAGS_INITIALIZED))
|
||||
{
|
||||
@@ -302,14 +299,14 @@ kgsl_driver_exit0(unsigned int pid)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_driver_exit(void)
|
||||
{
|
||||
int status;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DRIVER | KGSL_LOG_LEVEL_TRACE, "--> int kgsl_driver_exit()\n" );
|
||||
|
||||
status = kgsl_driver_exit0(GSL_CALLER_PROCESSID_GET());
|
||||
status = kgsl_driver_exit0(current->tgid);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_DRIVER | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_driver_exit(). Return value: %B\n", status );
|
||||
|
||||
@@ -318,7 +315,7 @@ kgsl_driver_exit(void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_driver_destroy(unsigned int pid)
|
||||
{
|
||||
return (kgsl_driver_exit0(pid));
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
#include "kos_libapi.h"
|
||||
#include "gsl_cmdstream.h"
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
#include "gsl_cmdstream.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_MX35
|
||||
#define V3_SYNC
|
||||
#endif
|
||||
@@ -127,7 +126,7 @@ kgsl_g12_intrcallback(gsl_intrid_t id, void *cookie)
|
||||
#ifndef _Z180
|
||||
case GSL_INTR_G12_FBC:
|
||||
// signal intr completion event
|
||||
kos_event_signal(device->intr.evnt[id]);
|
||||
complete_all(&device->intr.evnt[id]);
|
||||
break;
|
||||
#endif //_Z180
|
||||
|
||||
@@ -296,7 +295,7 @@ kgsl_g12_init(gsl_device_t *device)
|
||||
|
||||
#ifdef IRQTHREAD_POLL
|
||||
// Create event to trigger IRQ polling thread
|
||||
device->irqthread_event = kos_event_create(0);
|
||||
init_completion(&device->irqthread_event);
|
||||
#endif
|
||||
|
||||
// enable interrupts
|
||||
@@ -331,7 +330,7 @@ kgsl_g12_close(gsl_device_t *device)
|
||||
// empty irq counters. Otherwise there's a possibility to have them in
|
||||
// registers next time systems starts up and this results in a hang.
|
||||
status = device->ftbl.device_idle(device, 1000);
|
||||
KOS_ASSERT(status == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(status == GSL_SUCCESS);
|
||||
|
||||
destroy_workqueue(device->irq_workq);
|
||||
|
||||
@@ -359,7 +358,7 @@ kgsl_g12_close(gsl_device_t *device)
|
||||
|
||||
drawctx_id = 0;
|
||||
|
||||
KOS_ASSERT(g_z1xx.numcontext == 0);
|
||||
DEBUG_ASSERT(g_z1xx.numcontext == 0);
|
||||
}
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
@@ -375,7 +374,7 @@ kgsl_g12_destroy(gsl_device_t *device)
|
||||
|
||||
#ifdef _DEBUG
|
||||
// for now, signal catastrophic failure in a brute force way
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
#endif // _DEBUG
|
||||
|
||||
//todo: hard reset core?
|
||||
@@ -414,7 +413,7 @@ kgsl_g12_start(gsl_device_t *device, gsl_flags_t flags)
|
||||
return (status);
|
||||
}
|
||||
|
||||
KOS_ASSERT(g_z1xx.numcontext == 0);
|
||||
DEBUG_ASSERT(g_z1xx.numcontext == 0);
|
||||
|
||||
device->flags |= GSL_FLAGS_STARTED;
|
||||
|
||||
@@ -428,11 +427,11 @@ kgsl_g12_stop(gsl_device_t *device)
|
||||
{
|
||||
int status;
|
||||
|
||||
KOS_ASSERT(device->refcnt == 0);
|
||||
DEBUG_ASSERT(device->refcnt == 0);
|
||||
|
||||
/* wait for device to idle before setting it's clock off */
|
||||
status = device->ftbl.device_idle(device, 1000);
|
||||
KOS_ASSERT(status == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(status == GSL_SUCCESS);
|
||||
|
||||
status = kgsl_hal_setpowerstate(device->id, GSL_PWRFLAGS_CLK_OFF, 0);
|
||||
device->flags &= ~GSL_FLAGS_STARTED;
|
||||
@@ -453,7 +452,7 @@ kgsl_g12_getproperty(gsl_device_t *device, gsl_property_type_t type, void *value
|
||||
{
|
||||
gsl_devinfo_t *devinfo = (gsl_devinfo_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == sizeof(gsl_devinfo_t));
|
||||
DEBUG_ASSERT(sizebytes == sizeof(gsl_devinfo_t));
|
||||
|
||||
devinfo->device_id = device->id;
|
||||
devinfo->chip_id = (gsl_chipid_t)device->chip_id;
|
||||
@@ -485,7 +484,7 @@ kgsl_g12_setproperty(gsl_device_t *device, gsl_property_type_t type, void *value
|
||||
{
|
||||
gsl_powerprop_t *power = (gsl_powerprop_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == sizeof(gsl_powerprop_t));
|
||||
DEBUG_ASSERT(sizebytes == sizeof(gsl_powerprop_t));
|
||||
|
||||
if (!(device->flags & GSL_FLAGS_SAFEMODE))
|
||||
{
|
||||
@@ -573,9 +572,7 @@ int
|
||||
kgsl_g12_waitirq(gsl_device_t *device, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout)
|
||||
{
|
||||
int status = GSL_FAILURE_NOTSUPPORTED;
|
||||
#ifdef VG_HDK
|
||||
(void)timeout;
|
||||
#endif
|
||||
int complete = 0;
|
||||
|
||||
#ifndef _Z180
|
||||
if (intr_id == GSL_INTR_G12_G2D || intr_id == GSL_INTR_G12_FBC)
|
||||
@@ -583,27 +580,28 @@ kgsl_g12_waitirq(gsl_device_t *device, gsl_intrid_t intr_id, unsigned int *count
|
||||
if (intr_id == GSL_INTR_G12_G2D)
|
||||
#endif //_Z180
|
||||
{
|
||||
#ifndef VG_HDK
|
||||
if (kgsl_intr_isenabled(&device->intr, intr_id) == GSL_SUCCESS)
|
||||
#endif
|
||||
{
|
||||
// wait until intr completion event is received and check that
|
||||
// the interrupt is still enabled. If event is received, but
|
||||
// interrupt is not enabled any more, the driver is shutting
|
||||
// down and event structure is not valid anymore.
|
||||
#ifndef VG_HDK
|
||||
if (kos_event_wait(device->intr.evnt[intr_id], timeout) == OS_SUCCESS && kgsl_intr_isenabled(&device->intr, intr_id) == GSL_SUCCESS)
|
||||
#endif
|
||||
|
||||
if (timeout != OS_INFINITE)
|
||||
complete = wait_for_completion_timeout(&device->intr.evnt[intr_id], msecs_to_jiffies(timeout));
|
||||
else
|
||||
complete = wait_for_completion_killable(&device->intr.evnt[intr_id]);
|
||||
|
||||
if (complete && kgsl_intr_isenabled(&device->intr, intr_id) == GSL_SUCCESS)
|
||||
{
|
||||
unsigned int cntrs;
|
||||
int i;
|
||||
struct completion *comp = &device->intr.evnt[intr_id];
|
||||
|
||||
kgsl_device_active(device);
|
||||
#ifndef VG_HDK
|
||||
kos_event_reset(device->intr.evnt[intr_id]);
|
||||
|
||||
INIT_COMPLETION(*comp);
|
||||
device->ftbl.device_regread(device, (ADDR_VGC_IRQ_ACTIVE_CNT >> 2), &cntrs);
|
||||
#else
|
||||
device->ftbl.device_regread(device, (0x38 >> 2), &cntrs);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < GSL_G12_INTR_COUNT; i++)
|
||||
{
|
||||
@@ -620,19 +618,17 @@ kgsl_g12_waitirq(gsl_device_t *device, gsl_intrid_t intr_id, unsigned int *count
|
||||
device->intrcnt[intr_id - GSL_INTR_G12_MH] = 0;
|
||||
status = GSL_SUCCESS;
|
||||
}
|
||||
#ifndef VG_HDK
|
||||
else
|
||||
{
|
||||
status = GSL_FAILURE_TIMEOUT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if(intr_id == GSL_INTR_FOOBAR)
|
||||
{
|
||||
if (kgsl_intr_isenabled(&device->intr, GSL_INTR_G12_G2D) == GSL_SUCCESS)
|
||||
{
|
||||
kos_event_signal(device->intr.evnt[GSL_INTR_G12_G2D]);
|
||||
complete_all(&device->intr.evnt[GSL_INTR_G12_G2D]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -684,7 +680,7 @@ kgsl_g12_getfunctable(gsl_functable_t *ftbl)
|
||||
|
||||
static void addmarker(gsl_z1xx_t* z1xx)
|
||||
{
|
||||
KOS_ASSERT(z1xx);
|
||||
DEBUG_ASSERT(z1xx);
|
||||
{
|
||||
unsigned int *p = z1xx->cmdbuf[z1xx->curr];
|
||||
/* todo: use symbolic values */
|
||||
@@ -810,16 +806,16 @@ kgsl_g12_context_create(gsl_device_t* device, gsl_context_type_t type, unsigned
|
||||
for (i=0;i<GSL_HAL_NUMCMDBUFFERS;i++)
|
||||
{
|
||||
status = kgsl_sharedmem_alloc0(GSL_DEVICE_ANY, gslflags, GSL_HAL_CMDBUFFERSIZE, &g_z1xx.cmdbufdesc[i]);
|
||||
KOS_ASSERT(status == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(status == GSL_SUCCESS);
|
||||
g_z1xx.cmdbuf[i]=kmalloc(GSL_HAL_CMDBUFFERSIZE, GFP_KERNEL);
|
||||
KOS_ASSERT(g_z1xx.cmdbuf[i]);
|
||||
DEBUG_ASSERT(g_z1xx.cmdbuf[i]);
|
||||
memset((void*)g_z1xx.cmdbuf[i], 0, GSL_HAL_CMDBUFFERSIZE);
|
||||
|
||||
g_z1xx.curr = i;
|
||||
g_z1xx.offs = 0;
|
||||
addmarker(&g_z1xx);
|
||||
status = kgsl_sharedmem_write0(&g_z1xx.cmdbufdesc[i],0, g_z1xx.cmdbuf[i], (512 + 13) * sizeof(unsigned int), false);
|
||||
KOS_ASSERT(status == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(status == GSL_SUCCESS);
|
||||
}
|
||||
g_z1xx.curr = 0;
|
||||
cmd = (int)(((VGV3_NEXTCMD_JUMP) & VGV3_NEXTCMD_NEXTCMD_FMASK)<< VGV3_NEXTCMD_NEXTCMD_FSHIFT);
|
||||
@@ -829,7 +825,7 @@ kgsl_g12_context_create(gsl_device_t* device, gsl_context_type_t type, unsigned
|
||||
status |= kgsl_cmdwindow_write0(GSL_DEVICE_G12, GSL_CMDWINDOW_2D, ADDR_VGV3_NEXTADDR, g_z1xx.cmdbufdesc[0].gpuaddr );
|
||||
status |= kgsl_cmdwindow_write0(GSL_DEVICE_G12, GSL_CMDWINDOW_2D, ADDR_VGV3_NEXTCMD, cmd | 5);
|
||||
|
||||
KOS_ASSERT(status == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(status == GSL_SUCCESS);
|
||||
|
||||
/* Edge buffer setup todo: move register setup to own function.
|
||||
This function can be then called, if power managemnet is used and clocks are turned off and then on.
|
||||
@@ -846,7 +842,7 @@ kgsl_g12_context_create(gsl_device_t* device, gsl_context_type_t type, unsigned
|
||||
kgsl_sharedmem_set0(&g_z1xx.e2, 0, 0, GSL_HAL_EDGE2BUFSIZE);
|
||||
kgsl_cmdwindow_write0(GSL_DEVICE_G12, GSL_CMDWINDOW_2D, GSL_HAL_EDGE2REG, g_z1xx.e2.gpuaddr);
|
||||
#endif
|
||||
KOS_ASSERT(status == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(status == GSL_SUCCESS);
|
||||
}
|
||||
|
||||
if(g_z1xx.numcontext < GSL_CONTEXT_MAX)
|
||||
@@ -886,13 +882,13 @@ kgsl_g12_context_destroy(gsl_device_t* device, unsigned int drawctxt_id)
|
||||
int i;
|
||||
for (i=0;i<GSL_HAL_NUMCMDBUFFERS;i++)
|
||||
{
|
||||
kgsl_sharedmem_free0(&g_z1xx.cmdbufdesc[i], GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&g_z1xx.cmdbufdesc[i], current->tgid);
|
||||
kfree(g_z1xx.cmdbuf[i]);
|
||||
}
|
||||
kgsl_sharedmem_free0(&g_z1xx.e0, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&g_z1xx.e1, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&g_z1xx.e0, current->tgid);
|
||||
kgsl_sharedmem_free0(&g_z1xx.e1, current->tgid);
|
||||
#ifdef _Z180
|
||||
kgsl_sharedmem_free0(&g_z1xx.e2, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&g_z1xx.e2, current->tgid);
|
||||
#endif
|
||||
memset(&g_z1xx,0,sizeof(gsl_z1xx_t));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include "gsl.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -84,7 +86,7 @@ kgsl_intr_decode(gsl_device_t *device, gsl_intrblock_t block_id)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API void
|
||||
void
|
||||
kgsl_intr_isr(gsl_device_t *device)
|
||||
{
|
||||
if (device->intr.flags & GSL_FLAGS_INITIALIZED) {
|
||||
@@ -178,7 +180,7 @@ int kgsl_intr_enable(gsl_intr_t *intr, gsl_intrid_t id)
|
||||
|
||||
if (mask && !(enabled & mask))
|
||||
{
|
||||
intr->evnt[id] = kos_event_create(0);
|
||||
init_completion(&intr->evnt[id]);
|
||||
|
||||
enabled |= mask;
|
||||
intr->enabled[block->id] = enabled;
|
||||
@@ -201,13 +203,13 @@ int kgsl_intr_disable(gsl_intr_t *intr, gsl_intrid_t id)
|
||||
return (GSL_FAILURE_BADPARAM);
|
||||
}
|
||||
|
||||
if (intr->handler[id].callback == NULL)
|
||||
if (intr->handler[id].callback == NULL)
|
||||
{
|
||||
return (GSL_FAILURE_NOTINITIALIZED);
|
||||
}
|
||||
|
||||
block = kgsl_intr_id2block(id);
|
||||
if (block == NULL)
|
||||
if (block == NULL)
|
||||
{
|
||||
return (GSL_FAILURE_SYSTEMERROR);
|
||||
}
|
||||
@@ -215,15 +217,13 @@ int kgsl_intr_disable(gsl_intr_t *intr, gsl_intrid_t id)
|
||||
mask = gsl_cfg_intr_mask[id];
|
||||
enabled = intr->enabled[block->id];
|
||||
|
||||
if (enabled & mask)
|
||||
if (enabled & mask)
|
||||
{
|
||||
enabled &= ~mask;
|
||||
intr->enabled[block->id] = enabled;
|
||||
intr->device->ftbl.device_regwrite(intr->device, block->mask_reg, enabled);
|
||||
|
||||
kos_event_signal(intr->evnt[id]); // wake up waiting threads before destroying the event
|
||||
kos_event_destroy(intr->evnt[id]);
|
||||
intr->evnt[id] = 0;
|
||||
complete_all(&intr->evnt[id]); // wake up waiting threads before destroying the event
|
||||
}
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
|
||||
@@ -22,13 +22,10 @@
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include "gsl.h"
|
||||
|
||||
#define KGSL_OUTPUT_TYPE_MEMBUF 0
|
||||
#define KGSL_OUTPUT_TYPE_STDOUT 1
|
||||
#define KGSL_OUTPUT_TYPE_FILE 2
|
||||
|
||||
#define REG_OUTPUT( X ) case X: b += sprintf( b, "%s", #X ); break;
|
||||
#define INTRID_OUTPUT( X ) case X: b += sprintf( b, "%s", #X ); break;
|
||||
|
||||
@@ -40,7 +37,7 @@ typedef struct log_output
|
||||
|
||||
static log_output_t* outputs = NULL;
|
||||
|
||||
static oshandle_t log_mutex = NULL;
|
||||
static struct mutex log_mutex;
|
||||
static char buffer[256];
|
||||
static char buffer2[256];
|
||||
static int log_initialized = 0;
|
||||
@@ -53,7 +50,7 @@ int kgsl_log_start( unsigned int log_flags )
|
||||
|
||||
if( log_initialized ) return GSL_SUCCESS;
|
||||
|
||||
log_mutex = kos_mutex_create( "log_mutex" );
|
||||
mutex_init(&log_mutex);
|
||||
log_initialized = 1;
|
||||
|
||||
output = kmalloc( sizeof( log_output_t ), GFP_KERNEL );
|
||||
@@ -91,8 +88,6 @@ int kgsl_log_finish()
|
||||
outputs = temp;
|
||||
}
|
||||
|
||||
kos_mutex_free( log_mutex );
|
||||
|
||||
log_initialized = 0;
|
||||
|
||||
return GSL_SUCCESS;
|
||||
@@ -111,7 +106,7 @@ int kgsl_log_write( unsigned int log_flags, char* format, ... )
|
||||
if( !log_initialized ) return GSL_SUCCESS;
|
||||
|
||||
// Acquire mutex lock as we are using shared buffer for the string parsing
|
||||
kos_mutex_lock( log_mutex );
|
||||
mutex_lock(&log_mutex);
|
||||
|
||||
// Add separator
|
||||
*(b++) = '|'; *(b++) = ' ';
|
||||
@@ -498,7 +493,7 @@ int kgsl_log_write( unsigned int log_flags, char* format, ... )
|
||||
|
||||
va_end( arguments );
|
||||
|
||||
kos_mutex_unlock( log_mutex );
|
||||
mutex_unlock(&log_mutex );
|
||||
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -46,9 +46,6 @@
|
||||
|
||||
|
||||
// macros
|
||||
#define GSL_MEMARENA_LOCK() kos_mutex_lock(memarena->mutex)
|
||||
#define GSL_MEMARENA_UNLOCK() kos_mutex_unlock(memarena->mutex)
|
||||
|
||||
#define GSL_MEMARENA_SET_SIGNATURE (memarena->priv |= ((GSL_MEMARENA_INSTANCE_SIGNATURE << GSL_MEMARENAPRIV_SIGNATURE_SHIFT) & GSL_MEMARENAPRIV_SIGNATURE_MASK))
|
||||
#define GSL_MEMARENA_SET_MMU_VIRTUALIZED (memarena->priv |= ((mmu_virtualized << GSL_MEMARENAPRIV_MMUVIRTUALIZED_SHIFT) & GSL_MEMARENAPRIV_MMUVIRTUALIZED_MASK))
|
||||
#define GSL_MEMARENA_SET_ID (memarena->priv |= ((aperture_id << GSL_MEMARENAPRIV_APERTUREID_SHIFT) & GSL_MEMARENAPRIV_APERTUREID_MASK))
|
||||
@@ -61,7 +58,7 @@
|
||||
|
||||
// validate
|
||||
#define GSL_MEMARENA_VALIDATE(memarena) \
|
||||
KOS_ASSERT(memarena); \
|
||||
DEBUG_ASSERT(memarena); \
|
||||
if (GSL_MEMARENA_GET_SIGNATURE != GSL_MEMARENA_INSTANCE_SIGNATURE) \
|
||||
{ \
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, \
|
||||
@@ -72,7 +69,7 @@
|
||||
// " neko
|
||||
|
||||
// block alignment shift count
|
||||
OSINLINE unsigned int
|
||||
static __inline unsigned int
|
||||
gsl_memarena_alignmentshift(gsl_flags_t flags)
|
||||
{
|
||||
int alignshift = ((flags & GSL_MEMFLAGS_ALIGN_MASK) >> GSL_MEMFLAGS_ALIGN_SHIFT);
|
||||
@@ -82,7 +79,7 @@ gsl_memarena_alignmentshift(gsl_flags_t flags)
|
||||
}
|
||||
|
||||
// address alignment
|
||||
OSINLINE unsigned int
|
||||
static __inline unsigned int
|
||||
gsl_memarena_alignaddr(unsigned int address, int shift)
|
||||
{
|
||||
//
|
||||
@@ -100,7 +97,7 @@ gsl_memarena_alignaddr(unsigned int address, int shift)
|
||||
|
||||
// memory management API
|
||||
#ifdef GSL_MEMARENA_NODE_POOL_ENABLED
|
||||
OSINLINE memblk_t*
|
||||
static __inline memblk_t*
|
||||
kgsl_memarena_getmemblknode_pool(gsl_memarena_t *memarena)
|
||||
{
|
||||
gsl_nodepool_t *nodepool = memarena->nodepool;
|
||||
@@ -183,13 +180,13 @@ kgsl_memarena_getmemblknode_pool(gsl_memarena_t *memarena)
|
||||
}
|
||||
}
|
||||
|
||||
KOS_ASSERT(memblk);
|
||||
DEBUG_ASSERT(memblk);
|
||||
|
||||
return (memblk);
|
||||
}
|
||||
#endif
|
||||
|
||||
OSINLINE memblk_t*
|
||||
static __inline memblk_t*
|
||||
kgsl_memarena_getmemblknode(gsl_memarena_t *memarena)
|
||||
{
|
||||
#ifdef GSL_MEMARENA_NODE_POOL_ENABLED
|
||||
@@ -205,21 +202,21 @@ kgsl_memarena_getmemblknode(gsl_memarena_t *memarena)
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#ifdef GSL_MEMARENA_NODE_POOL_ENABLED
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_memarena_releasememblknode_pool(gsl_memarena_t *memarena, memblk_t *memblk)
|
||||
{
|
||||
gsl_nodepool_t *nodepool = memarena->nodepool;
|
||||
|
||||
KOS_ASSERT(memblk);
|
||||
KOS_ASSERT(nodepool);
|
||||
DEBUG_ASSERT(memblk);
|
||||
DEBUG_ASSERT(nodepool);
|
||||
|
||||
// locate pool to which this memblk node belongs
|
||||
while (((unsigned int) memblk) < ((unsigned int) nodepool) ||
|
||||
while (((unsigned int) memblk) < ((unsigned int) nodepool) ||
|
||||
((unsigned int) memblk) > ((unsigned int) nodepool) + sizeof(gsl_nodepool_t))
|
||||
{
|
||||
nodepool = nodepool->prev;
|
||||
|
||||
KOS_ASSERT(nodepool != memarena->nodepool);
|
||||
DEBUG_ASSERT(nodepool != memarena->nodepool);
|
||||
}
|
||||
|
||||
// mark memblk node as unused
|
||||
@@ -254,7 +251,7 @@ kgsl_memarena_releasememblknode_pool(gsl_memarena_t *memarena, memblk_t *memblk)
|
||||
}
|
||||
#endif
|
||||
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_memarena_releasememblknode(gsl_memarena_t *memarena, memblk_t *memblk)
|
||||
{
|
||||
#ifdef GSL_MEMARENA_NODE_POOL_ENABLED
|
||||
@@ -273,8 +270,6 @@ gsl_memarena_t*
|
||||
kgsl_memarena_create(int aperture_id, int mmu_virtualized, unsigned int hostbaseaddr, gpuaddr_t gpubaseaddr, int sizebytes)
|
||||
{
|
||||
static int count = 0;
|
||||
char name[100], id_str[2];
|
||||
int len;
|
||||
gsl_memarena_t *memarena;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
@@ -282,7 +277,7 @@ kgsl_memarena_create(int aperture_id, int mmu_virtualized, unsigned int hostbase
|
||||
|
||||
memarena = (gsl_memarena_t *)kmalloc(sizeof(gsl_memarena_t), GFP_KERNEL);
|
||||
|
||||
if (!memarena)
|
||||
if (!memarena)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR,
|
||||
"ERROR: Memarena allocation failed.\n" );
|
||||
@@ -296,14 +291,7 @@ kgsl_memarena_create(int aperture_id, int mmu_virtualized, unsigned int hostbase
|
||||
GSL_MEMARENA_SET_MMU_VIRTUALIZED;
|
||||
GSL_MEMARENA_SET_ID;
|
||||
|
||||
// define unique mutex for each memory arena instance
|
||||
id_str[0] = (char) (count + '0');
|
||||
id_str[1] = '\0';
|
||||
strcpy(name, "GSL_memory_arena_");
|
||||
len = strlen(name);
|
||||
strcpy(&name[len], id_str);
|
||||
|
||||
memarena->mutex = kos_mutex_create(name);
|
||||
mutex_init(&memarena->lock);
|
||||
|
||||
// set up the memory arena
|
||||
memarena->hostbaseaddr = hostbaseaddr;
|
||||
@@ -332,6 +320,7 @@ int
|
||||
kgsl_memarena_destroy(gsl_memarena_t *memarena)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
int err;
|
||||
memblk_t *p, *next;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
@@ -339,7 +328,11 @@ kgsl_memarena_destroy(gsl_memarena_t *memarena)
|
||||
|
||||
GSL_MEMARENA_VALIDATE(memarena);
|
||||
|
||||
GSL_MEMARENA_LOCK();
|
||||
err = mutex_lock_interruptible(&memarena->lock);
|
||||
if (err == -EINTR) {
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_FATAL,
|
||||
"WARNING: memarena mutex lock was interrupted\n");
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
// memory leak check
|
||||
@@ -363,12 +356,7 @@ kgsl_memarena_destroy(gsl_memarena_t *memarena)
|
||||
p = next;
|
||||
} while (p != memarena->freelist.head);
|
||||
|
||||
GSL_MEMARENA_UNLOCK();
|
||||
|
||||
if (memarena->mutex)
|
||||
{
|
||||
kos_mutex_free(memarena->mutex);
|
||||
}
|
||||
mutex_unlock(&memarena->lock);
|
||||
|
||||
kfree((void *)memarena);
|
||||
|
||||
@@ -403,11 +391,11 @@ kgsl_memarena_checkconsistency(gsl_memarena_t *memarena)
|
||||
{
|
||||
if (p->next->blkaddr != memarena->freelist.head->blkaddr)
|
||||
{
|
||||
if (p->prev->next->blkaddr != p->blkaddr ||
|
||||
if (p->prev->next->blkaddr != p->blkaddr ||
|
||||
p->next->prev->blkaddr != p->blkaddr ||
|
||||
p->blkaddr + p->blksize >= p->next->blkaddr)
|
||||
{
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_checkconsistency. Return value: %B\n", GSL_FAILURE );
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
@@ -427,7 +415,7 @@ int
|
||||
kgsl_memarena_querystats(gsl_memarena_t *memarena, gsl_memarena_stats_t *stats)
|
||||
{
|
||||
#ifdef GSL_STATS_MEM
|
||||
KOS_ASSERT(stats);
|
||||
DEBUG_ASSERT(stats);
|
||||
GSL_MEMARENA_VALIDATE(memarena);
|
||||
|
||||
memcpy(stats, &memarena->stats, sizeof(gsl_memarena_stats_t));
|
||||
@@ -448,6 +436,7 @@ int
|
||||
kgsl_memarena_checkfreeblock(gsl_memarena_t *memarena, int bytesneeded)
|
||||
{
|
||||
memblk_t *p;
|
||||
int err;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_memarena_checkfreeblock(gsl_memarena_t *memarena=0x%08x, int bytesneeded=%d)\n", memarena, bytesneeded );
|
||||
@@ -457,12 +446,16 @@ kgsl_memarena_checkfreeblock(gsl_memarena_t *memarena, int bytesneeded)
|
||||
if (bytesneeded < 1)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Illegal number of bytes needed.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_checkfreeblock. Return value: %B\n", GSL_FAILURE );
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
GSL_MEMARENA_LOCK();
|
||||
err = mutex_lock_interruptible(&memarena->lock);
|
||||
if (err == -EINTR) {
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_FATAL,
|
||||
"WARNING: memarena mutex lock was interrupted\n");
|
||||
}
|
||||
|
||||
p = memarena->freelist.head;
|
||||
do
|
||||
@@ -476,7 +469,7 @@ kgsl_memarena_checkfreeblock(gsl_memarena_t *memarena, int bytesneeded)
|
||||
p = p->next;
|
||||
} while (p != memarena->freelist.head);
|
||||
|
||||
GSL_MEMARENA_UNLOCK();
|
||||
mutex_unlock(&memarena->lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_checkfreeblock. Return value: %B\n", GSL_FAILURE );
|
||||
|
||||
@@ -493,6 +486,7 @@ kgsl_memarena_alloc(gsl_memarena_t *memarena, gsl_flags_t flags, int size, gsl_m
|
||||
unsigned int blksize;
|
||||
unsigned int baseaddr, alignedbaseaddr, alignfragment;
|
||||
int freeblk, alignmentshift;
|
||||
int err;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_memarena_alloc(gsl_memarena_t *memarena=0x%08x, gsl_flags_t flags=0x%08x, int size=%d, gsl_memdesc_t *memdesc=%M)\n", memarena, flags, size, memdesc );
|
||||
@@ -502,7 +496,7 @@ kgsl_memarena_alloc(gsl_memarena_t *memarena, gsl_flags_t flags, int size, gsl_m
|
||||
if (size <= 0)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Invalid size for memory allocation.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_alloc. Return value: %B\n", GSL_FAILURE );
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
@@ -517,14 +511,14 @@ kgsl_memarena_alloc(gsl_memarena_t *memarena, gsl_flags_t flags, int size, gsl_m
|
||||
// by blksize and return the address after allocating the memory. if the free block size becomes
|
||||
// 0 then remove this node from the free list
|
||||
//
|
||||
// there would be no node on the free list if all available memory were to be allocated.
|
||||
// handling an empty list would require executing error checking code in the main branch which
|
||||
// is not desired. instead, the free list will have at least one node at all times. This node
|
||||
// there would be no node on the free list if all available memory were to be allocated.
|
||||
// handling an empty list would require executing error checking code in the main branch which
|
||||
// is not desired. instead, the free list will have at least one node at all times. This node
|
||||
// could have a block size of zero
|
||||
//
|
||||
// we use a next fit allocation mechanism that uses a roving pointer on a circular free block list.
|
||||
// we use a next fit allocation mechanism that uses a roving pointer on a circular free block list.
|
||||
// the pointer is advanced along the chain when searching for a fit. Thus each allocation begins
|
||||
// looking where the previous one finished.
|
||||
// looking where the previous one finished.
|
||||
//
|
||||
|
||||
// when allocating from external memory aperture, round up size of requested block to multiple of page size if needed
|
||||
@@ -545,7 +539,11 @@ kgsl_memarena_alloc(gsl_memarena_t *memarena, gsl_flags_t flags, int size, gsl_m
|
||||
// adjust size of requested block to include alignment
|
||||
blksize = (unsigned int)((size + ((1 << alignmentshift) - 1)) >> alignmentshift) << alignmentshift;
|
||||
|
||||
GSL_MEMARENA_LOCK();
|
||||
err = mutex_lock_interruptible(&memarena->lock);
|
||||
if (err == -EINTR) {
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_FATAL,
|
||||
"WARNING: memarena mutex lock was interrupted\n");
|
||||
}
|
||||
|
||||
// check consistency, debug only
|
||||
KGSL_DEBUG(GSL_DBGFLAGS_MEMMGR, kgsl_memarena_checkconsistency(memarena));
|
||||
@@ -620,12 +618,13 @@ kgsl_memarena_alloc(gsl_memarena_t *memarena, gsl_flags_t flags, int size, gsl_m
|
||||
|
||||
} while (!freeblk && ptrfree != memarena->freelist.allocrover);
|
||||
|
||||
GSL_MEMARENA_UNLOCK();
|
||||
|
||||
mutex_unlock(&memarena->lock);
|
||||
|
||||
if (result == GSL_SUCCESS)
|
||||
{
|
||||
GSL_MEMARENA_STATS(
|
||||
{
|
||||
{
|
||||
int i = 0;
|
||||
while (memdesc->size >> (GSL_PAGESIZE_SHIFT + i))
|
||||
{
|
||||
@@ -662,11 +661,12 @@ kgsl_memarena_free(gsl_memarena_t *memarena, gsl_memdesc_t *memdesc)
|
||||
memblk_t *ptrfree, *ptrend, *p;
|
||||
int mallocfreeblk, clockwise;
|
||||
unsigned int addrtofree;
|
||||
int err;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> void kgsl_memarena_free(gsl_memarena_t *memarena=0x%08x, gsl_memdesc_t *memdesc=%M)\n", memarena, memdesc );
|
||||
|
||||
KOS_ASSERT(memarena);
|
||||
DEBUG_ASSERT(memarena);
|
||||
if (GSL_MEMARENA_GET_SIGNATURE != GSL_MEMARENA_INSTANCE_SIGNATURE)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_free.\n" );
|
||||
@@ -677,17 +677,21 @@ kgsl_memarena_free(gsl_memarena_t *memarena, gsl_memdesc_t *memdesc)
|
||||
if (memdesc->size <= 0)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Illegal size for the memdesc.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_free.\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
// check address range
|
||||
KOS_ASSERT( memarena->gpubaseaddr <= memdesc->gpuaddr);
|
||||
KOS_ASSERT((memarena->gpubaseaddr + memarena->sizebytes) >= memdesc->gpuaddr + memdesc->size);
|
||||
DEBUG_ASSERT( memarena->gpubaseaddr <= memdesc->gpuaddr);
|
||||
DEBUG_ASSERT((memarena->gpubaseaddr + memarena->sizebytes) >= memdesc->gpuaddr + memdesc->size);
|
||||
|
||||
GSL_MEMARENA_LOCK();
|
||||
err = mutex_lock_interruptible(&memarena->lock);
|
||||
if (err == -EINTR) {
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_FATAL,
|
||||
"WARNING: memarena mutex lock was interrupted\n");
|
||||
}
|
||||
|
||||
// check consistency of memory map, debug only
|
||||
KGSL_DEBUG(GSL_DBGFLAGS_MEMMGR, kgsl_memarena_checkconsistency(memarena));
|
||||
@@ -760,7 +764,7 @@ kgsl_memarena_free(gsl_memarena_t *memarena, gsl_memdesc_t *memdesc)
|
||||
// traverse the nodes
|
||||
do
|
||||
{
|
||||
if ((addrtofree >= ptrfree->blkaddr + ptrfree->blksize) &&
|
||||
if ((addrtofree >= ptrfree->blkaddr + ptrfree->blksize) &&
|
||||
(addrtofree + memdesc->size <= ptrfree->next->blkaddr))
|
||||
{
|
||||
if (addrtofree == ptrfree->blkaddr + ptrfree->blksize)
|
||||
@@ -834,10 +838,10 @@ kgsl_memarena_free(gsl_memarena_t *memarena, gsl_memdesc_t *memdesc)
|
||||
memarena->freelist.freerover = ptrfree;
|
||||
}
|
||||
|
||||
GSL_MEMARENA_UNLOCK();
|
||||
mutex_unlock(&memarena->lock);
|
||||
|
||||
GSL_MEMARENA_STATS(
|
||||
{
|
||||
{
|
||||
int i = 0;
|
||||
while (memdesc->size >> (GSL_PAGESIZE_SHIFT + i))
|
||||
{
|
||||
@@ -854,8 +858,7 @@ kgsl_memarena_free(gsl_memarena_t *memarena, gsl_memdesc_t *memdesc)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void *
|
||||
kgsl_memarena_gethostptr(gsl_memarena_t *memarena, gpuaddr_t gpuaddr)
|
||||
void *kgsl_memarena_gethostptr(gsl_memarena_t *memarena, gpuaddr_t gpuaddr)
|
||||
{
|
||||
//
|
||||
// get the host mapped address for a hardware device address
|
||||
@@ -866,7 +869,7 @@ kgsl_memarena_gethostptr(gsl_memarena_t *memarena, gpuaddr_t gpuaddr)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> void* kgsl_memarena_gethostptr(gsl_memarena_t *memarena=0x%08x, gpuaddr_t gpuaddr=0x%08x)\n", memarena, gpuaddr );
|
||||
|
||||
KOS_ASSERT(memarena);
|
||||
DEBUG_ASSERT(memarena);
|
||||
if (GSL_MEMARENA_GET_SIGNATURE != GSL_MEMARENA_INSTANCE_SIGNATURE)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_gethostptr. Return value: 0x%08x\n", NULL );
|
||||
@@ -874,8 +877,8 @@ kgsl_memarena_gethostptr(gsl_memarena_t *memarena, gpuaddr_t gpuaddr)
|
||||
}
|
||||
|
||||
// check address range
|
||||
KOS_ASSERT(gpuaddr >= memarena->gpubaseaddr);
|
||||
KOS_ASSERT(gpuaddr < memarena->gpubaseaddr + memarena->sizebytes);
|
||||
DEBUG_ASSERT(gpuaddr >= memarena->gpubaseaddr);
|
||||
DEBUG_ASSERT(gpuaddr < memarena->gpubaseaddr + memarena->sizebytes);
|
||||
|
||||
hostptr = (void *)((gpuaddr - memarena->gpubaseaddr) + memarena->hostbaseaddr);
|
||||
|
||||
@@ -886,8 +889,7 @@ kgsl_memarena_gethostptr(gsl_memarena_t *memarena, gpuaddr_t gpuaddr)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
gpuaddr_t
|
||||
kgsl_memarena_getgpuaddr(gsl_memarena_t *memarena, void *hostptr)
|
||||
gpuaddr_t kgsl_memarena_getgpuaddr(gsl_memarena_t *memarena, void *hostptr)
|
||||
{
|
||||
//
|
||||
// get the hardware device address for a host mapped address
|
||||
@@ -898,7 +900,7 @@ kgsl_memarena_getgpuaddr(gsl_memarena_t *memarena, void *hostptr)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_memarena_getgpuaddr(gsl_memarena_t *memarena=0x%08x, void *hostptr=0x%08x)\n", memarena, hostptr );
|
||||
|
||||
KOS_ASSERT(memarena);
|
||||
DEBUG_ASSERT(memarena);
|
||||
if (GSL_MEMARENA_GET_SIGNATURE != GSL_MEMARENA_INSTANCE_SIGNATURE)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_getgpuaddr. Return value: 0x%08x\n", 0 );
|
||||
@@ -906,9 +908,9 @@ kgsl_memarena_getgpuaddr(gsl_memarena_t *memarena, void *hostptr)
|
||||
}
|
||||
|
||||
// check address range
|
||||
KOS_ASSERT(hostptr >= (void *)memarena->hostbaseaddr);
|
||||
KOS_ASSERT(hostptr < (void *)(memarena->hostbaseaddr + memarena->sizebytes));
|
||||
|
||||
DEBUG_ASSERT(hostptr >= (void *)memarena->hostbaseaddr);
|
||||
DEBUG_ASSERT(hostptr < (void *)(memarena->hostbaseaddr + memarena->sizebytes));
|
||||
|
||||
gpuaddr = ((unsigned int)hostptr - memarena->hostbaseaddr) + memarena->gpubaseaddr;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_getgpuaddr. Return value: 0x%08x\n", gpuaddr );
|
||||
@@ -918,18 +920,19 @@ kgsl_memarena_getgpuaddr(gsl_memarena_t *memarena, void *hostptr)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
unsigned int
|
||||
unsigned int
|
||||
kgsl_memarena_getlargestfreeblock(gsl_memarena_t *memarena, gsl_flags_t flags)
|
||||
{
|
||||
memblk_t *ptrfree;
|
||||
unsigned int blocksize, largestblocksize = 0;
|
||||
int alignmentshift;
|
||||
int alignmentshift;
|
||||
int err;
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> unsigned int kgsl_memarena_getlargestfreeblock(gsl_memarena_t *memarena=0x%08x, gsl_flags_t flags=0x%08x)\n", memarena, flags );
|
||||
|
||||
KOS_ASSERT(memarena);
|
||||
if (GSL_MEMARENA_GET_SIGNATURE != GSL_MEMARENA_INSTANCE_SIGNATURE)
|
||||
DEBUG_ASSERT(memarena);
|
||||
if (GSL_MEMARENA_GET_SIGNATURE != GSL_MEMARENA_INSTANCE_SIGNATURE)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_getlargestfreeblock. Return value: %d\n", 0 );
|
||||
return (0);
|
||||
@@ -938,7 +941,11 @@ kgsl_memarena_getlargestfreeblock(gsl_memarena_t *memarena, gsl_flags_t flags)
|
||||
// determine shift count for alignment requested
|
||||
alignmentshift = gsl_memarena_alignmentshift(flags);
|
||||
|
||||
GSL_MEMARENA_LOCK();
|
||||
err = mutex_lock_interruptible(&memarena->lock);
|
||||
if (err == -EINTR) {
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_FATAL,
|
||||
"WARNING: memarena mutex lock was interrupted\n");
|
||||
}
|
||||
|
||||
ptrfree = memarena->freelist.head;
|
||||
|
||||
@@ -955,7 +962,7 @@ kgsl_memarena_getlargestfreeblock(gsl_memarena_t *memarena, gsl_flags_t flags)
|
||||
|
||||
} while (ptrfree != memarena->freelist.head);
|
||||
|
||||
GSL_MEMARENA_UNLOCK();
|
||||
mutex_unlock(&memarena->lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_memarena_getlargestfreeblock. Return value: %d\n", largestblocksize );
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
@@ -65,18 +66,6 @@ const unsigned int GSL_PT_PAGE_AP[4] = {(GSL_PT_PAGE_READ | GSL_PT_PAGE_WRITE),
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// macros
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
#define GSL_MMU_MUTEX_CREATE() mmu->mutex = kos_mutex_create("gsl_mmu"); \
|
||||
if (!mmu->mutex) {return (GSL_FAILURE);}
|
||||
#define GSL_MMU_LOCK() kos_mutex_lock(mmu->mutex)
|
||||
#define GSL_MMU_UNLOCK() kos_mutex_unlock(mmu->mutex)
|
||||
#define GSL_MMU_MUTEX_FREE() kos_mutex_free(mmu->mutex); mmu->mutex = 0;
|
||||
#else
|
||||
#define GSL_MMU_MUTEX_CREATE()
|
||||
#define GSL_MMU_LOCK()
|
||||
#define GSL_MMU_UNLOCK()
|
||||
#define GSL_MMU_MUTEX_FREE()
|
||||
#endif
|
||||
|
||||
#define GSL_PT_ENTRY_GET(va) ((va - pagetable->va_base) >> GSL_PAGESIZE_SHIFT)
|
||||
#define GSL_PT_VIRT_GET(pte) (pagetable->va_base + (pte * GSL_PAGESIZE))
|
||||
@@ -107,7 +96,7 @@ const unsigned int GSL_PT_PAGE_AP[4] = {(GSL_PT_PAGE_READ | GSL_PT_PAGE_WRITE),
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// process index in pagetable object table
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
OSINLINE int
|
||||
static __inline int
|
||||
kgsl_mmu_getprocessindex(unsigned int pid, int *pindex)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
@@ -126,7 +115,7 @@ kgsl_mmu_getprocessindex(unsigned int pid, int *pindex)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// pagetable object for current caller process
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
OSINLINE gsl_pagetable_t*
|
||||
static __inline gsl_pagetable_t*
|
||||
kgsl_mmu_getpagetableobject(gsl_mmu_t *mmu, unsigned int pid)
|
||||
{
|
||||
int pindex = 0;
|
||||
@@ -201,7 +190,7 @@ kgsl_mmu_checkconsistency(gsl_pagetable_t *pagetable)
|
||||
|
||||
if (pagetable->last_superpte % GSL_PT_SUPER_PTE != 0)
|
||||
{
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_checkconsistency. Return value %B\n", GSL_FAILURE );
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
@@ -261,7 +250,7 @@ kgsl_mmu_destroypagetableobject(gsl_mmu_t *mmu, unsigned int pid)
|
||||
/* Because it is an annoyance for HW guys, it is disabled for dumpx */
|
||||
if(!gsl_driver.flags_debug & GSL_DBGFLAGS_DUMPX)
|
||||
{
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -269,7 +258,7 @@ kgsl_mmu_destroypagetableobject(gsl_mmu_t *mmu, unsigned int pid)
|
||||
|
||||
if (pagetable->base.gpuaddr)
|
||||
{
|
||||
kgsl_sharedmem_free0(&pagetable->base, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&pagetable->base, current->tgid);
|
||||
}
|
||||
|
||||
kfree(pagetable);
|
||||
@@ -337,8 +326,8 @@ kgsl_mmu_createpagetableobject(gsl_mmu_t *mmu, unsigned int pid)
|
||||
// pagetable object exists
|
||||
if (tmp_pagetable)
|
||||
{
|
||||
KOS_ASSERT(tmp_pagetable->va_base == mmu->va_base);
|
||||
KOS_ASSERT(tmp_pagetable->va_range == mmu->va_range);
|
||||
DEBUG_ASSERT(tmp_pagetable->va_base == mmu->va_base);
|
||||
DEBUG_ASSERT(tmp_pagetable->va_range == mmu->va_range);
|
||||
|
||||
// set pagetable object reference
|
||||
mmu->pagetable[pindex] = tmp_pagetable;
|
||||
@@ -401,8 +390,6 @@ kgsl_mmu_setpagetable(gsl_device_t *device, unsigned int pid)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> gsl_pagetable_t* kgsl_mmu_setpagetable(gsl_device_t *device=0x%08x)\n", device );
|
||||
|
||||
GSL_MMU_LOCK();
|
||||
|
||||
if (mmu->flags & GSL_FLAGS_STARTED)
|
||||
{
|
||||
#ifdef GSL_MMU_PAGETABLE_PERPROCESS
|
||||
@@ -441,8 +428,6 @@ kgsl_mmu_setpagetable(gsl_device_t *device, unsigned int pid)
|
||||
}
|
||||
}
|
||||
|
||||
GSL_MMU_UNLOCK();
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_setpagetable. Return value %B\n", status );
|
||||
|
||||
return (status);
|
||||
@@ -512,8 +497,8 @@ kgsl_mmu_init(gsl_device_t *device)
|
||||
device->ftbl.device_idle(device, GSL_TIMEOUT_DEFAULT);
|
||||
|
||||
// make sure aligned to pagesize
|
||||
KOS_ASSERT((mmu->mpu_base & ((1 << GSL_PAGESIZE_SHIFT)-1)) == 0);
|
||||
KOS_ASSERT(((mmu->mpu_base + mmu->mpu_range) & ((1 << GSL_PAGESIZE_SHIFT)-1)) == 0);
|
||||
DEBUG_ASSERT((mmu->mpu_base & ((1 << GSL_PAGESIZE_SHIFT)-1)) == 0);
|
||||
DEBUG_ASSERT(((mmu->mpu_base + mmu->mpu_range) & ((1 << GSL_PAGESIZE_SHIFT)-1)) == 0);
|
||||
|
||||
// define physical memory range accessible by the core
|
||||
device->ftbl.device_regwrite(device, gsl_cfg_mmu_reg[devindex].MPU_BASE, mmu->mpu_base);
|
||||
@@ -528,13 +513,11 @@ kgsl_mmu_init(gsl_device_t *device)
|
||||
// sub-client MMU lookups require address translation
|
||||
if ((mmu->config & ~0x1) > 0)
|
||||
{
|
||||
GSL_MMU_MUTEX_CREATE();
|
||||
|
||||
// make sure virtual address range is a multiple of 64Kb
|
||||
KOS_ASSERT((mmu->va_range & ((1 << 16)-1)) == 0);
|
||||
DEBUG_ASSERT((mmu->va_range & ((1 << 16)-1)) == 0);
|
||||
|
||||
// setup pagetable object
|
||||
pagetable = kgsl_mmu_createpagetableobject(mmu, GSL_CALLER_PROCESSID_GET());
|
||||
pagetable = kgsl_mmu_createpagetableobject(mmu, current->tgid);
|
||||
if (!pagetable)
|
||||
{
|
||||
kgsl_mmu_close(device);
|
||||
@@ -609,12 +592,12 @@ kgsl_mmu_map(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, const gsl_scatterlist_t *sca
|
||||
"--> int kgsl_mmu_map(gsl_mmu_t *mmu=0x%08x, gpuaddr_t gpubaseaddr=0x%08x, gsl_scatterlist_t *scatterlist=%M, gsl_flags_t flags=%d, uint pid=0x%08x)\n",
|
||||
mmu, gpubaseaddr, scatterlist, flags, pid );
|
||||
|
||||
KOS_ASSERT(scatterlist);
|
||||
DEBUG_ASSERT(scatterlist);
|
||||
|
||||
if (scatterlist->num <= 0)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: num pages is too small.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_map. Return value %B\n", GSL_FAILURE );
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
@@ -622,12 +605,9 @@ kgsl_mmu_map(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, const gsl_scatterlist_t *sca
|
||||
// get gpu access permissions
|
||||
ap = GSL_PT_PAGE_AP[((flags & GSL_MEMFLAGS_GPUAP_MASK) >> GSL_MEMFLAGS_GPUAP_SHIFT)];
|
||||
|
||||
GSL_MMU_LOCK();
|
||||
|
||||
pagetable = kgsl_mmu_getpagetableobject(mmu, pid);
|
||||
if (!pagetable)
|
||||
{
|
||||
GSL_MMU_UNLOCK();
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
@@ -698,12 +678,10 @@ kgsl_mmu_map(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, const gsl_scatterlist_t *sca
|
||||
{
|
||||
// this should never happen
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_FATAL, "FATAL: This should never happen.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
status = GSL_FAILURE;
|
||||
}
|
||||
|
||||
GSL_MMU_UNLOCK();
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_map. Return value %B\n", GSL_SUCCESS );
|
||||
|
||||
return (status);
|
||||
@@ -739,7 +717,7 @@ kgsl_mmu_unmap(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, int range, unsigned int pi
|
||||
if (range <= 0)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Range is too small.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_unmap. Return value %B\n", GSL_FAILURE );
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
@@ -750,12 +728,9 @@ kgsl_mmu_unmap(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, int range, unsigned int pi
|
||||
numpages++;
|
||||
}
|
||||
|
||||
GSL_MMU_LOCK();
|
||||
|
||||
pagetable = kgsl_mmu_getpagetableobject(mmu, pid);
|
||||
if (!pagetable)
|
||||
{
|
||||
GSL_MMU_UNLOCK();
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
@@ -803,15 +778,13 @@ kgsl_mmu_unmap(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, int range, unsigned int pi
|
||||
{
|
||||
// this should never happen
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_FATAL, "FATAL: This should never happen.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
status = GSL_FAILURE;
|
||||
}
|
||||
|
||||
// invalidate tlb, debug only
|
||||
KGSL_DEBUG(GSL_DBGFLAGS_MMU, mmu->device->ftbl.mmu_tlbinvalidate(mmu->device, gsl_cfg_mmu_reg[mmu->device->id-1].INVALIDATE, pagetable->pid));
|
||||
|
||||
GSL_MMU_UNLOCK();
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_unmap. Return value %B\n", GSL_SUCCESS );
|
||||
|
||||
return (status);
|
||||
@@ -841,17 +814,14 @@ kgsl_mmu_getmap(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, int range, gsl_scatterlis
|
||||
if (range <= 0 || scatterlist->num != numpages)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Range is too small.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_getmap. Return value %B\n", GSL_FAILURE );
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
GSL_MMU_LOCK();
|
||||
|
||||
pagetable = kgsl_mmu_getpagetableobject(mmu, pid);
|
||||
if (!pagetable)
|
||||
{
|
||||
GSL_MMU_UNLOCK();
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
@@ -885,8 +855,6 @@ kgsl_mmu_getmap(gsl_mmu_t *mmu, gpuaddr_t gpubaseaddr, int range, gsl_scatterlis
|
||||
scatterlist->pages[0] = GSL_PT_MAP_GETADDR(ptefirst);
|
||||
}
|
||||
|
||||
GSL_MMU_UNLOCK();
|
||||
|
||||
scatterlist->contiguous = contiguous;
|
||||
|
||||
return (GSL_SUCCESS);
|
||||
@@ -915,7 +883,7 @@ kgsl_mmu_close(gsl_device_t *device)
|
||||
if (mmu->flags & GSL_FLAGS_STARTED)
|
||||
{
|
||||
// terminate pagetable object
|
||||
kgsl_mmu_destroypagetableobject(mmu, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_mmu_destroypagetableobject(mmu, current->tgid);
|
||||
}
|
||||
|
||||
// no more processes attached to current device mmu
|
||||
@@ -931,7 +899,7 @@ kgsl_mmu_close(gsl_device_t *device)
|
||||
/* Because it is an annoyance for HW guys, it is disabled for dumpx */
|
||||
if(!gsl_driver.flags_debug & GSL_DBGFLAGS_DUMPX)
|
||||
{
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -953,11 +921,9 @@ kgsl_mmu_close(gsl_device_t *device)
|
||||
|
||||
if (mmu->dummyspace.gpuaddr)
|
||||
{
|
||||
kgsl_sharedmem_free0(&mmu->dummyspace, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&mmu->dummyspace, current->tgid);
|
||||
}
|
||||
|
||||
GSL_MMU_MUTEX_FREE();
|
||||
|
||||
mmu->flags &= ~GSL_FLAGS_STARTED;
|
||||
mmu->flags &= ~GSL_FLAGS_INITIALIZED;
|
||||
mmu->flags &= ~GSL_FLAGS_INITIALIZED0;
|
||||
@@ -984,8 +950,6 @@ kgsl_mmu_attachcallback(gsl_mmu_t *mmu, unsigned int pid)
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "--> int kgsl_mmu_attachcallback(gsl_mmu_t *mmu=0x%08x, uint pid=0x%08x)\n", mmu, pid );
|
||||
|
||||
GSL_MMU_LOCK();
|
||||
|
||||
if (mmu->flags & GSL_FLAGS_INITIALIZED0)
|
||||
{
|
||||
// attach to current device mmu
|
||||
@@ -1006,8 +970,6 @@ kgsl_mmu_attachcallback(gsl_mmu_t *mmu, unsigned int pid)
|
||||
}
|
||||
}
|
||||
|
||||
GSL_MMU_UNLOCK();
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_attachcallback. Return value %B\n", status );
|
||||
|
||||
return (status);
|
||||
@@ -1026,8 +988,6 @@ kgsl_mmu_detachcallback(gsl_mmu_t *mmu, unsigned int pid)
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "--> int kgsl_mmu_detachcallback(gsl_mmu_t *mmu=0x%08x, uint pid=0x%08x)\n", mmu, pid );
|
||||
|
||||
GSL_MMU_LOCK();
|
||||
|
||||
if (mmu->flags & GSL_FLAGS_INITIALIZED0)
|
||||
{
|
||||
// detach from current device mmu
|
||||
@@ -1048,8 +1008,6 @@ kgsl_mmu_detachcallback(gsl_mmu_t *mmu, unsigned int pid)
|
||||
}
|
||||
}
|
||||
|
||||
GSL_MMU_UNLOCK();
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_mmu_detachcallback. Return value %B\n", status );
|
||||
|
||||
return (status);
|
||||
@@ -1063,9 +1021,7 @@ kgsl_mmu_querystats(gsl_mmu_t *mmu, gsl_mmustats_t *stats)
|
||||
#ifdef GSL_STATS_MMU
|
||||
int status = GSL_SUCCESS;
|
||||
|
||||
KOS_ASSERT(stats);
|
||||
|
||||
GSL_MMU_LOCK();
|
||||
DEBUG_ASSERT(stats);
|
||||
|
||||
if (mmu->flags & GSL_FLAGS_STARTED)
|
||||
{
|
||||
@@ -1076,8 +1032,6 @@ kgsl_mmu_querystats(gsl_mmu_t *mmu, gsl_mmustats_t *stats)
|
||||
memset(stats, 0, sizeof(gsl_mmustats_t));
|
||||
}
|
||||
|
||||
GSL_MMU_UNLOCK();
|
||||
|
||||
return (status);
|
||||
#else
|
||||
// unreferenced formal parameters
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
#include "gsl_cmdstream.h"
|
||||
@@ -45,7 +47,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// ringbuffer size log2 quadwords equivalent
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
OSINLINE unsigned int
|
||||
static __inline unsigned int
|
||||
gsl_ringbuffer_sizelog2quadwords(unsigned int sizedwords)
|
||||
{
|
||||
unsigned int sizelog2quadwords = 0;
|
||||
@@ -97,7 +99,7 @@ kgsl_cp_intrcallback(gsl_intrid_t id, void *cookie)
|
||||
case GSL_INTR_YDX_CP_RING_BUFFER:
|
||||
|
||||
// signal intr completion event
|
||||
kos_event_signal(rb->device->intr.evnt[id]);
|
||||
complete_all(&rb->device->intr.evnt[id]);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -120,8 +122,6 @@ kgsl_ringbuffer_watchdog()
|
||||
|
||||
if (rb->flags & GSL_FLAGS_STARTED)
|
||||
{
|
||||
GSL_RB_MUTEX_LOCK();
|
||||
|
||||
GSL_RB_GET_READPTR(rb, &rb->rptr);
|
||||
|
||||
// ringbuffer is currently not empty
|
||||
@@ -152,9 +152,7 @@ kgsl_ringbuffer_watchdog()
|
||||
rb->watchdog.flags &= ~GSL_FLAGS_ACTIVE;
|
||||
}
|
||||
|
||||
GSL_RB_MUTEX_UNLOCK();
|
||||
}
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_COMMAND | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_ringbuffer_watchdog.\n" );
|
||||
}
|
||||
|
||||
@@ -162,7 +160,7 @@ kgsl_ringbuffer_watchdog()
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_ringbuffer_checkregister(unsigned int reg, int pmodecheck)
|
||||
{
|
||||
if (pmodecheck)
|
||||
@@ -171,7 +169,7 @@ kgsl_ringbuffer_checkregister(unsigned int reg, int pmodecheck)
|
||||
if (reg <= (GSL_RB_PROTECTED_MODE_CONTROL & 0x3FFF))
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Register protection mode violation.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +177,7 @@ kgsl_ringbuffer_checkregister(unsigned int reg, int pmodecheck)
|
||||
if (reg > (gsl_driver.device[GSL_DEVICE_YAMATO-1].regspace.sizebytes >> 2))
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Register out of range.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +217,7 @@ kgsl_ringbuffer_checkpm4type3(unsigned int header, unsigned int** cmds, int indi
|
||||
if (indirection > 2)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Only two levels of indirection supported.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
}
|
||||
|
||||
switch(pm4header.it_opcode)
|
||||
@@ -258,7 +256,7 @@ kgsl_ringbuffer_checkpm4type3(unsigned int header, unsigned int** cmds, int indi
|
||||
if(indirection != 0)
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: ME INIT packet cannot reside in an ib.\n" );
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -345,7 +343,7 @@ kgsl_ringbuffer_submit(gsl_ringbuffer_t *rb)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_COMMAND | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> static void kgsl_ringbuffer_submit(gsl_ringbuffer_t *rb=0x%08x)\n", rb );
|
||||
|
||||
KOS_ASSERT(rb->wptr != 0);
|
||||
DEBUG_ASSERT(rb->wptr != 0);
|
||||
|
||||
kgsl_device_active(rb->device);
|
||||
|
||||
@@ -422,7 +420,7 @@ kgsl_ringbuffer_addcmds(gsl_ringbuffer_t *rb, unsigned int numcmds)
|
||||
"--> static unsigned int* kgsl_ringbuffer_addcmds(gsl_ringbuffer_t *rb=0x%08x, unsigned int numcmds=%d)\n",
|
||||
rb, numcmds );
|
||||
|
||||
KOS_ASSERT(numcmds < rb->sizedwords);
|
||||
DEBUG_ASSERT(numcmds < rb->sizedwords);
|
||||
|
||||
// update host copy of read pointer when running in safe mode
|
||||
if (rb->device->flags & GSL_FLAGS_SAFEMODE)
|
||||
@@ -670,8 +668,6 @@ kgsl_ringbuffer_init(gsl_device_t *device)
|
||||
rb->sizedwords = (2 << gsl_cfg_rb_sizelog2quadwords);
|
||||
rb->blksizequadwords = gsl_cfg_rb_blksizequadwords;
|
||||
|
||||
GSL_RB_MUTEX_CREATE();
|
||||
|
||||
// allocate memory for ringbuffer, needs to be double octword aligned
|
||||
// align on page from contiguous physical memory
|
||||
flags = (GSL_MEMFLAGS_ALIGNPAGE | GSL_MEMFLAGS_CONPHYS | GSL_MEMFLAGS_STRICTREQUEST);
|
||||
@@ -734,29 +730,23 @@ kgsl_ringbuffer_close(gsl_ringbuffer_t *rb)
|
||||
kgsl_log_write( KGSL_LOG_GROUP_COMMAND | KGSL_LOG_LEVEL_TRACE,
|
||||
"--> int kgsl_ringbuffer_close(gsl_ringbuffer_t *rb=0x%08x)\n", rb );
|
||||
|
||||
GSL_RB_MUTEX_LOCK();
|
||||
|
||||
// stop ringbuffer
|
||||
kgsl_ringbuffer_stop(rb);
|
||||
|
||||
// free buffer
|
||||
if (rb->buffer_desc.hostptr)
|
||||
{
|
||||
kgsl_sharedmem_free0(&rb->buffer_desc, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&rb->buffer_desc, current->tgid);
|
||||
}
|
||||
|
||||
// free memory pointers
|
||||
if (rb->memptrs_desc.hostptr)
|
||||
{
|
||||
kgsl_sharedmem_free0(&rb->memptrs_desc, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_sharedmem_free0(&rb->memptrs_desc, current->tgid);
|
||||
}
|
||||
|
||||
rb->flags &= ~GSL_FLAGS_INITIALIZED;
|
||||
|
||||
GSL_RB_MUTEX_UNLOCK();
|
||||
|
||||
GSL_RB_MUTEX_FREE();
|
||||
|
||||
memset(rb, 0, sizeof(gsl_ringbuffer_t));
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_COMMAND | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_ringbuffer_close. Return value %B\n", GSL_SUCCESS );
|
||||
@@ -795,7 +785,7 @@ kgsl_ringbuffer_issuecmds(gsl_device_t *device, int pmodeoff, unsigned int *cmds
|
||||
|
||||
#if defined GSL_RB_TIMESTAMP_INTERUPT
|
||||
pmodesizedwords += 2;
|
||||
#endif
|
||||
#endif
|
||||
// allocate space in ringbuffer
|
||||
ringcmds = kgsl_ringbuffer_addcmds(rb, pmodesizedwords + sizedwords + 6);
|
||||
|
||||
@@ -872,13 +862,11 @@ kgsl_ringbuffer_issueibcmds(gsl_device_t *device, int drawctxt_index, gpuaddr_t
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
KOS_ASSERT(ibaddr);
|
||||
KOS_ASSERT(sizedwords);
|
||||
DEBUG_ASSERT(ibaddr);
|
||||
DEBUG_ASSERT(sizedwords);
|
||||
|
||||
KGSL_DEBUG(GSL_DBGFLAGS_DUMPX, dumpx_swap = kgsl_dumpx_parse_ibs(ibaddr, sizedwords));
|
||||
|
||||
GSL_RB_MUTEX_LOCK();
|
||||
|
||||
// context switch if needed
|
||||
kgsl_drawctxt_switch(device, &device->drawctxt[drawctxt_index], flags);
|
||||
|
||||
@@ -886,9 +874,7 @@ kgsl_ringbuffer_issueibcmds(gsl_device_t *device, int drawctxt_index, gpuaddr_t
|
||||
link[1] = ibaddr;
|
||||
link[2] = sizedwords;
|
||||
|
||||
*timestamp = kgsl_ringbuffer_issuecmds(device, 0, &link[0], 3, GSL_CALLER_PROCESSID_GET());
|
||||
|
||||
GSL_RB_MUTEX_UNLOCK();
|
||||
*timestamp = kgsl_ringbuffer_issuecmds(device, 0, &link[0], 3, current->tgid);
|
||||
|
||||
// idle device when running in safe mode
|
||||
if (device->flags & GSL_FLAGS_SAFEMODE)
|
||||
@@ -954,7 +940,7 @@ int
|
||||
kgsl_ringbuffer_querystats(gsl_ringbuffer_t *rb, gsl_rbstats_t *stats)
|
||||
{
|
||||
#ifdef GSL_STATS_RINGBUFFER
|
||||
KOS_ASSERT(stats);
|
||||
DEBUG_ASSERT(stats);
|
||||
|
||||
if (!(rb->flags & GSL_FLAGS_STARTED))
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/sched.h>
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hal.h"
|
||||
@@ -32,11 +33,11 @@
|
||||
|
||||
#define GSL_MEMFLAGS_APERTURE_GET(flags, aperture_id) \
|
||||
aperture_id = (gsl_apertureid_t)((flags & GSL_MEMFLAGS_APERTURE_MASK) >> GSL_MEMFLAGS_APERTURE_SHIFT); \
|
||||
KOS_ASSERT(aperture_id < GSL_APERTURE_MAX);
|
||||
DEBUG_ASSERT(aperture_id < GSL_APERTURE_MAX);
|
||||
|
||||
#define GSL_MEMFLAGS_CHANNEL_GET(flags, channel_id) \
|
||||
channel_id = (gsl_channelid_t)((flags & GSL_MEMFLAGS_CHANNEL_MASK) >> GSL_MEMFLAGS_CHANNEL_SHIFT); \
|
||||
KOS_ASSERT(channel_id < GSL_CHANNEL_MAX);
|
||||
DEBUG_ASSERT(channel_id < GSL_CHANNEL_MAX);
|
||||
|
||||
#define GSL_MEMDESC_APERTURE_SET(memdesc, aperture_index) \
|
||||
memdesc->priv = (memdesc->priv & ~GSL_APERTURE_MASK) | ((aperture_index << GSL_APERTURE_SHIFT) & GSL_APERTURE_MASK);
|
||||
@@ -48,14 +49,14 @@
|
||||
memdesc->priv = (memdesc->priv & ~GSL_EXTALLOC_MASK) | ((flag << GSL_EXTALLOC_SHIFT) & GSL_EXTALLOC_MASK);
|
||||
|
||||
#define GSL_MEMDESC_APERTURE_GET(memdesc, aperture_index) \
|
||||
KOS_ASSERT(memdesc); \
|
||||
DEBUG_ASSERT(memdesc); \
|
||||
aperture_index = ((memdesc->priv & GSL_APERTURE_MASK) >> GSL_APERTURE_SHIFT); \
|
||||
KOS_ASSERT(aperture_index < GSL_SHMEM_MAX_APERTURES);
|
||||
DEBUG_ASSERT(aperture_index < GSL_SHMEM_MAX_APERTURES);
|
||||
|
||||
#define GSL_MEMDESC_DEVICE_GET(memdesc, device_id) \
|
||||
KOS_ASSERT(memdesc); \
|
||||
DEBUG_ASSERT(memdesc); \
|
||||
device_id = (gsl_deviceid_t)((memdesc->priv & GSL_DEVICEID_MASK) >> GSL_DEVICEID_SHIFT); \
|
||||
KOS_ASSERT(device_id <= GSL_DEVICE_MAX);
|
||||
DEBUG_ASSERT(device_id <= GSL_DEVICE_MAX);
|
||||
|
||||
#define GSL_MEMDESC_EXTALLOC_ISMARKED(memdesc) \
|
||||
((memdesc->priv & GSL_EXTALLOC_MASK) >> GSL_EXTALLOC_SHIFT)
|
||||
@@ -64,10 +65,10 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// aperture index in shared memory object
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
OSINLINE int
|
||||
static __inline int
|
||||
kgsl_sharedmem_getapertureindex(gsl_sharedmem_t *shmem, gsl_apertureid_t aperture_id, gsl_channelid_t channel_id)
|
||||
{
|
||||
KOS_ASSERT(shmem->aperturelookup[aperture_id][channel_id] < shmem->numapertures);
|
||||
DEBUG_ASSERT(shmem->aperturelookup[aperture_id][channel_id] < shmem->numapertures);
|
||||
|
||||
return (shmem->aperturelookup[aperture_id][channel_id]);
|
||||
}
|
||||
@@ -125,7 +126,7 @@ kgsl_sharedmem_init(gsl_sharedmem_t *shmem)
|
||||
}
|
||||
|
||||
// make sure aligned to page size
|
||||
KOS_ASSERT((gpubaseaddr & ((1 << GSL_PAGESIZE_SHIFT) - 1)) == 0);
|
||||
DEBUG_ASSERT((gpubaseaddr & ((1 << GSL_PAGESIZE_SHIFT) - 1)) == 0);
|
||||
|
||||
// make a multiple of page size
|
||||
sizebytes = (sizebytes & ~((1 << GSL_PAGESIZE_SHIFT) - 1));
|
||||
@@ -217,8 +218,8 @@ kgsl_sharedmem_alloc0(gsl_deviceid_t device_id, gsl_flags_t flags, int sizebytes
|
||||
"--> int kgsl_sharedmem_alloc(gsl_deviceid_t device_id=%D, gsl_flags_t flags=0x%08x, int sizebytes=%d, gsl_memdesc_t *memdesc=%M)\n",
|
||||
device_id, flags, sizebytes, memdesc );
|
||||
|
||||
KOS_ASSERT(sizebytes);
|
||||
KOS_ASSERT(memdesc);
|
||||
DEBUG_ASSERT(sizebytes);
|
||||
DEBUG_ASSERT(memdesc);
|
||||
|
||||
GSL_MEMFLAGS_APERTURE_GET(flags, aperture_id);
|
||||
GSL_MEMFLAGS_CHANNEL_GET(flags, channel_id);
|
||||
@@ -270,7 +271,7 @@ kgsl_sharedmem_alloc0(gsl_deviceid_t device_id, gsl_flags_t flags, int sizebytes
|
||||
}
|
||||
}
|
||||
|
||||
KOS_ASSERT(device_id > GSL_DEVICE_ANY && device_id <= GSL_DEVICE_MAX);
|
||||
DEBUG_ASSERT(device_id > GSL_DEVICE_ANY && device_id <= GSL_DEVICE_MAX);
|
||||
|
||||
// get mmu reference
|
||||
mmu = &gsl_driver.device[device_id-1].mmu;
|
||||
@@ -356,7 +357,7 @@ kgsl_sharedmem_alloc0(gsl_deviceid_t device_id, gsl_flags_t flags, int sizebytes
|
||||
result = kgsl_hal_allocphysical(memdesc->gpuaddr, scatterlist.num, scatterlist.pages);
|
||||
if (result == GSL_SUCCESS)
|
||||
{
|
||||
result = kgsl_mmu_map(mmu, memdesc->gpuaddr, &scatterlist, flags, GSL_CALLER_PROCESSID_GET());
|
||||
result = kgsl_mmu_map(mmu, memdesc->gpuaddr, &scatterlist, flags, current->tgid);
|
||||
if (result != GSL_SUCCESS)
|
||||
{
|
||||
kgsl_hal_freephysical(memdesc->gpuaddr, scatterlist.num, scatterlist.pages);
|
||||
@@ -386,13 +387,13 @@ kgsl_sharedmem_alloc0(gsl_deviceid_t device_id, gsl_flags_t flags, int sizebytes
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_alloc(gsl_deviceid_t device_id, gsl_flags_t flags, int sizebytes, gsl_memdesc_t *memdesc)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
status = kgsl_sharedmem_alloc0(device_id, flags, sizebytes, memdesc);
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -442,14 +443,14 @@ kgsl_sharedmem_free0(gsl_memdesc_t *memdesc, unsigned int pid)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_free(gsl_memdesc_t *memdesc)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
status = kgsl_sharedmem_free0(memdesc, GSL_CALLER_PROCESSID_GET());
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
return status;
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
status = kgsl_sharedmem_free0(memdesc, current->tgid);
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -482,8 +483,8 @@ kgsl_sharedmem_read0(const gsl_memdesc_t *memdesc, void *dst, unsigned int offse
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
KOS_ASSERT(dst);
|
||||
KOS_ASSERT(sizebytes);
|
||||
DEBUG_ASSERT(dst);
|
||||
DEBUG_ASSERT(sizebytes);
|
||||
|
||||
if (memdesc->gpuaddr < shmem->apertures[aperture_index].memarena->gpubaseaddr)
|
||||
{
|
||||
@@ -506,13 +507,13 @@ kgsl_sharedmem_read0(const gsl_memdesc_t *memdesc, void *dst, unsigned int offse
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_read(const gsl_memdesc_t *memdesc, void *dst, unsigned int offsetbytes, unsigned int sizebytes, unsigned int touserspace)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
status = kgsl_sharedmem_read0(memdesc, dst, offsetbytes, sizebytes, touserspace);
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -546,10 +547,10 @@ kgsl_sharedmem_write0(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, vo
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
KOS_ASSERT(src);
|
||||
KOS_ASSERT(sizebytes);
|
||||
KOS_ASSERT(memdesc->gpuaddr >= shmem->apertures[aperture_index].memarena->gpubaseaddr);
|
||||
KOS_ASSERT((memdesc->gpuaddr + sizebytes) <= (shmem->apertures[aperture_index].memarena->gpubaseaddr + shmem->apertures[aperture_index].memarena->sizebytes));
|
||||
DEBUG_ASSERT(src);
|
||||
DEBUG_ASSERT(sizebytes);
|
||||
DEBUG_ASSERT(memdesc->gpuaddr >= shmem->apertures[aperture_index].memarena->gpubaseaddr);
|
||||
DEBUG_ASSERT((memdesc->gpuaddr + sizebytes) <= (shmem->apertures[aperture_index].memarena->gpubaseaddr + shmem->apertures[aperture_index].memarena->sizebytes));
|
||||
|
||||
gpuoffsetbytes = (memdesc->gpuaddr - shmem->apertures[aperture_index].memarena->gpubaseaddr) + offsetbytes;
|
||||
|
||||
@@ -566,13 +567,13 @@ kgsl_sharedmem_write0(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, vo
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_write(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, void *src, unsigned int sizebytes, unsigned int fromuserspace)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
status = kgsl_sharedmem_write0(memdesc, offsetbytes, src, sizebytes, fromuserspace);
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -606,9 +607,9 @@ kgsl_sharedmem_set0(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsi
|
||||
return (GSL_FAILURE);
|
||||
}
|
||||
|
||||
KOS_ASSERT(sizebytes);
|
||||
KOS_ASSERT(memdesc->gpuaddr >= shmem->apertures[aperture_index].memarena->gpubaseaddr);
|
||||
KOS_ASSERT((memdesc->gpuaddr + sizebytes) <= (shmem->apertures[aperture_index].memarena->gpubaseaddr + shmem->apertures[aperture_index].memarena->sizebytes));
|
||||
DEBUG_ASSERT(sizebytes);
|
||||
DEBUG_ASSERT(memdesc->gpuaddr >= shmem->apertures[aperture_index].memarena->gpubaseaddr);
|
||||
DEBUG_ASSERT((memdesc->gpuaddr + sizebytes) <= (shmem->apertures[aperture_index].memarena->gpubaseaddr + shmem->apertures[aperture_index].memarena->sizebytes));
|
||||
|
||||
gpuoffsetbytes = (memdesc->gpuaddr - shmem->apertures[aperture_index].memarena->gpubaseaddr) + offsetbytes;
|
||||
|
||||
@@ -625,19 +626,19 @@ kgsl_sharedmem_set0(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsi
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_set(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int value, unsigned int sizebytes)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
status = kgsl_sharedmem_set0(memdesc, offsetbytes, value, sizebytes);
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API unsigned int
|
||||
unsigned int
|
||||
kgsl_sharedmem_largestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
{
|
||||
gsl_apertureid_t aperture_id;
|
||||
@@ -658,14 +659,14 @@ kgsl_sharedmem_largestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
GSL_MEMFLAGS_APERTURE_GET(flags, aperture_id);
|
||||
GSL_MEMFLAGS_CHANNEL_GET(flags, channel_id);
|
||||
|
||||
GSL_API_MUTEX_LOCK();
|
||||
mutex_lock(&gsl_driver.lock);
|
||||
|
||||
shmem = &gsl_driver.shmem;
|
||||
|
||||
if (!(shmem->flags & GSL_FLAGS_INITIALIZED))
|
||||
{
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_ERROR, "ERROR: Shared memory not initialized.\n" );
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_sharedmem_largestfreeblock. Return value %d\n", 0 );
|
||||
return (0);
|
||||
}
|
||||
@@ -677,7 +678,7 @@ kgsl_sharedmem_largestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
result = kgsl_memarena_getlargestfreeblock(shmem->apertures[aperture_index].memarena, flags);
|
||||
}
|
||||
|
||||
GSL_API_MUTEX_UNLOCK();
|
||||
mutex_unlock(&gsl_driver.lock);
|
||||
|
||||
kgsl_log_write( KGSL_LOG_GROUP_MEMORY | KGSL_LOG_LEVEL_TRACE, "<-- kgsl_sharedmem_largestfreeblock. Return value %d\n", result );
|
||||
|
||||
@@ -686,7 +687,7 @@ kgsl_sharedmem_largestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_map(gsl_deviceid_t device_id, gsl_flags_t flags, const gsl_scatterlist_t *scatterlist, gsl_memdesc_t *memdesc)
|
||||
{
|
||||
int status = GSL_FAILURE;
|
||||
@@ -736,7 +737,7 @@ kgsl_sharedmem_map(gsl_deviceid_t device_id, gsl_flags_t flags, const gsl_scatte
|
||||
}
|
||||
}
|
||||
|
||||
KOS_ASSERT(device_id > GSL_DEVICE_ANY && device_id <= GSL_DEVICE_MAX);
|
||||
DEBUG_ASSERT(device_id > GSL_DEVICE_ANY && device_id <= GSL_DEVICE_MAX);
|
||||
|
||||
if (shmem->flags & GSL_FLAGS_INITIALIZED)
|
||||
{
|
||||
@@ -744,8 +745,8 @@ kgsl_sharedmem_map(gsl_deviceid_t device_id, gsl_flags_t flags, const gsl_scatte
|
||||
|
||||
if (kgsl_memarena_isvirtualized(shmem->apertures[aperture_index].memarena))
|
||||
{
|
||||
KOS_ASSERT(scatterlist->num);
|
||||
KOS_ASSERT(scatterlist->pages);
|
||||
DEBUG_ASSERT(scatterlist->num);
|
||||
DEBUG_ASSERT(scatterlist->pages);
|
||||
|
||||
status = kgsl_memarena_alloc(shmem->apertures[aperture_index].memarena, flags, scatterlist->num *GSL_PAGESIZE, memdesc);
|
||||
if (status == GSL_SUCCESS)
|
||||
@@ -756,7 +757,7 @@ kgsl_sharedmem_map(gsl_deviceid_t device_id, gsl_flags_t flags, const gsl_scatte
|
||||
// mark descriptor's memory as externally allocated -- i.e. outside GSL
|
||||
GSL_MEMDESC_EXTALLOC_SET(memdesc, 1);
|
||||
|
||||
status = kgsl_mmu_map(&gsl_driver.device[device_id-1].mmu, memdesc->gpuaddr, scatterlist, flags, GSL_CALLER_PROCESSID_GET());
|
||||
status = kgsl_mmu_map(&gsl_driver.device[device_id-1].mmu, memdesc->gpuaddr, scatterlist, flags, current->tgid);
|
||||
if (status != GSL_SUCCESS)
|
||||
{
|
||||
kgsl_memarena_free(shmem->apertures[aperture_index].memarena, memdesc);
|
||||
@@ -772,15 +773,15 @@ kgsl_sharedmem_map(gsl_deviceid_t device_id, gsl_flags_t flags, const gsl_scatte
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_unmap(gsl_memdesc_t *memdesc)
|
||||
{
|
||||
return (kgsl_sharedmem_free0(memdesc, GSL_CALLER_PROCESSID_GET()));
|
||||
return (kgsl_sharedmem_free0(memdesc, current->tgid));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_getmap(const gsl_memdesc_t *memdesc, gsl_scatterlist_t *scatterlist)
|
||||
{
|
||||
int status = GSL_SUCCESS;
|
||||
@@ -799,16 +800,16 @@ kgsl_sharedmem_getmap(const gsl_memdesc_t *memdesc, gsl_scatterlist_t *scatterli
|
||||
|
||||
if (shmem->flags & GSL_FLAGS_INITIALIZED)
|
||||
{
|
||||
KOS_ASSERT(scatterlist->num);
|
||||
KOS_ASSERT(scatterlist->pages);
|
||||
KOS_ASSERT(memdesc->gpuaddr >= shmem->apertures[aperture_index].memarena->gpubaseaddr);
|
||||
KOS_ASSERT((memdesc->gpuaddr + memdesc->size) <= (shmem->apertures[aperture_index].memarena->gpubaseaddr + shmem->apertures[aperture_index].memarena->sizebytes));
|
||||
DEBUG_ASSERT(scatterlist->num);
|
||||
DEBUG_ASSERT(scatterlist->pages);
|
||||
DEBUG_ASSERT(memdesc->gpuaddr >= shmem->apertures[aperture_index].memarena->gpubaseaddr);
|
||||
DEBUG_ASSERT((memdesc->gpuaddr + memdesc->size) <= (shmem->apertures[aperture_index].memarena->gpubaseaddr + shmem->apertures[aperture_index].memarena->sizebytes));
|
||||
|
||||
memset(scatterlist->pages, 0, sizeof(unsigned int) * scatterlist->num);
|
||||
|
||||
if (kgsl_memarena_isvirtualized(shmem->apertures[aperture_index].memarena))
|
||||
{
|
||||
status = kgsl_mmu_getmap(&gsl_driver.device[device_id-1].mmu, memdesc->gpuaddr, memdesc->size, scatterlist, GSL_CALLER_PROCESSID_GET());
|
||||
status = kgsl_mmu_getmap(&gsl_driver.device[device_id-1].mmu, memdesc->gpuaddr, memdesc->size, scatterlist, current->tgid);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -832,7 +833,7 @@ kgsl_sharedmem_querystats(gsl_sharedmem_t *shmem, gsl_sharedmem_stats_t *stats)
|
||||
int status = GSL_SUCCESS;
|
||||
int i;
|
||||
|
||||
KOS_ASSERT(stats);
|
||||
DEBUG_ASSERT(stats);
|
||||
|
||||
if (shmem->flags & GSL_FLAGS_INITIALIZED)
|
||||
{
|
||||
@@ -906,7 +907,7 @@ kgsl_sharedmem_convertaddr(unsigned int addr, int type)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_cacheoperation(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int sizebytes, unsigned int operation)
|
||||
{
|
||||
int status = GSL_FAILURE;
|
||||
@@ -924,7 +925,7 @@ kgsl_sharedmem_cacheoperation(const gsl_memdesc_t *memdesc, unsigned int offsetb
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_sharedmem_fromhostpointer(gsl_deviceid_t device_id, gsl_memdesc_t *memdesc, void* hostptr)
|
||||
{
|
||||
int status = GSL_FAILURE;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_tbdump.h"
|
||||
#include "kos_libapi.h"
|
||||
|
||||
#ifdef TBDUMP
|
||||
|
||||
@@ -31,9 +30,7 @@ typedef struct TBDump_
|
||||
|
||||
|
||||
static TBDump g_tb;
|
||||
static oshandle_t tbdump_mutex = 0;
|
||||
#define TBDUMP_MUTEX_LOCK() if( tbdump_mutex ) kos_mutex_lock( tbdump_mutex )
|
||||
#define TBDUMP_MUTEX_UNLOCK() if( tbdump_mutex ) kos_mutex_unlock( tbdump_mutex )
|
||||
static struct mutex *tbdump_mutex = NULL;
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
@@ -74,7 +71,11 @@ static void tbdump_getmemhex(char* buffer, unsigned int addr, unsigned int sizew
|
||||
|
||||
void tbdump_open(char* filename)
|
||||
{
|
||||
if( !tbdump_mutex ) tbdump_mutex = kos_mutex_create( "TBDUMP_MUTEX" );
|
||||
if( !tbdump_mutex ) {
|
||||
tbdump_mutex = (struct mutex *) kmalloc(sizeof(struct mutex), GFP_KERNEL);
|
||||
if (tbdump_mutex)
|
||||
mutex_init(tbdump_mutex);
|
||||
}
|
||||
|
||||
memset( &g_tb, 0, sizeof( g_tb ) );
|
||||
|
||||
@@ -90,14 +91,16 @@ void tbdump_open(char* filename)
|
||||
|
||||
void tbdump_close()
|
||||
{
|
||||
TBDUMP_MUTEX_LOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_lock(tbdump_mutex);
|
||||
|
||||
kos_fclose( g_tb.file );
|
||||
g_tb.file = 0;
|
||||
|
||||
TBDUMP_MUTEX_UNLOCK();
|
||||
|
||||
if( tbdump_mutex ) kos_mutex_free( tbdump_mutex );
|
||||
if( tbdump_mutex ) {
|
||||
mutex_unlock(tbdump_mutex);
|
||||
kfree( tbdump_mutex );
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
@@ -109,7 +112,8 @@ void tbdump_syncmem(unsigned int addr, unsigned int src, unsigned int sizebytes)
|
||||
unsigned int end = addr+sizebytes;
|
||||
char buffer[65];
|
||||
|
||||
TBDUMP_MUTEX_LOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_lock(tbdump_mutex);
|
||||
|
||||
beg = (beg+15) & ~15;
|
||||
end &= ~15;
|
||||
@@ -120,7 +124,8 @@ void tbdump_syncmem(unsigned int addr, unsigned int src, unsigned int sizebytes)
|
||||
|
||||
tbdump_printline("19 %08x %i 1 %s", addr, sizebytes, buffer);
|
||||
|
||||
TBDUMP_MUTEX_UNLOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_unlock(tbdump_mutex);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -153,40 +158,46 @@ void tbdump_syncmem(unsigned int addr, unsigned int src, unsigned int sizebytes)
|
||||
tbdump_printline("19 %08x %i 1 %s", end, (addr+sizebytes)-end, buffer);
|
||||
}
|
||||
|
||||
TBDUMP_MUTEX_UNLOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_unlock(tbdump_mutex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void tbdump_setmem(unsigned int addr, unsigned int value, unsigned int sizebytes)
|
||||
{
|
||||
TBDUMP_MUTEX_LOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_lock(tbdump_mutex);
|
||||
|
||||
tbdump_printline("19 %08x 4 %i %032x", addr, (sizebytes+3)/4, value );
|
||||
|
||||
TBDUMP_MUTEX_UNLOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_unlock(tbdump_mutex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void tbdump_slavewrite(unsigned int addr, unsigned int value)
|
||||
{
|
||||
TBDUMP_MUTEX_LOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_lock(tbdump_mutex);
|
||||
|
||||
tbdump_printline("1 %08x %08x", addr, value);
|
||||
|
||||
TBDUMP_MUTEX_UNLOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_unlock(tbdump_mutex);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_tbdump_waitirq()
|
||||
{
|
||||
if(!g_tb.file) return GSL_FAILURE;
|
||||
|
||||
TBDUMP_MUTEX_LOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_lock(tbdump_mutex);
|
||||
|
||||
tbdump_printinfo("wait irq");
|
||||
tbdump_printline("10");
|
||||
@@ -195,14 +206,15 @@ kgsl_tbdump_waitirq()
|
||||
tbdump_printline("1 00000418 00000003");
|
||||
tbdump_printline("18 00000018 00000000 # slave read & assert");
|
||||
|
||||
TBDUMP_MUTEX_UNLOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_unlock(tbdump_mutex);
|
||||
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
KGSL_API int
|
||||
int
|
||||
kgsl_tbdump_exportbmp(const void* addr, unsigned int format, unsigned int stride, unsigned int width, unsigned int height)
|
||||
{
|
||||
static char filename[20];
|
||||
@@ -210,13 +222,16 @@ kgsl_tbdump_exportbmp(const void* addr, unsigned int format, unsigned int stride
|
||||
|
||||
if(!g_tb.file) return GSL_FAILURE;
|
||||
|
||||
TBDUMP_MUTEX_LOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_lock(tbdump_mutex);
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
sprintf( filename, "tbdump_%08d.bmp", numframe++ );
|
||||
|
||||
tbdump_printline("13 %s %d %08x %d %d %d 0", filename, format, (unsigned int)addr, stride, width, height);
|
||||
|
||||
TBDUMP_MUTEX_UNLOCK();
|
||||
if (tbdump_mutex)
|
||||
mutex_unlock(tbdump_mutex);
|
||||
|
||||
return GSL_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ kgsl_yamato_gmeminit(gsl_device_t *device)
|
||||
unsigned int edram_value = 0;
|
||||
|
||||
// make sure edram range is aligned to size
|
||||
KOS_ASSERT((device->gmemspace.gpu_base & (device->gmemspace.sizebytes - 1)) == 0);
|
||||
DEBUG_ASSERT((device->gmemspace.gpu_base & (device->gmemspace.sizebytes - 1)) == 0);
|
||||
|
||||
// get edram_size value equivalent
|
||||
gmem_size = (device->gmemspace.sizebytes >> 14);
|
||||
@@ -86,7 +86,7 @@ kgsl_yamato_rbbmintrcallback(gsl_intrid_t id, void *cookie)
|
||||
case GSL_INTR_YDX_RBBM_DISPLAY_UPDATE:
|
||||
case GSL_INTR_YDX_RBBM_GUI_IDLE:
|
||||
|
||||
kos_event_signal(device->intr.evnt[id]);
|
||||
complete_all(&device->intr.evnt[id]);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -159,7 +159,7 @@ kgsl_yamato_bist(gsl_device_t *device)
|
||||
// interrupt bist
|
||||
link[0] = pm4_type3_packet(PM4_INTERRUPT, 1);
|
||||
link[1] = CP_INT_CNTL__RB_INT_MASK;
|
||||
kgsl_ringbuffer_issuecmds(device, 1, &link[0], 2, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_ringbuffer_issuecmds(device, 1, &link[0], 2, current->tgid);
|
||||
|
||||
status = kgsl_mmu_bist(&device->mmu);
|
||||
if (status != GSL_SUCCESS)
|
||||
@@ -401,7 +401,7 @@ kgsl_yamato_destroy(gsl_device_t *device)
|
||||
|
||||
#ifdef _DEBUG
|
||||
// for now, signal catastrophic failure in a brute force way
|
||||
KOS_ASSERT(0);
|
||||
DEBUG_ASSERT(0);
|
||||
#endif // _DEBUG
|
||||
|
||||
// todo: - hard reset core?
|
||||
@@ -498,7 +498,7 @@ kgsl_yamato_stop(gsl_device_t *device)
|
||||
unsigned int cmds[2];
|
||||
cmds[0] = pm4_type3_packet(PM4_WAIT_FOR_IDLE, 1);
|
||||
cmds[0] = 0;
|
||||
kgsl_ringbuffer_issuecmds(device, 0, cmds, 2, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_ringbuffer_issuecmds(device, 0, cmds, 2, current->tgid);
|
||||
|
||||
// disable rbbm interrupts
|
||||
kgsl_intr_detach(&device->intr, GSL_INTR_YDX_RBBM_READ_ERROR);
|
||||
@@ -545,7 +545,7 @@ kgsl_yamato_getproperty(gsl_device_t *device, gsl_property_type_t type, void *va
|
||||
{
|
||||
gsl_devinfo_t *devinfo = (gsl_devinfo_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == sizeof(gsl_devinfo_t));
|
||||
DEBUG_ASSERT(sizebytes == sizeof(gsl_devinfo_t));
|
||||
|
||||
devinfo->device_id = device->id;
|
||||
devinfo->chip_id = (gsl_chipid_t)device->chip_id;
|
||||
@@ -576,7 +576,7 @@ kgsl_yamato_setproperty(gsl_device_t *device, gsl_property_type_t type, void *va
|
||||
{
|
||||
gsl_powerprop_t *power = (gsl_powerprop_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == sizeof(gsl_powerprop_t));
|
||||
DEBUG_ASSERT(sizebytes == sizeof(gsl_powerprop_t));
|
||||
|
||||
if (!(device->flags & GSL_FLAGS_SAFEMODE))
|
||||
{
|
||||
@@ -602,7 +602,7 @@ kgsl_yamato_setproperty(gsl_device_t *device, gsl_property_type_t type, void *va
|
||||
{
|
||||
gsl_dmiprop_t *dmi = (gsl_dmiprop_t *) value;
|
||||
|
||||
KOS_ASSERT(sizebytes == sizeof(gsl_dmiprop_t));
|
||||
DEBUG_ASSERT(sizebytes == sizeof(gsl_dmiprop_t));
|
||||
|
||||
//
|
||||
// In order to enable DMI, it must not already be enabled.
|
||||
@@ -716,7 +716,7 @@ kgsl_yamato_setproperty(gsl_device_t *device, gsl_property_type_t type, void *va
|
||||
}
|
||||
|
||||
// issue the commands
|
||||
kgsl_ringbuffer_issuecmds(device, 1, &cmdbuf[0], size, GSL_CALLER_PROCESSID_GET());
|
||||
kgsl_ringbuffer_issuecmds(device, 1, &cmdbuf[0], size, current->tgid);
|
||||
|
||||
gsl_driver.dmi_frame %= gsl_driver.dmi_max_frame;
|
||||
status = GSL_SUCCESS;
|
||||
@@ -744,8 +744,6 @@ kgsl_yamato_idle(gsl_device_t *device, unsigned int timeout)
|
||||
|
||||
KGSL_DEBUG(GSL_DBGFLAGS_DUMPX, KGSL_DEBUG_DUMPX(BB_DUMP_REGPOLL, device->id, mmRBBM_STATUS, 0x80000000, "kgsl_yamato_idle"));
|
||||
|
||||
GSL_RB_MUTEX_LOCK();
|
||||
|
||||
// first, wait until the CP has consumed all the commands in the ring buffer
|
||||
if (rb->flags & GSL_FLAGS_STARTED)
|
||||
{
|
||||
@@ -768,8 +766,6 @@ kgsl_yamato_idle(gsl_device_t *device, unsigned int timeout)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GSL_RB_MUTEX_UNLOCK();
|
||||
|
||||
return (status);
|
||||
}
|
||||
@@ -827,7 +823,14 @@ kgsl_yamato_waitirq(gsl_device_t *device, gsl_intrid_t intr_id, unsigned int *co
|
||||
if (kgsl_intr_isenabled(&device->intr, intr_id) == GSL_SUCCESS)
|
||||
{
|
||||
// wait until intr completion event is received
|
||||
if (kos_event_wait(device->intr.evnt[intr_id], timeout) == OS_SUCCESS)
|
||||
int complete = OS_SUCCESS;
|
||||
|
||||
if (timeout != OS_INFINITE)
|
||||
complete = wait_for_completion_timeout(&device->intr.evnt[intr_id], msecs_to_jiffies(timeout));
|
||||
else
|
||||
wait_for_completion_killable(&device->intr.evnt[intr_id]);
|
||||
|
||||
if (complete == OS_SUCCESS)
|
||||
{
|
||||
*count = 1;
|
||||
status = GSL_SUCCESS;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __GSL_DISPLAYAPI_H
|
||||
#define __GSL_DISPLAYAPI_H
|
||||
|
||||
@@ -33,19 +33,7 @@
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// entrypoints
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __GSLDISPLAY_EXPORTS
|
||||
#define DISP_API OS_DLLEXPORT
|
||||
#else
|
||||
#define DISP_API OS_DLLIMPORT
|
||||
#endif // __GSLDISPLAY_EXPORTS
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
#define GSL_DISPLAY_PANEL_TOSHIBA_640x480 0
|
||||
#define GSL_DISPLAY_PANEL_HITACHI_240x320 1
|
||||
#define GSL_DISPLAY_PANEL_DEFAULT GSL_DISPLAY_PANEL_TOSHIBA_640x480
|
||||
@@ -70,14 +58,14 @@ typedef struct _gsl_displaymode_t {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// prototypes
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
DISP_API gsl_display_id_t gsl_display_open(gsl_devhandle_t devhandle, int panel_id);
|
||||
DISP_API int gsl_display_close(gsl_display_id_t display_id);
|
||||
DISP_API int gsl_display_getcount(void);
|
||||
DISP_API int gsl_display_setmode(gsl_display_id_t display_id, gsl_displaymode_t displaymode);
|
||||
DISP_API int gsl_display_getmode(gsl_display_id_t display_id, gsl_displaymode_t *displaymode);
|
||||
DISP_API gsl_surface_id_t gsl_display_setsurface(gsl_display_id_t display_id, void *buffer);
|
||||
DISP_API int gsl_display_getactivesurface(gsl_display_id_t display_id, void **buffer);
|
||||
DISP_API int gsl_display_flipsurface(gsl_display_id_t display_id, gsl_surface_id_t surface_id);
|
||||
extern gsl_display_id_t gsl_display_open(gsl_devhandle_t devhandle, int panel_id);
|
||||
extern int gsl_display_close(gsl_display_id_t display_id);
|
||||
extern int gsl_display_getcount(void);
|
||||
extern int gsl_display_setmode(gsl_display_id_t display_id, gsl_displaymode_t displaymode);
|
||||
extern int gsl_display_getmode(gsl_display_id_t display_id, gsl_displaymode_t *displaymode);
|
||||
extern gsl_surface_id_t gsl_display_setsurface(gsl_display_id_t display_id, void *buffer);
|
||||
extern int gsl_display_getactivesurface(gsl_display_id_t display_id, void **buffer);
|
||||
extern int gsl_display_flipsurface(gsl_display_id_t display_id, gsl_surface_id_t surface_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -36,23 +36,8 @@ extern "C" {
|
||||
#include "gsl_types.h"
|
||||
#include "gsl_properties.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// entrypoints
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __KGSLLIB_EXPORTS
|
||||
#define KGSL_API OS_DLLEXPORT
|
||||
#else
|
||||
#ifdef __KERNEL_MODE__
|
||||
#define KGSL_API extern
|
||||
#else
|
||||
#define KGSL_API OS_DLLIMPORT
|
||||
#endif
|
||||
#endif // __KGSLLIB_EXPORTS
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// version control
|
||||
// version control
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#define KGSLLIB_NAME "AMD GSL Kernel Library"
|
||||
#define KGSLLIB_VERSION "0.1"
|
||||
@@ -61,73 +46,73 @@ extern "C" {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// library API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API int kgsl_driver_init(void);
|
||||
KGSL_API int kgsl_driver_close(void);
|
||||
KGSL_API int kgsl_driver_entry(gsl_flags_t flags);
|
||||
KGSL_API int kgsl_driver_exit(void);
|
||||
KGSL_API int kgsl_driver_destroy(unsigned int pid);
|
||||
int kgsl_driver_init(void);
|
||||
int kgsl_driver_close(void);
|
||||
int kgsl_driver_entry(gsl_flags_t flags);
|
||||
int kgsl_driver_exit(void);
|
||||
int kgsl_driver_destroy(unsigned int pid);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// device API
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API int kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
KGSL_API int kgsl_device_stop(gsl_deviceid_t device_id);
|
||||
KGSL_API int kgsl_device_idle(gsl_deviceid_t device_id, unsigned int timeout);
|
||||
KGSL_API int kgsl_device_isidle(gsl_deviceid_t device_id);
|
||||
KGSL_API int kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
KGSL_API int kgsl_device_setproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
KGSL_API int kgsl_device_regread(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned int *value);
|
||||
KGSL_API int kgsl_device_regwrite(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned int value);
|
||||
KGSL_API int kgsl_device_waitirq(gsl_deviceid_t device_id, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout);
|
||||
int kgsl_device_start(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
int kgsl_device_stop(gsl_deviceid_t device_id);
|
||||
int kgsl_device_idle(gsl_deviceid_t device_id, unsigned int timeout);
|
||||
int kgsl_device_isidle(gsl_deviceid_t device_id);
|
||||
int kgsl_device_getproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
int kgsl_device_setproperty(gsl_deviceid_t device_id, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
int kgsl_device_regread(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned int *value);
|
||||
int kgsl_device_regwrite(gsl_deviceid_t device_id, unsigned int offsetwords, unsigned int value);
|
||||
int kgsl_device_waitirq(gsl_deviceid_t device_id, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// command API
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API int kgsl_cmdstream_issueibcmds(gsl_deviceid_t device_id, int drawctxt_index, gpuaddr_t ibaddr, int sizedwords, gsl_timestamp_t *timestamp, gsl_flags_t flags);
|
||||
KGSL_API gsl_timestamp_t kgsl_cmdstream_readtimestamp(gsl_deviceid_t device_id, gsl_timestamp_type_t type);
|
||||
KGSL_API int kgsl_cmdstream_freememontimestamp(gsl_deviceid_t device_id, gsl_memdesc_t *memdesc, gsl_timestamp_t timestamp, gsl_timestamp_type_t type);
|
||||
KGSL_API int kgsl_cmdstream_waittimestamp(gsl_deviceid_t device_id, gsl_timestamp_t timestamp, unsigned int timeout);
|
||||
KGSL_API int kgsl_cmdwindow_write(gsl_deviceid_t device_id, gsl_cmdwindow_t target, unsigned int addr, unsigned int data);
|
||||
KGSL_API int kgsl_add_timestamp(gsl_deviceid_t device_id, gsl_timestamp_t *timestamp);
|
||||
KGSL_API int kgsl_cmdstream_check_timestamp(gsl_deviceid_t device_id, gsl_timestamp_t timestamp);
|
||||
int kgsl_cmdstream_issueibcmds(gsl_deviceid_t device_id, int drawctxt_index, gpuaddr_t ibaddr, int sizedwords, gsl_timestamp_t *timestamp, gsl_flags_t flags);
|
||||
gsl_timestamp_t kgsl_cmdstream_readtimestamp(gsl_deviceid_t device_id, gsl_timestamp_type_t type);
|
||||
int kgsl_cmdstream_freememontimestamp(gsl_deviceid_t device_id, gsl_memdesc_t *memdesc, gsl_timestamp_t timestamp, gsl_timestamp_type_t type);
|
||||
int kgsl_cmdstream_waittimestamp(gsl_deviceid_t device_id, gsl_timestamp_t timestamp, unsigned int timeout);
|
||||
int kgsl_cmdwindow_write(gsl_deviceid_t device_id, gsl_cmdwindow_t target, unsigned int addr, unsigned int data);
|
||||
int kgsl_add_timestamp(gsl_deviceid_t device_id, gsl_timestamp_t *timestamp);
|
||||
int kgsl_cmdstream_check_timestamp(gsl_deviceid_t device_id, gsl_timestamp_t timestamp);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// context API
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API int kgsl_context_create(gsl_deviceid_t device_id, gsl_context_type_t type, unsigned int *drawctxt_id, gsl_flags_t flags);
|
||||
KGSL_API int kgsl_context_destroy(gsl_deviceid_t device_id, unsigned int drawctxt_id);
|
||||
KGSL_API int kgsl_drawctxt_bind_gmem_shadow(gsl_deviceid_t device_id, unsigned int drawctxt_id, const gsl_rect_t* gmem_rect, unsigned int shadow_x, unsigned int shadow_y, const gsl_buffer_desc_t* shadow_buffer, unsigned int buffer_id);
|
||||
int kgsl_context_create(gsl_deviceid_t device_id, gsl_context_type_t type, unsigned int *drawctxt_id, gsl_flags_t flags);
|
||||
int kgsl_context_destroy(gsl_deviceid_t device_id, unsigned int drawctxt_id);
|
||||
int kgsl_drawctxt_bind_gmem_shadow(gsl_deviceid_t device_id, unsigned int drawctxt_id, const gsl_rect_t* gmem_rect, unsigned int shadow_x, unsigned int shadow_y, const gsl_buffer_desc_t* shadow_buffer, unsigned int buffer_id);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// sharedmem API
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API int kgsl_sharedmem_alloc(gsl_deviceid_t device_id, gsl_flags_t flags, int sizebytes, gsl_memdesc_t *memdesc);
|
||||
KGSL_API int kgsl_sharedmem_free(gsl_memdesc_t *memdesc);
|
||||
KGSL_API int kgsl_sharedmem_read(const gsl_memdesc_t *memdesc, void *dst, unsigned int offsetbytes, unsigned int sizebytes, unsigned int touserspace);
|
||||
KGSL_API int kgsl_sharedmem_write(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, void *src, unsigned int sizebytes, unsigned int fromuserspace);
|
||||
KGSL_API int kgsl_sharedmem_set(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int value, unsigned int sizebytes);
|
||||
KGSL_API unsigned int kgsl_sharedmem_largestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
KGSL_API int kgsl_sharedmem_map(gsl_deviceid_t device_id, gsl_flags_t flags, const gsl_scatterlist_t *scatterlist, gsl_memdesc_t *memdesc);
|
||||
KGSL_API int kgsl_sharedmem_unmap(gsl_memdesc_t *memdesc);
|
||||
KGSL_API int kgsl_sharedmem_getmap(const gsl_memdesc_t *memdesc, gsl_scatterlist_t *scatterlist);
|
||||
KGSL_API int kgsl_sharedmem_cacheoperation(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int sizebytes, unsigned int operation);
|
||||
KGSL_API int kgsl_sharedmem_fromhostpointer(gsl_deviceid_t device_id, gsl_memdesc_t *memdesc, void* hostptr);
|
||||
int kgsl_sharedmem_alloc(gsl_deviceid_t device_id, gsl_flags_t flags, int sizebytes, gsl_memdesc_t *memdesc);
|
||||
int kgsl_sharedmem_free(gsl_memdesc_t *memdesc);
|
||||
int kgsl_sharedmem_read(const gsl_memdesc_t *memdesc, void *dst, unsigned int offsetbytes, unsigned int sizebytes, unsigned int touserspace);
|
||||
int kgsl_sharedmem_write(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, void *src, unsigned int sizebytes, unsigned int fromuserspace);
|
||||
int kgsl_sharedmem_set(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int value, unsigned int sizebytes);
|
||||
unsigned int kgsl_sharedmem_largestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
int kgsl_sharedmem_map(gsl_deviceid_t device_id, gsl_flags_t flags, const gsl_scatterlist_t *scatterlist, gsl_memdesc_t *memdesc);
|
||||
int kgsl_sharedmem_unmap(gsl_memdesc_t *memdesc);
|
||||
int kgsl_sharedmem_getmap(const gsl_memdesc_t *memdesc, gsl_scatterlist_t *scatterlist);
|
||||
int kgsl_sharedmem_cacheoperation(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int sizebytes, unsigned int operation);
|
||||
int kgsl_sharedmem_fromhostpointer(gsl_deviceid_t device_id, gsl_memdesc_t *memdesc, void* hostptr);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// interrupt API
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API void kgsl_intr_isr(gsl_device_t *device);
|
||||
void kgsl_intr_isr(gsl_device_t *device);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// TB dump API
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
KGSL_API int kgsl_tbdump_waitirq(void);
|
||||
KGSL_API int kgsl_tbdump_exportbmp(const void* addr, unsigned int format, unsigned int stride, unsigned int width, unsigned int height);
|
||||
int kgsl_tbdump_waitirq(void);
|
||||
int kgsl_tbdump_exportbmp(const void* addr, unsigned int format, unsigned int stride, unsigned int width, unsigned int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -35,106 +35,67 @@ extern "C" {
|
||||
|
||||
#include "gsl_types.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// entrypoints
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __GSLLIB_EXPORTS
|
||||
#define GSL_API OS_DLLEXPORT
|
||||
#else
|
||||
#define GSL_API OS_DLLIMPORT
|
||||
#endif // __GSLLIB_EXPORTS
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
#define GSLLIB_NAME "AMD GSL User Library"
|
||||
#define GSLLIB_VERSION "0.1"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// libary API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API int gsl_library_open(gsl_flags_t flags);
|
||||
GSL_API int gsl_library_close(void);
|
||||
int gsl_library_open(gsl_flags_t flags);
|
||||
int gsl_library_close(void);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// device API
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API gsl_devhandle_t gsl_device_open(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
GSL_API int gsl_device_close(gsl_devhandle_t devhandle);
|
||||
GSL_API int gsl_device_idle(gsl_devhandle_t devhandle, unsigned int timeout);
|
||||
GSL_API int gsl_device_isidle(gsl_devhandle_t devhandle);
|
||||
GSL_API int gsl_device_getcount(void);
|
||||
GSL_API int gsl_device_getinfo(gsl_devhandle_t devhandle, gsl_devinfo_t *devinfo);
|
||||
GSL_API int gsl_device_setpowerstate(gsl_devhandle_t devhandle, gsl_flags_t flags);
|
||||
GSL_API int gsl_device_setdmistate(gsl_devhandle_t devhandle, gsl_flags_t flags);
|
||||
GSL_API int gsl_device_waitirq(gsl_devhandle_t devhandle, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout);
|
||||
GSL_API int gsl_device_waittimestamp(gsl_devhandle_t devhandle, gsl_timestamp_t timestamp, unsigned int timeout);
|
||||
GSL_API int gsl_device_addtimestamp(gsl_devhandle_t devhandle, gsl_timestamp_t *timestamp);
|
||||
gsl_devhandle_t gsl_device_open(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
int gsl_device_close(gsl_devhandle_t devhandle);
|
||||
int gsl_device_idle(gsl_devhandle_t devhandle, unsigned int timeout);
|
||||
int gsl_device_isidle(gsl_devhandle_t devhandle);
|
||||
int gsl_device_getcount(void);
|
||||
int gsl_device_getinfo(gsl_devhandle_t devhandle, gsl_devinfo_t *devinfo);
|
||||
int gsl_device_setpowerstate(gsl_devhandle_t devhandle, gsl_flags_t flags);
|
||||
int gsl_device_setdmistate(gsl_devhandle_t devhandle, gsl_flags_t flags);
|
||||
int gsl_device_waitirq(gsl_devhandle_t devhandle, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout);
|
||||
int gsl_device_waittimestamp(gsl_devhandle_t devhandle, gsl_timestamp_t timestamp, unsigned int timeout);
|
||||
int gsl_device_addtimestamp(gsl_devhandle_t devhandle, gsl_timestamp_t *timestamp);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// direct register API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API int gsl_register_read(gsl_devhandle_t devhandle, unsigned int offsetwords, unsigned int *data);
|
||||
int gsl_register_read(gsl_devhandle_t devhandle, unsigned int offsetwords, unsigned int *data);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// command API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API int gsl_cp_issueibcommands(gsl_devhandle_t devhandle, gsl_ctxthandle_t ctxthandle, gpuaddr_t ibaddr, unsigned int sizewords, gsl_timestamp_t *timestamp, gsl_flags_t flags);
|
||||
GSL_API gsl_timestamp_t gsl_cp_readtimestamp(gsl_devhandle_t devhandle, gsl_timestamp_type_t type);
|
||||
GSL_API int gsl_cp_checktimestamp(gsl_devhandle_t devhandle, gsl_timestamp_t timestamp, gsl_timestamp_type_t type);
|
||||
GSL_API int gsl_cp_freememontimestamp(gsl_devhandle_t devhandle, gsl_memdesc_t *memdesc, gsl_timestamp_t timestamp, gsl_timestamp_type_t type);
|
||||
GSL_API int gsl_v3_issuecommand(gsl_devhandle_t devhandle, gsl_cmdwindow_t target, unsigned int addr, unsigned int data);
|
||||
int gsl_cp_issueibcommands(gsl_devhandle_t devhandle, gsl_ctxthandle_t ctxthandle, gpuaddr_t ibaddr, unsigned int sizewords, gsl_timestamp_t *timestamp, gsl_flags_t flags);
|
||||
gsl_timestamp_t gsl_cp_readtimestamp(gsl_devhandle_t devhandle, gsl_timestamp_type_t type);
|
||||
int gsl_cp_checktimestamp(gsl_devhandle_t devhandle, gsl_timestamp_t timestamp, gsl_timestamp_type_t type);
|
||||
int gsl_cp_freememontimestamp(gsl_devhandle_t devhandle, gsl_memdesc_t *memdesc, gsl_timestamp_t timestamp, gsl_timestamp_type_t type);
|
||||
int gsl_v3_issuecommand(gsl_devhandle_t devhandle, gsl_cmdwindow_t target, unsigned int addr, unsigned int data);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// context API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API gsl_ctxthandle_t gsl_context_create(gsl_devhandle_t devhandle, gsl_context_type_t type, gsl_flags_t flags);
|
||||
GSL_API int gsl_context_destroy(gsl_devhandle_t devhandle, gsl_ctxthandle_t ctxthandle);
|
||||
GSL_API int gsl_context_bind_gmem_shadow(gsl_devhandle_t devhandle, gsl_ctxthandle_t ctxthandle, const gsl_rect_t* gmem_rect, unsigned int shadow_x, unsigned int shadow_y, const gsl_buffer_desc_t* shadow_buffer, unsigned int buffer_id);
|
||||
gsl_ctxthandle_t gsl_context_create(gsl_devhandle_t devhandle, gsl_context_type_t type, gsl_flags_t flags);
|
||||
int gsl_context_destroy(gsl_devhandle_t devhandle, gsl_ctxthandle_t ctxthandle);
|
||||
int gsl_context_bind_gmem_shadow(gsl_devhandle_t devhandle, gsl_ctxthandle_t ctxthandle, const gsl_rect_t* gmem_rect, unsigned int shadow_x, unsigned int shadow_y, const gsl_buffer_desc_t* shadow_buffer, unsigned int buffer_id);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sharedmem API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API int gsl_memory_alloc(gsl_deviceid_t device_id, unsigned int sizebytes, gsl_flags_t flags, gsl_memdesc_t *memdesc);
|
||||
GSL_API int gsl_memory_free(gsl_memdesc_t *memdesc);
|
||||
GSL_API int gsl_memory_read(const gsl_memdesc_t *memdesc, void *dst, unsigned int sizebytes, unsigned int offsetbytes);
|
||||
GSL_API int gsl_memory_write(const gsl_memdesc_t *memdesc, void *src, unsigned int sizebytes, unsigned int offsetbytes);
|
||||
GSL_API int gsl_memory_write_multiple(const gsl_memdesc_t *memdesc, void *src, unsigned int srcstridebytes, unsigned int dststridebytes, unsigned int blocksizebytes, unsigned int numblocks, unsigned int offsetbytes);
|
||||
GSL_API unsigned int gsl_memory_getlargestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
GSL_API int gsl_memory_set(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int value, unsigned int sizebytes);
|
||||
GSL_API int gsl_memory_cacheoperation(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int sizebytes, unsigned int operation);
|
||||
GSL_API int gsl_memory_fromhostpointer(gsl_deviceid_t device_id, gsl_memdesc_t *memdesc, void* hostptr);
|
||||
int gsl_memory_alloc(gsl_deviceid_t device_id, unsigned int sizebytes, gsl_flags_t flags, gsl_memdesc_t *memdesc);
|
||||
int gsl_memory_free(gsl_memdesc_t *memdesc);
|
||||
int gsl_memory_read(const gsl_memdesc_t *memdesc, void *dst, unsigned int sizebytes, unsigned int offsetbytes);
|
||||
int gsl_memory_write(const gsl_memdesc_t *memdesc, void *src, unsigned int sizebytes, unsigned int offsetbytes);
|
||||
int gsl_memory_write_multiple(const gsl_memdesc_t *memdesc, void *src, unsigned int srcstridebytes, unsigned int dststridebytes, unsigned int blocksizebytes, unsigned int numblocks, unsigned int offsetbytes);
|
||||
unsigned int gsl_memory_getlargestfreeblock(gsl_deviceid_t device_id, gsl_flags_t flags);
|
||||
int gsl_memory_set(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int value, unsigned int sizebytes);
|
||||
int gsl_memory_cacheoperation(const gsl_memdesc_t *memdesc, unsigned int offsetbytes, unsigned int sizebytes, unsigned int operation);
|
||||
int gsl_memory_fromhostpointer(gsl_deviceid_t device_id, gsl_memdesc_t *memdesc, void* hostptr);
|
||||
|
||||
#ifdef _DIRECT_MAPPED
|
||||
GSL_API unsigned int gsl_sharedmem_gethostaddr(const gsl_memdesc_t *memdesc);
|
||||
unsigned int gsl_sharedmem_gethostaddr(const gsl_memdesc_t *memdesc);
|
||||
#endif // _DIRECT_MAPPED
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// address translation API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API int gsl_translate_physaddr(void* virtAddr, unsigned int* physAddr);
|
||||
int gsl_translate_physaddr(void* virtAddr, unsigned int* physAddr);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// TB dump API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
GSL_API int gsl_tbdump_waitirq();
|
||||
GSL_API int gsl_tbdump_exportbmp(const void* addr, unsigned int format, unsigned int stride, unsigned int width, unsigned int height);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// OS specific APIs - need to go into their own gsl_libapi_platform.h file
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef WM7
|
||||
GSL_API int gsl_kos_wm7_surfobjfromhbitmap(HBITMAP hbitmap, SURFOBJ *surfobj);
|
||||
#endif // WM7
|
||||
|
||||
int gsl_tbdump_waitirq();
|
||||
int gsl_tbdump_exportbmp(const void* addr, unsigned int format, unsigned int stride, unsigned int width, unsigned int height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -29,9 +29,51 @@
|
||||
#ifndef __GSL_TYPES_H
|
||||
#define __GSL_TYPES_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include "stddef.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Operating System values
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#define OS_SUCCESS 0
|
||||
#define OS_FAILURE -1
|
||||
#define OS_FAILURE_SYSTEMERROR -2
|
||||
#define OS_FAILURE_DEVICEERROR -3
|
||||
#define OS_FAILURE_OUTOFMEM -4
|
||||
#define OS_FAILURE_BADPARAM -5
|
||||
#define OS_FAILURE_NOTSUPPORTED -6
|
||||
#define OS_FAILURE_NOMOREAVAILABLE -7
|
||||
#define OS_FAILURE_NOTINITIALIZED -8
|
||||
#define OS_FAILURE_ALREADYINITIALIZED -9
|
||||
#define OS_FAILURE_TIMEOUT -10
|
||||
|
||||
|
||||
#define OS_INFINITE 0xFFFFFFFF
|
||||
#define OS_TLS_OUTOFINDEXES 0xFFFFFFFF
|
||||
#define OS_TRUE 1
|
||||
#define OS_FALSE 0
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
OS_PROTECTION_GLOBAL, // inter process
|
||||
OS_PROTECTION_LOCAL, // process local
|
||||
OS_PROTECTION_NONE, // none
|
||||
} os_protection_t;
|
||||
|
||||
typedef struct _os_cputimer_t {
|
||||
int refcount; // Reference count
|
||||
int enabled; // Counter is enabled
|
||||
int size; // Number of counters
|
||||
__s64 start_time; // start time in cpu ticks
|
||||
__s64 end_time; // end time in cpu ticks
|
||||
__s64 timer_frequency; // cpu ticks per second
|
||||
__s64 *counter_array; // number of ticks for each counter
|
||||
} os_cputimer_t;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// status
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#ifndef __GSL_H
|
||||
#define __GSL_H
|
||||
|
||||
//#define __KGSLLIB_EXPORTS
|
||||
#define __KERNEL_MODE__
|
||||
|
||||
|
||||
@@ -45,8 +44,6 @@ typedef struct _gsl_device_t gsl_device_t;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#include "gsl_buildconfig.h"
|
||||
|
||||
#include "kos_libapi.h"
|
||||
|
||||
#include "gsl_klibapi.h"
|
||||
|
||||
#ifdef GSL_BLD_YAMATO
|
||||
@@ -76,4 +73,7 @@ typedef struct _gsl_device_t gsl_device_t;
|
||||
|
||||
#include "gsl_config.h"
|
||||
|
||||
|
||||
#define DEBUG_ASSERT(x)
|
||||
|
||||
#endif // __GSL_H
|
||||
|
||||
@@ -29,31 +29,9 @@
|
||||
#ifndef __GSL_CMDSTREAM_H
|
||||
#define __GSL_CMDSTREAM_H
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef VG_HDK
|
||||
#define GSL_CMDSTREAM_GET_SOP_TIMESTAMP(device, data)
|
||||
#else
|
||||
#define GSL_CMDSTREAM_GET_SOP_TIMESTAMP(device, data) kgsl_sharedmem_read0(&device->memstore, (data), GSL_DEVICE_MEMSTORE_OFFSET(soptimestamp), 4, false)
|
||||
#endif
|
||||
|
||||
#ifdef VG_HDK
|
||||
#define GSL_CMDSTREAM_GET_EOP_TIMESTAMP(device, data) (*((int*)data) = (gsl_driver.device[GSL_DEVICE_G12-1]).timestamp)
|
||||
#else
|
||||
#define GSL_CMDSTREAM_GET_EOP_TIMESTAMP(device, data) kgsl_sharedmem_read0(&device->memstore, (data), GSL_DEVICE_MEMSTORE_OFFSET(eoptimestamp), 4, false)
|
||||
#endif
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// types
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
gsl_timestamp_t kgsl_cmdstream_readtimestamp0(gsl_deviceid_t device_id, gsl_timestamp_type_t type);
|
||||
void kgsl_cmdstream_memqueue_drain(gsl_device_t *device);
|
||||
int kgsl_cmdstream_init(gsl_device_t *device);
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/* Copyright (c) 2008-2010, Advanced Micro Devices. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __GSL_CONTEXT_H
|
||||
#define __GSL_CONTEXT_H
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// types
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // __GSL_CONTEXT_H
|
||||
@@ -40,89 +40,76 @@
|
||||
// function table
|
||||
// --------------
|
||||
typedef struct _gsl_functable_t {
|
||||
int (*device_init) (gsl_device_t *device);
|
||||
int (*device_close) (gsl_device_t *device);
|
||||
int (*device_destroy) (gsl_device_t *device);
|
||||
int (*device_start) (gsl_device_t *device, gsl_flags_t flags);
|
||||
int (*device_stop) (gsl_device_t *device);
|
||||
int (*device_getproperty) (gsl_device_t *device, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
int (*device_setproperty) (gsl_device_t *device, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
int (*device_idle) (gsl_device_t *device, unsigned int timeout);
|
||||
int (*device_regread) (gsl_device_t *device, unsigned int offsetwords, unsigned int *value);
|
||||
int (*device_regwrite) (gsl_device_t *device, unsigned int offsetwords, unsigned int value);
|
||||
int (*device_waitirq) (gsl_device_t *device, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout);
|
||||
int (*device_init) (gsl_device_t *device);
|
||||
int (*device_close) (gsl_device_t *device);
|
||||
int (*device_destroy) (gsl_device_t *device);
|
||||
int (*device_start) (gsl_device_t *device, gsl_flags_t flags);
|
||||
int (*device_stop) (gsl_device_t *device);
|
||||
int (*device_getproperty) (gsl_device_t *device, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
int (*device_setproperty) (gsl_device_t *device, gsl_property_type_t type, void *value, unsigned int sizebytes);
|
||||
int (*device_idle) (gsl_device_t *device, unsigned int timeout);
|
||||
int (*device_regread) (gsl_device_t *device, unsigned int offsetwords, unsigned int *value);
|
||||
int (*device_regwrite) (gsl_device_t *device, unsigned int offsetwords, unsigned int value);
|
||||
int (*device_waitirq) (gsl_device_t *device, gsl_intrid_t intr_id, unsigned int *count, unsigned int timeout);
|
||||
int (*device_waittimestamp) (gsl_device_t *device, gsl_timestamp_t timestamp, unsigned int timeout);
|
||||
int (*device_runpending) (gsl_device_t *device);
|
||||
int (*device_addtimestamp) (gsl_device_t *device_id, gsl_timestamp_t *timestamp);
|
||||
int (*intr_isr) (gsl_device_t *device);
|
||||
int (*device_runpending) (gsl_device_t *device);
|
||||
int (*device_addtimestamp) (gsl_device_t *device_id, gsl_timestamp_t *timestamp);
|
||||
int (*intr_isr) (gsl_device_t *device);
|
||||
int (*mmu_tlbinvalidate) (gsl_device_t *device, unsigned int reg_invalidate, unsigned int pid);
|
||||
int (*mmu_setpagetable) (gsl_device_t *device, unsigned int reg_ptbase, gpuaddr_t ptbase, unsigned int pid);
|
||||
int (*cmdstream_issueibcmds) (gsl_device_t *device, int drawctxt_index, gpuaddr_t ibaddr, int sizedwords, gsl_timestamp_t *timestamp, gsl_flags_t flags);
|
||||
int (*context_create) (gsl_device_t *device, gsl_context_type_t type, unsigned int *drawctxt_id, gsl_flags_t flags);
|
||||
int (*context_destroy) (gsl_device_t *device_id, unsigned int drawctxt_id);
|
||||
int (*cmdstream_issueibcmds) (gsl_device_t *device, int drawctxt_index, gpuaddr_t ibaddr, int sizedwords, gsl_timestamp_t *timestamp, gsl_flags_t flags);
|
||||
int (*context_create) (gsl_device_t *device, gsl_context_type_t type, unsigned int *drawctxt_id, gsl_flags_t flags);
|
||||
int (*context_destroy) (gsl_device_t *device_id, unsigned int drawctxt_id);
|
||||
} gsl_functable_t;
|
||||
|
||||
// -------------
|
||||
// device object
|
||||
// -------------
|
||||
// device object
|
||||
struct _gsl_device_t {
|
||||
|
||||
unsigned int refcnt;
|
||||
unsigned int callerprocess[GSL_CALLER_PROCESS_MAX]; // caller process table
|
||||
gsl_functable_t ftbl;
|
||||
gsl_flags_t flags;
|
||||
gsl_deviceid_t id;
|
||||
unsigned int chip_id;
|
||||
gsl_memregion_t regspace;
|
||||
gsl_intr_t intr;
|
||||
gsl_memdesc_t memstore;
|
||||
gsl_memqueue_t memqueue; // queue of memfrees pending timestamp elapse
|
||||
unsigned int refcnt;
|
||||
unsigned int callerprocess[GSL_CALLER_PROCESS_MAX]; // caller process table
|
||||
gsl_functable_t ftbl;
|
||||
gsl_flags_t flags;
|
||||
gsl_deviceid_t id;
|
||||
unsigned int chip_id;
|
||||
gsl_memregion_t regspace;
|
||||
gsl_intr_t intr;
|
||||
gsl_memdesc_t memstore;
|
||||
gsl_memqueue_t memqueue; // queue of memfrees pending timestamp elapse
|
||||
|
||||
#ifdef GSL_DEVICE_SHADOW_MEMSTORE_TO_USER
|
||||
unsigned int memstoreshadow[GSL_CALLER_PROCESS_MAX];
|
||||
unsigned int memstoreshadow[GSL_CALLER_PROCESS_MAX];
|
||||
#endif // GSL_DEVICE_SHADOW_MEMSTORE_TO_USER
|
||||
|
||||
#ifndef GSL_NO_MMU
|
||||
gsl_mmu_t mmu;
|
||||
gsl_mmu_t mmu;
|
||||
#endif // GSL_NO_MMU
|
||||
|
||||
#ifdef GSL_BLD_YAMATO
|
||||
gsl_memregion_t gmemspace;
|
||||
gsl_ringbuffer_t ringbuffer;
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
oshandle_t drawctxt_mutex;
|
||||
#endif
|
||||
unsigned int drawctxt_count;
|
||||
gsl_drawctxt_t *drawctxt_active;
|
||||
gsl_drawctxt_t drawctxt[GSL_CONTEXT_MAX];
|
||||
gsl_memregion_t gmemspace;
|
||||
gsl_ringbuffer_t ringbuffer;
|
||||
unsigned int drawctxt_count;
|
||||
gsl_drawctxt_t *drawctxt_active;
|
||||
gsl_drawctxt_t drawctxt[GSL_CONTEXT_MAX];
|
||||
#endif // GSL_BLD_YAMATO
|
||||
|
||||
#ifdef GSL_BLD_G12
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
oshandle_t cmdwindow_mutex;
|
||||
#endif
|
||||
unsigned int intrcnt[GSL_G12_INTR_COUNT];
|
||||
gsl_timestamp_t current_timestamp;
|
||||
gsl_timestamp_t timestamp;
|
||||
unsigned int intrcnt[GSL_G12_INTR_COUNT];
|
||||
gsl_timestamp_t current_timestamp;
|
||||
gsl_timestamp_t timestamp;
|
||||
#ifdef IRQTHREAD_POLL
|
||||
oshandle_t irqthread_event;
|
||||
struct completion irqthread_event;
|
||||
#endif
|
||||
#endif // GSL_BLD_G12
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
oshandle_t cmdstream_mutex;
|
||||
#endif
|
||||
|
||||
wait_queue_head_t timestamp_waitq;
|
||||
struct workqueue_struct *irq_workq;
|
||||
struct work_struct irq_work;
|
||||
struct work_struct irq_work;
|
||||
struct work_struct irq_err_work;
|
||||
|
||||
void *autogate;
|
||||
void *autogate;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// prototypes
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
int kgsl_device_init(gsl_device_t *device, gsl_deviceid_t device_id);
|
||||
int kgsl_device_close(gsl_device_t *device);
|
||||
int kgsl_device_destroy(gsl_device_t *device);
|
||||
|
||||
@@ -29,42 +29,20 @@
|
||||
#ifndef __GSL_DRIVER_H
|
||||
#define __GSL_DRIVER_H
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// macros
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef GSL_DEDICATED_PROCESS
|
||||
#define GSL_CALLER_PROCESSID_GET() kos_callerprocess_getid()
|
||||
#else
|
||||
#define GSL_CALLER_PROCESSID_GET() kos_process_getid()
|
||||
#endif // GSL_DEDICATED_PROCESS
|
||||
|
||||
#ifdef GSL_LOCKING_COARSEGRAIN
|
||||
#define GSL_API_MUTEX_CREATE() gsl_driver.mutex = kos_mutex_create("gsl_global"); \
|
||||
if (!gsl_driver.mutex) {return (GSL_FAILURE);}
|
||||
#define GSL_API_MUTEX_LOCK() kos_mutex_lock(gsl_driver.mutex)
|
||||
#define GSL_API_MUTEX_UNLOCK() kos_mutex_unlock(gsl_driver.mutex)
|
||||
#define GSL_API_MUTEX_FREE() kos_mutex_free(gsl_driver.mutex); gsl_driver.mutex = 0;
|
||||
#else
|
||||
#define GSL_API_MUTEX_CREATE()
|
||||
#define GSL_API_MUTEX_LOCK()
|
||||
#define GSL_API_MUTEX_UNLOCK()
|
||||
#define GSL_API_MUTEX_FREE()
|
||||
#endif
|
||||
|
||||
#include <linux/mutex.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// types
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// -------------
|
||||
// driver object
|
||||
// driver object
|
||||
// -------------
|
||||
typedef struct _gsl_driver_t {
|
||||
gsl_flags_t flags_debug;
|
||||
int refcnt;
|
||||
unsigned int callerprocess[GSL_CALLER_PROCESS_MAX]; // caller process table
|
||||
oshandle_t mutex; // global API mutex
|
||||
struct mutex lock; // global API mutex
|
||||
void *hal;
|
||||
gsl_sharedmem_t shmem;
|
||||
gsl_device_t device[GSL_DEVICE_MAX];
|
||||
@@ -85,7 +63,7 @@ extern gsl_driver_t gsl_driver;
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// inline functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
OSINLINE int
|
||||
static __inline int
|
||||
kgsl_driver_getcallerprocessindex(unsigned int pid, int *index)
|
||||
{
|
||||
int i;
|
||||
@@ -95,7 +73,7 @@ kgsl_driver_getcallerprocessindex(unsigned int pid, int *index)
|
||||
{
|
||||
if (gsl_driver.callerprocess[i] == pid)
|
||||
{
|
||||
*index = i;
|
||||
*index = i;
|
||||
return (GSL_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,19 +33,6 @@
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/*
|
||||
#include "gsl_buildconfig.h"
|
||||
#include "kos_libapi.h"
|
||||
#include "gsl_klibapi.h"
|
||||
#ifdef GSL_BLD_YAMATO
|
||||
#include <reg/yamato.h>
|
||||
#endif
|
||||
#ifdef GSL_BLD_G12
|
||||
#include <reg/g12_reg.h>
|
||||
#endif
|
||||
#include "gsl_hwaccess.h"
|
||||
*/
|
||||
|
||||
#include "gsl.h"
|
||||
#include "gsl_hwaccess.h"
|
||||
|
||||
@@ -61,7 +48,7 @@ extern "C" {
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// version control
|
||||
// version control
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#define KGSLHAL_NAME "AMD GSL Kernel HAL"
|
||||
#define KGSLHAL_VERSION "0.1"
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#ifndef __GSL_INTRMGR_H
|
||||
#define __GSL_INTRMGR_H
|
||||
|
||||
#include <linux/sched.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// types
|
||||
@@ -85,7 +86,7 @@ typedef struct _gsl_intr_t
|
||||
gsl_device_t *device;
|
||||
unsigned int enabled[GSL_INTR_BLOCK_COUNT];
|
||||
gsl_intr_handler_t handler[GSL_INTR_COUNT];
|
||||
oshandle_t evnt[GSL_INTR_COUNT];
|
||||
struct completion evnt[GSL_INTR_COUNT];
|
||||
} gsl_intr_t;
|
||||
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ int kgsl_log_write( unsigned int log_flags, char* format, ... );
|
||||
#else
|
||||
|
||||
// Empty function definitions
|
||||
OSINLINE int kgsl_log_finish(void) { return GSL_SUCCESS; }
|
||||
OSINLINE int kgsl_log_start( unsigned int log_flags ) { (void)log_flags; return GSL_SUCCESS; }
|
||||
OSINLINE int kgsl_log_write( unsigned int log_flags, char* format, ... ) { (void)log_flags; (void)format; return GSL_SUCCESS; }
|
||||
static __inline int kgsl_log_finish(void) { return GSL_SUCCESS; }
|
||||
static __inline int kgsl_log_start( unsigned int log_flags ) { (void)log_flags; return GSL_SUCCESS; }
|
||||
static __inline int kgsl_log_write( unsigned int log_flags, char* format, ... ) { (void)log_flags; (void)format; return GSL_SUCCESS; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#define __GSL_MEMMGR_H
|
||||
|
||||
|
||||
#include <linux/mutex.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -91,7 +93,7 @@ typedef struct _gsl_nodepool_t {
|
||||
// memory arena object
|
||||
// -------------------
|
||||
typedef struct _gsl_memarena_t {
|
||||
oshandle_t mutex;
|
||||
struct mutex lock;
|
||||
unsigned int gpubaseaddr;
|
||||
unsigned int hostbaseaddr;
|
||||
unsigned int sizebytes;
|
||||
|
||||
@@ -135,9 +135,6 @@ typedef struct _gsl_tlbflushfilter_t {
|
||||
// mmu object
|
||||
// ----------
|
||||
typedef struct _gsl_mmu_t {
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
oshandle_t mutex;
|
||||
#endif
|
||||
unsigned int refcnt;
|
||||
gsl_flags_t flags;
|
||||
gsl_device_t *device;
|
||||
@@ -159,7 +156,7 @@ typedef struct _gsl_mmu_t {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// inline functions
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
OSINLINE int
|
||||
static __inline int
|
||||
kgsl_mmu_isenabled(gsl_mmu_t *mmu)
|
||||
{
|
||||
// address translation enabled
|
||||
|
||||
@@ -136,9 +136,6 @@ typedef struct _gsl_ringbuffer_t {
|
||||
|
||||
gsl_device_t *device;
|
||||
gsl_flags_t flags;
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
oshandle_t mutex;
|
||||
#endif
|
||||
gsl_memdesc_t buffer_desc; // allocated memory descriptor
|
||||
gsl_memdesc_t memptrs_desc;
|
||||
|
||||
@@ -161,23 +158,6 @@ typedef struct _gsl_ringbuffer_t {
|
||||
} gsl_ringbuffer_t;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// macros
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef GSL_LOCKING_FINEGRAIN
|
||||
#define GSL_RB_MUTEX_CREATE() rb->mutex = kos_mutex_create("gsl_ringbuffer"); \
|
||||
if (!rb->mutex) {return (GSL_FAILURE);}
|
||||
#define GSL_RB_MUTEX_LOCK() kos_mutex_lock(rb->mutex)
|
||||
#define GSL_RB_MUTEX_UNLOCK() kos_mutex_unlock(rb->mutex)
|
||||
#define GSL_RB_MUTEX_FREE() kos_mutex_free(rb->mutex); rb->mutex = 0;
|
||||
#else
|
||||
#define GSL_RB_MUTEX_CREATE()
|
||||
#define GSL_RB_MUTEX_LOCK()
|
||||
#define GSL_RB_MUTEX_UNLOCK()
|
||||
#define GSL_RB_MUTEX_FREE()
|
||||
#endif
|
||||
|
||||
// ----------
|
||||
// ring write
|
||||
// ----------
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/* Copyright (c) 2008-2010, QUALCOMM Incorporated. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of QUALCOMM Incorporated nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __OSTYPES_H
|
||||
#define __OSTYPES_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// status
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#define OS_SUCCESS 0
|
||||
#define OS_FAILURE -1
|
||||
#define OS_FAILURE_SYSTEMERROR -2
|
||||
#define OS_FAILURE_DEVICEERROR -3
|
||||
#define OS_FAILURE_OUTOFMEM -4
|
||||
#define OS_FAILURE_BADPARAM -5
|
||||
#define OS_FAILURE_NOTSUPPORTED -6
|
||||
#define OS_FAILURE_NOMOREAVAILABLE -7
|
||||
#define OS_FAILURE_NOTINITIALIZED -8
|
||||
#define OS_FAILURE_ALREADYINITIALIZED -9
|
||||
#define OS_FAILURE_TIMEOUT -10
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// inline
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef OSINLINE
|
||||
#define OSINLINE static __inline
|
||||
#endif // OSINLINE
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// values
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#define OS_INFINITE 0xFFFFFFFF
|
||||
#define OS_TLS_OUTOFINDEXES 0xFFFFFFFF
|
||||
#define OS_TRUE 1
|
||||
#define OS_FALSE 0
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0x0
|
||||
#endif // !NULL
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// types
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
// oshandle_t
|
||||
//
|
||||
typedef void * oshandle_t;
|
||||
#define OS_HANDLE_NULL (oshandle_t)0x0
|
||||
|
||||
typedef enum {
|
||||
OS_PROTECTION_GLOBAL, // inter process
|
||||
OS_PROTECTION_LOCAL, // process local
|
||||
OS_PROTECTION_NONE, // none
|
||||
} os_protection_t;
|
||||
|
||||
typedef struct _os_cputimer_t {
|
||||
int refcount; // Reference count
|
||||
int enabled; // Counter is enabled
|
||||
int size; // Number of counters
|
||||
__s64 start_time; // start time in cpu ticks
|
||||
__s64 end_time; // end time in cpu ticks
|
||||
__s64 timer_frequency; // cpu ticks per second
|
||||
__s64 *counter_array; // number of ticks for each counter
|
||||
} os_cputimer_t;
|
||||
|
||||
#endif // __OSTYPES_H
|
||||
@@ -1,463 +0,0 @@
|
||||
/* Copyright (c) 2008-2010, Advanced Micro Devices. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Advanced Micro Devices nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __KOSAPI_H
|
||||
#define __KOSAPI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
#include "os_types.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// entrypoint abstraction
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define KOS_DLLEXPORT extern
|
||||
#define KOS_DLLIMPORT
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// KOS lib entrypoints
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __KOSLIB_EXPORTS
|
||||
#define KOS_API KOS_DLLEXPORT
|
||||
#else
|
||||
#define KOS_API KOS_DLLIMPORT
|
||||
#endif // __KOSLIB_EXPORTS
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// assert API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
KOS_API void kos_assert_hook(const char* file, int line, int expression);
|
||||
|
||||
#if defined(DEBUG) || defined(DBG) || defined (_DBG) || defined (_DEBUG)
|
||||
#define KOS_ASSERT(expression) //kos_assert_hook(__FILE__, __LINE__, (int)(expression))
|
||||
#else
|
||||
#define KOS_ASSERT(expression)
|
||||
#endif // DEBUG || DBG || _DBG
|
||||
|
||||
#if defined(_DEBUG)
|
||||
#define KOS_MALLOC_DBG(size) kos_malloc(int size)
|
||||
#endif // _DEBUG
|
||||
|
||||
#define kos_assert(expression) KOS_ASSERT(expression)
|
||||
#define kos_malloc_dbg(size) KOS_MALLOC_DBG(size)
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define KOS_PAGE_SIZE 0x1000
|
||||
#endif
|
||||
|
||||
typedef enum mutexIndex mutexIndex_t;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sync API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Create a mutex instance.
|
||||
*
|
||||
*
|
||||
* \param void* name Name string for the new mutex.
|
||||
* \return Returns a handle to the mutex.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API oshandle_t kos_mutex_create(const char* name);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Get a handle to an already existing mutex.
|
||||
*
|
||||
*
|
||||
* \param void* name Name string for the new mutex.
|
||||
* \return Returns a handle to the mutex.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API oshandle_t kos_mutex_open(const char* name);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Free the given mutex.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t mutexhandle Handle to the mutex.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_mutex_free(oshandle_t mutexhandle);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Lock the given mutex.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t mutexhandle Handle to the mutex.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_mutex_lock(oshandle_t mutexhandle);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Try to lock the given mutex, if already locked returns immediately.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t mutexhandle Handle to the mutex.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_mutex_locktry(oshandle_t mutexhandle);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Try to lock the given mutex by waiting for its release. Returns without locking if the
|
||||
* mutex is already locked and cannot be acquired within the given period.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t mutexhandle Handle to the mutex.
|
||||
* \param int millisecondstowait Time to wait for the mutex to be available.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_mutex_lockwait(oshandle_t mutexhandle, int millisecondstowait);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Unlock the given mutex.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t mutexhandle Handle to the mutex.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_mutex_unlock(oshandle_t mutexhandle);
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Increments (increases by one) the value of the specified 32-bit variable as an atomic operation.
|
||||
*
|
||||
*
|
||||
* \param int* ptr Pointer to the value to be incremented.
|
||||
* \return Returns the new incremented value.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interlock_incr(int* ptr);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Decrements (decreases by one) the value of the specified 32-bit variable as an atomic operation.
|
||||
*
|
||||
*
|
||||
* \param int* ptr Pointer to the value to be decremented.
|
||||
* \return Returns the new decremented value.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interlock_decr(int* ptr);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Atomic replacement of a value.
|
||||
*
|
||||
*
|
||||
* \param int* ptr Pointer to the value to be replaced.
|
||||
* \param int value The new value.
|
||||
* \return Returns the old value.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interlock_xchg(int* ptr, int value);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Perform an atomic compare-and-exchange operation on the specified values. Compares the two specified 32-bit values and exchanges
|
||||
* with another 32-bit value based on the outcome of the comparison.
|
||||
*
|
||||
*
|
||||
* \param int* ptr Pointer to the value to be replaced.
|
||||
* \param int value The new value.
|
||||
* \param int compvalue Value to be compared with.
|
||||
* \return Returns the initial value of the first given parameter.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interlock_compxchg(int* ptr, int value, int compvalue);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Atomic addition of two 32-bit values.
|
||||
*
|
||||
*
|
||||
* \param int* ptr Pointer to the target value.
|
||||
* \param int value Value to be added to the target.
|
||||
* \return Returns the initial value of the target.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interlock_xchgadd(int* ptr, int value);
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Create an event semaphore.
|
||||
*
|
||||
*
|
||||
* \param int a_manualReset Selection for performing reset manually (or by the system).
|
||||
* \return Returns an handle to the created semaphore.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API oshandle_t kos_event_create(int a_manualReset);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Destroy an event semaphore.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t a_event Handle to the semaphore.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_event_destroy(oshandle_t a_event);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Signal an event semaphore.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t a_event Handle to the semaphore.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_event_signal(oshandle_t a_event);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Reset an event semaphore.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t a_event Handle to the semaphore.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_event_reset(oshandle_t a_event);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Wait for an event semaphore to be freed and acquire it.
|
||||
*
|
||||
*
|
||||
* \param oshandle_t a_event Handle to the semaphore.
|
||||
* \param int a_milliSeconds Time to wait.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_event_wait(oshandle_t a_event, int a_milliSeconds);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// interrupt handler API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Enable an interrupt with specified id.
|
||||
*
|
||||
*
|
||||
* \param int interrupt Identification number for the interrupt.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interrupt_enable(int interrupt);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Disable an interrupt with specified id.
|
||||
*
|
||||
*
|
||||
* \param int interrupt Identification number for the interrupt.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interrupt_disable(int interrupt);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Set the callback function for an interrupt.
|
||||
*
|
||||
*
|
||||
* \param int interrupt Identification number for the interrupt.
|
||||
* \param void* handler Pointer to the callback function.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interrupt_setcallback(int interrupt, void* handler);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Remove a callback function from an interrupt.
|
||||
*
|
||||
*
|
||||
* \param int interrupt Identification number for the interrupt.
|
||||
* \param void* handler Pointer to the callback function.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_interrupt_clearcallback(int interrupt, void* handler);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// thread and process API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Allocate an entry from the thread local storage table.
|
||||
*
|
||||
*
|
||||
* \return Index of the reserved entry.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API unsigned int kos_tls_alloc(void);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Free an entry from the thread local storage table.
|
||||
*
|
||||
*
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_tls_free(unsigned int tlsindex);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Read the value of an entry in the thread local storage table.
|
||||
*
|
||||
*
|
||||
* \param unsigned int tlsindex Index of the entry.
|
||||
* \return Returns the value of the entry.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API void* kos_tls_read(unsigned int tlsindex);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Write a value to an entry in the thread local storage table.
|
||||
*
|
||||
*
|
||||
* \param unsigned int tlsindex Index of the entry.
|
||||
* \param void* tlsvalue Value to be written.
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_tls_write(unsigned int tlsindex, void* tlsvalue);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Get the id of the current process.
|
||||
*
|
||||
*
|
||||
* \return Returns the process id.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API unsigned int kos_process_getid(void);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Get the id of the current caller process.
|
||||
*
|
||||
*
|
||||
* \return Returns the caller process id.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API unsigned int kos_callerprocess_getid(void);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// timing API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Get the current time as a timestamp.
|
||||
*
|
||||
*
|
||||
* \return Returns the timestamp.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API unsigned int kos_timestamp(void);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// libary API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Map the given library (not required an all OS'es).
|
||||
*
|
||||
*
|
||||
* \param char* libraryname The name string of the lib.
|
||||
* \return Returns a handle for the lib.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API oshandle_t kos_lib_map(char* libraryname);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Unmap the given library.
|
||||
*
|
||||
* \param oshandle_t libhandle Handle to the lib.
|
||||
* \return Returns an error code incase of an error.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_lib_unmap(oshandle_t libhandle);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Get the address of a lib.
|
||||
*
|
||||
* \param oshandle_t libhandle Handle to the lib.
|
||||
* \return Returns a pointer to the lib.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API void* kos_lib_getaddr(oshandle_t libhandle, char* procname);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// query API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Sync block start
|
||||
*
|
||||
* \param void
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_syncblock_start(void);
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Sync block end
|
||||
*
|
||||
* \param void
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_syncblock_end(void);
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Sync block start with argument
|
||||
*
|
||||
* \param void
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_syncblock_start_ex( mutexIndex_t a_index );
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Sync block start with argument
|
||||
*
|
||||
* \param void
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_syncblock_end_ex( mutexIndex_t a_index );
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// file API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Opens a file
|
||||
*
|
||||
* \param const char* filename Name of the file to open.
|
||||
* \param const char* mode Mode used for file opening. See fopen.
|
||||
* \return Returns file handle or NULL if error.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API oshandle_t kos_fopen(const char* filename, const char* mode);
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Writes to a file
|
||||
*
|
||||
* \param oshandle_t file Handle of the file to write to.
|
||||
* \param const char* format Format string. See fprintf.
|
||||
* \return Returns the number of bytes written
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_fprintf(oshandle_t file, const char* format, ...);
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Closes a file
|
||||
*
|
||||
* \param oshandle_t file Handle of the file to close.
|
||||
* \return Returns zero if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_fclose(oshandle_t file);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
#endif // __KOSAPI_H
|
||||
@@ -1,296 +0,0 @@
|
||||
/* Copyright (c) 2008-2010, Advanced Micro Devices. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/mm.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/limits.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <asm/current.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/kthread.h>
|
||||
#include "kos_libapi.h"
|
||||
|
||||
// defines
|
||||
|
||||
// macros
|
||||
#define KOS_DBGFLAGS_SET(flag)
|
||||
|
||||
// assert API
|
||||
KOS_API void
|
||||
kos_assert_hook(const char* file, int line, int expression)
|
||||
{
|
||||
if (expression)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
printk(KERN_ERR "Assertion failed at %s:%d!\n", file, line);
|
||||
//BUG();
|
||||
}
|
||||
|
||||
// put breakpoint here
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sync API
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
KOS_API oshandle_t
|
||||
kos_mutex_create(const char *name)
|
||||
{
|
||||
struct mutex *mutex = kmalloc(sizeof(struct mutex), GFP_KERNEL);
|
||||
if (!mutex)
|
||||
return 0;
|
||||
mutex_init(mutex);
|
||||
return mutex;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KOS_API oshandle_t
|
||||
kos_mutex_open(const char *name)
|
||||
{
|
||||
// not implemented
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KOS_API int
|
||||
kos_mutex_free(oshandle_t mutexhandle)
|
||||
{
|
||||
struct mutex *mutex = (struct mutex *)mutexhandle;
|
||||
if (!mutex)
|
||||
return OS_FAILURE;
|
||||
kfree(mutex);
|
||||
return OS_SUCCESS;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KOS_API int
|
||||
kos_mutex_lock(oshandle_t mutexhandle)
|
||||
{
|
||||
struct mutex *mutex = (struct mutex *)mutexhandle;
|
||||
if (!mutex)
|
||||
return OS_FAILURE;
|
||||
if (mutex_lock_interruptible(mutex) == -EINTR)
|
||||
return OS_FAILURE;
|
||||
return OS_SUCCESS;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KOS_API int
|
||||
kos_mutex_locktry(oshandle_t mutexhandle)
|
||||
{
|
||||
struct mutex *mutex = (struct mutex *)mutexhandle;
|
||||
if (!mutex)
|
||||
return OS_FAILURE;
|
||||
if (!mutex_trylock(mutex))
|
||||
return OS_FAILURE;
|
||||
return OS_SUCCESS;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KOS_API int
|
||||
kos_mutex_unlock(oshandle_t mutexhandle)
|
||||
{
|
||||
struct mutex *mutex = (struct mutex *)mutexhandle;
|
||||
if (!mutex)
|
||||
return OS_FAILURE;
|
||||
KOS_ASSERT(mutex_is_locked(mutex));
|
||||
mutex_unlock(mutex);
|
||||
return OS_SUCCESS;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
KOS_API unsigned int
|
||||
kos_process_getid(void)
|
||||
{
|
||||
return current->tgid;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
/* ------------------------------------------------------------------- *//*
|
||||
* \brief Creates new event semaphore
|
||||
* \param uint32 a_manualReset
|
||||
* When this param is zero, system automatically resets the
|
||||
* event state to nonsignaled after waiting thread has been
|
||||
* released
|
||||
* \return oshandle_t
|
||||
*//* ------------------------------------------------------------------- */
|
||||
KOS_API oshandle_t
|
||||
kos_event_create(int a_manualReset)
|
||||
{
|
||||
struct completion *comp = kmalloc(sizeof(struct completion), GFP_KERNEL);
|
||||
|
||||
KOS_ASSERT(comp);
|
||||
if(!comp)
|
||||
{
|
||||
return (oshandle_t)NULL;
|
||||
}
|
||||
|
||||
init_completion(comp);
|
||||
|
||||
return (oshandle_t)comp;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- *//*
|
||||
* \brief Frees event semaphore
|
||||
* \param oshandle_t a_event, event semaphore
|
||||
* \return int
|
||||
*//* ------------------------------------------------------------------- */
|
||||
KOS_API int
|
||||
kos_event_destroy(oshandle_t a_event)
|
||||
{
|
||||
struct completion *comp = (struct completion *)a_event;
|
||||
|
||||
KOS_ASSERT(comp);
|
||||
// KOS_ASSERT(completion_done(comp));
|
||||
|
||||
kfree(comp);
|
||||
return (OS_SUCCESS);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- *//*
|
||||
* \brief Signals event semaphore
|
||||
* \param oshandle_t a_event, event semaphore
|
||||
* \return int
|
||||
*//* ------------------------------------------------------------------- */
|
||||
KOS_API int
|
||||
kos_event_signal(oshandle_t a_event)
|
||||
{
|
||||
struct completion *comp = (struct completion *)a_event;
|
||||
|
||||
KOS_ASSERT(comp);
|
||||
complete_all(comp); // perhaps complete_all?
|
||||
return (OS_SUCCESS);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- *//*
|
||||
* \brief Resets event semaphore state to nonsignaled
|
||||
* \param oshandle_t a_event, event semaphore
|
||||
* \return int
|
||||
*//* ------------------------------------------------------------------- */
|
||||
KOS_API int
|
||||
kos_event_reset(oshandle_t a_event)
|
||||
{
|
||||
struct completion *comp = (struct completion *)a_event;
|
||||
|
||||
KOS_ASSERT(comp);
|
||||
INIT_COMPLETION(*comp);
|
||||
return (OS_SUCCESS);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------- *//*
|
||||
* \brief Waits event semaphore to be signaled
|
||||
* \param oshandle_t a_event, event semaphore
|
||||
* \return int
|
||||
*//* ------------------------------------------------------------------- */
|
||||
KOS_API int
|
||||
kos_event_wait(oshandle_t a_event, int a_milliSeconds)
|
||||
{
|
||||
struct completion *comp = (struct completion *)a_event;
|
||||
|
||||
KOS_ASSERT(comp);
|
||||
if(a_milliSeconds == OS_INFINITE)
|
||||
{
|
||||
wait_for_completion_killable(comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// should interpret milliseconds really to jiffies?
|
||||
if(!wait_for_completion_timeout(comp, msecs_to_jiffies(a_milliSeconds)))
|
||||
{
|
||||
return (OS_FAILURE);
|
||||
}
|
||||
}
|
||||
return (OS_SUCCESS);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \brief Sync block API
|
||||
* Same mutex needed from different blocks of driver
|
||||
*//*-------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Sync block start
|
||||
*
|
||||
* \param void
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
|
||||
static struct mutex* syncblock_mutex = 0;
|
||||
|
||||
KOS_API int kos_syncblock_start(void)
|
||||
{
|
||||
int return_value;
|
||||
|
||||
if(!syncblock_mutex)
|
||||
{
|
||||
syncblock_mutex = kos_mutex_create("syncblock");
|
||||
}
|
||||
|
||||
if(syncblock_mutex)
|
||||
{
|
||||
return_value = kos_mutex_lock(syncblock_mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return_value = -1;
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
/*-------------------------------------------------------------------*//*!
|
||||
* \external
|
||||
* \brief Sync block end
|
||||
*
|
||||
* \param void
|
||||
* \return Returns NULL if no error, otherwise an error code.
|
||||
*//*-------------------------------------------------------------------*/
|
||||
KOS_API int kos_syncblock_end(void)
|
||||
{
|
||||
int return_value;
|
||||
|
||||
if(syncblock_mutex)
|
||||
{
|
||||
return_value = kos_mutex_unlock(syncblock_mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
return_value = -1;
|
||||
}
|
||||
|
||||
return return_value;
|
||||
}
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "gsl_linux_map.h"
|
||||
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_hwaccess_memread(void *dst, unsigned int gpubase, unsigned int gpuoffset, unsigned int sizebytes, unsigned int touserspace)
|
||||
{
|
||||
if (gsl_driver.enable_mmu && (gpubase >= GSL_LINUX_MAP_RANGE_START) && (gpubase < GSL_LINUX_MAP_RANGE_END)) {
|
||||
@@ -61,7 +61,7 @@ kgsl_hwaccess_memread(void *dst, unsigned int gpubase, unsigned int gpuoffset, u
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_hwaccess_memwrite(unsigned int gpubase, unsigned int gpuoffset, void *src, unsigned int sizebytes, unsigned int fromuserspace)
|
||||
{
|
||||
if (gsl_driver.enable_mmu && (gpubase >= GSL_LINUX_MAP_RANGE_START) && (gpubase < GSL_LINUX_MAP_RANGE_END)) {
|
||||
@@ -87,7 +87,7 @@ kgsl_hwaccess_memwrite(unsigned int gpubase, unsigned int gpuoffset, void *src,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_hwaccess_memset(unsigned int gpubase, unsigned int gpuoffset, unsigned int value, unsigned int sizebytes)
|
||||
{
|
||||
if (gsl_driver.enable_mmu && (gpubase >= GSL_LINUX_MAP_RANGE_START) && (gpubase < GSL_LINUX_MAP_RANGE_END)) {
|
||||
@@ -103,7 +103,7 @@ kgsl_hwaccess_memset(unsigned int gpubase, unsigned int gpuoffset, unsigned int
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_hwaccess_regread(gsl_deviceid_t device_id, unsigned int gpubase, unsigned int offsetwords, unsigned int *data)
|
||||
{
|
||||
unsigned int *reg;
|
||||
@@ -122,7 +122,7 @@ kgsl_hwaccess_regread(gsl_deviceid_t device_id, unsigned int gpubase, unsigned i
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
OSINLINE void
|
||||
static __inline void
|
||||
kgsl_hwaccess_regwrite(gsl_deviceid_t device_id, unsigned int gpubase, unsigned int offsetwords, unsigned int data)
|
||||
{
|
||||
unsigned int *reg;
|
||||
|
||||
@@ -373,7 +373,7 @@ static int gsl_kmod_ioctl(struct inode *inode, struct file *fd, unsigned int cmd
|
||||
* always check against GSL_SUCCESS or GSL_FAILURE as they are not the only
|
||||
* return values.
|
||||
*/
|
||||
KOS_ASSERT(tmpStatus == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(tmpStatus == GSL_SUCCESS);
|
||||
printk(KERN_ERR "%s: copy_to_user error\n", __func__);
|
||||
kgslStatus = GSL_FAILURE;
|
||||
break;
|
||||
@@ -427,7 +427,7 @@ static int gsl_kmod_ioctl(struct inode *inode, struct file *fd, unsigned int cmd
|
||||
if (copy_to_user(param.memdesc, &tmp, sizeof(gsl_memdesc_t)))
|
||||
{
|
||||
tmpStatus = kgsl_sharedmem_free(&tmp);
|
||||
KOS_ASSERT(tmpStatus == GSL_SUCCESS);
|
||||
DEBUG_ASSERT(tmpStatus == GSL_SUCCESS);
|
||||
printk(KERN_ERR "%s: copy_to_user error\n", __func__);
|
||||
kgslStatus = GSL_FAILURE;
|
||||
break;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
static u32 device_id_to_device_index(gsl_deviceid_t device_id)
|
||||
{
|
||||
KOS_ASSERT((GSL_DEVICE_ANY < device_id) &&
|
||||
DEBUG_ASSERT((GSL_DEVICE_ANY < device_id) &&
|
||||
(device_id <= GSL_DEVICE_MAX));
|
||||
return (u32)(device_id - 1);
|
||||
}
|
||||
@@ -40,9 +40,9 @@ static struct gsl_kmod_per_fd_data *get_fd_private_data(struct file *fd)
|
||||
{
|
||||
struct gsl_kmod_per_fd_data *datp;
|
||||
|
||||
KOS_ASSERT(fd);
|
||||
DEBUG_ASSERT(fd);
|
||||
datp = (struct gsl_kmod_per_fd_data *)fd->private_data;
|
||||
KOS_ASSERT(datp);
|
||||
DEBUG_ASSERT(datp);
|
||||
return datp;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ static s8 *find_first_entry_with(s8 *subarray, s8 context_id)
|
||||
|
||||
//printk(KERN_DEBUG "At %s, ctx_id = %d\n", __func__, context_id);
|
||||
|
||||
KOS_ASSERT(context_id >= EMPTY_ENTRY);
|
||||
KOS_ASSERT(context_id <= GSL_CONTEXT_MAX); // TODO: check the bound.
|
||||
DEBUG_ASSERT(context_id >= EMPTY_ENTRY);
|
||||
DEBUG_ASSERT(context_id <= GSL_CONTEXT_MAX); // TODO: check the bound.
|
||||
|
||||
for(i = 0; i < GSL_CONTEXT_MAX; i++) // TODO: check the bound.
|
||||
{
|
||||
@@ -85,12 +85,12 @@ int add_memblock_to_allocated_list(struct file *fd,
|
||||
struct gsl_kmod_alloc_list *lisp;
|
||||
struct list_head *head;
|
||||
|
||||
KOS_ASSERT(allocated_block);
|
||||
DEBUG_ASSERT(allocated_block);
|
||||
|
||||
datp = get_fd_private_data(fd);
|
||||
|
||||
head = &datp->allocated_blocks_head;
|
||||
KOS_ASSERT(head);
|
||||
DEBUG_ASSERT(head);
|
||||
|
||||
/* allocate and put new entry in the list of allocated memory descriptors */
|
||||
lisp = (struct gsl_kmod_alloc_list *)kzalloc(sizeof(struct gsl_kmod_alloc_list), GFP_KERNEL);
|
||||
@@ -127,14 +127,14 @@ int del_memblock_from_allocated_list(struct file *fd,
|
||||
struct list_head *head;
|
||||
// int is_different;
|
||||
|
||||
KOS_ASSERT(freed_block);
|
||||
DEBUG_ASSERT(freed_block);
|
||||
|
||||
datp = get_fd_private_data(fd);
|
||||
|
||||
head = &datp->allocated_blocks_head;
|
||||
KOS_ASSERT(head);
|
||||
DEBUG_ASSERT(head);
|
||||
|
||||
KOS_ASSERT(datp->number_of_allocated_blocks > 0);
|
||||
DEBUG_ASSERT(datp->number_of_allocated_blocks > 0);
|
||||
|
||||
if(!list_empty(head))
|
||||
{
|
||||
@@ -143,7 +143,7 @@ int del_memblock_from_allocated_list(struct file *fd,
|
||||
if(cursor->allocated_block.gpuaddr == freed_block->gpuaddr)
|
||||
{
|
||||
// is_different = memcmp(&cursor->allocated_block, freed_block, sizeof(gsl_memdesc_t));
|
||||
// KOS_ASSERT(!is_different);
|
||||
// DEBUG_ASSERT(!is_different);
|
||||
|
||||
list_del(&cursor->node);
|
||||
// printk(KERN_DEBUG "List entry #%u freed\n", cursor->allocation_number);
|
||||
@@ -166,7 +166,7 @@ int del_all_memblocks_from_allocated_list(struct file *fd)
|
||||
datp = get_fd_private_data(fd);
|
||||
|
||||
head = &datp->allocated_blocks_head;
|
||||
KOS_ASSERT(head);
|
||||
DEBUG_ASSERT(head);
|
||||
|
||||
if(!list_empty(head))
|
||||
{
|
||||
@@ -180,7 +180,7 @@ int del_all_memblocks_from_allocated_list(struct file *fd)
|
||||
}
|
||||
}
|
||||
|
||||
KOS_ASSERT(list_empty(head));
|
||||
DEBUG_ASSERT(list_empty(head));
|
||||
datp->number_of_allocated_blocks = 0;
|
||||
|
||||
return 0;
|
||||
@@ -206,10 +206,10 @@ void add_device_context_to_array(struct file *fd,
|
||||
subarray = datp->created_contexts_array[device_index];
|
||||
entry = find_first_entry_with(subarray, EMPTY_ENTRY);
|
||||
|
||||
KOS_ASSERT(entry);
|
||||
KOS_ASSERT((datp->created_contexts_array[device_index] <= entry) &&
|
||||
DEBUG_ASSERT(entry);
|
||||
DEBUG_ASSERT((datp->created_contexts_array[device_index] <= entry) &&
|
||||
(entry < datp->created_contexts_array[device_index] + GSL_CONTEXT_MAX));
|
||||
KOS_ASSERT(context_id < 127);
|
||||
DEBUG_ASSERT(context_id < 127);
|
||||
*entry = (s8)context_id;
|
||||
}
|
||||
|
||||
@@ -224,11 +224,11 @@ void del_device_context_from_array(struct file *fd,
|
||||
|
||||
datp = get_fd_private_data(fd);
|
||||
|
||||
KOS_ASSERT(context_id < 127);
|
||||
DEBUG_ASSERT(context_id < 127);
|
||||
subarray = &(datp->created_contexts_array[device_index][0]);
|
||||
entry = find_first_entry_with(subarray, context_id);
|
||||
KOS_ASSERT(entry);
|
||||
KOS_ASSERT((datp->created_contexts_array[device_index] <= entry) &&
|
||||
DEBUG_ASSERT(entry);
|
||||
DEBUG_ASSERT((datp->created_contexts_array[device_index] <= entry) &&
|
||||
(entry < datp->created_contexts_array[device_index] + GSL_CONTEXT_MAX));
|
||||
*entry = EMPTY_ENTRY;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user