Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
  • Loading branch information
felipec committed Oct 20, 2008
0 parents commit 831cb03
Show file tree
Hide file tree
Showing 7 changed files with 597 additions and 0 deletions.
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
CC := arm-linux-gcc
# CFLAGS := -Wall -g3
CFLAGS := -Wall -O2

CL6X := $(DSP_TOOLS)/bin/cl6x
LNK6X := $(DSP_TOOLS)/bin/lnk6x
DLLCREATE := $(DSP_DOFFBUILD)/bin/DLLcreate

ifdef DEBUG
CFLAGS += -DDEBUG
endif

# bridge
BRIDGE_LIBS := -L$(BRIDGE_DIR) -lbridge
BRIDGE_CFLAGS := -I$(BRIDGE_DIR)/inc -DOMAP_3430

all:

# dummy

dummy: dummy_arm.o dmm_buffer.o
dummy: CFLAGS := $(CFLAGS) $(BRIDGE_CFLAGS)
dummy: LIBS := $(BRIDGE_LIBS) -lpthread

bins += dummy

dummy.x64P: dummy_dsp.o64P dummy_bridge.o64P

dummy.dll64P: dummy.x64P
dummy.dll64P: CFLAGS :=
dummy.dll64P: INCLUDES := -I$(DSP_TOOLS)/include

bins += dummy.dll64P

all: $(bins)

clean:
$(Q)rm -f $(bins)
$(Q)rm -f *.o *.o64P *.x64P

# from Lauri Leukkunen's build system
ifdef V
Q =
P = @printf "" # <- space before hash is important!!!
else
P = @printf "[%s] $@\n" # <- space before hash is important!!!
Q = @
endif

%.o64P:: %.s
$(P)CL6X
$(Q)$(CL6X) $(CFLAGS) $(INCLUDES) -mv=64p -eo.o64P -c $<

%.o64P:: %.c
$(P)CL6X
$(Q)$(CL6X) $(CFLAGS) $(INCLUDES) -mv=64p -eo.o64P -c $<

%.x64P::
$(P)LNK6X
$(Q)$(LNK6X) -r -cr -o $@ $+

%.dll64P::
$(P)DLLCREATE
$(Q)$(DLLCREATE) $< -o=$@

%.o:: %.c
$(P)CC
$(Q)$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<

dummy:
$(P)LINK
$(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
66 changes: 66 additions & 0 deletions dmm_buffer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2008 Nokia Corporation.
*
* Author: Felipe Contreras <felipe.contreras@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

#include "dmm_buffer.h"

#include <stdlib.h>

DmmBuffer *
dmm_buffer_new (DSP_HNODE handle)
{
DmmBuffer *buffer;
buffer = calloc (1, sizeof (DmmBuffer));

buffer->handle = handle;

return buffer;
}

void
dmm_buffer_free (DmmBuffer *buffer)
{
#ifdef DEBUG
printf ("%s: %p\n", __func__, buffer);
#endif
DSPProcessor_UnMap (buffer->handle, buffer->map);
DSPProcessor_UnReserveMemory (buffer->handle, buffer->reserve);
free (buffer->allocated_data);
free (buffer);
}

void
dmm_buffer_allocate (DmmBuffer *buffer,
unsigned int size)
{
buffer->data = buffer->allocated_data = malloc (size);
buffer->size = size;
dmm_buffer_map (buffer);
}

void
dmm_buffer_use (DmmBuffer *buffer,
void *data,
unsigned int size)
{
buffer->data = data;
buffer->size = size;
dmm_buffer_map (buffer);
}
79 changes: 79 additions & 0 deletions dmm_buffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2008 Nokia Corporation.
*
* Author: Felipe Contreras <felipe.contreras@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation
* version 2.1 of the License.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

#ifndef DMM_BUFFER_H
#define DMM_BUFFER_H

#include <dbapi.h>

#define DMM_PAGE_SIZE 4096
#define ROUND_TO_PAGESIZE(n) ((((n) + 4095) / DMM_PAGE_SIZE) * DMM_PAGE_SIZE)

typedef struct
{
DSP_HNODE handle;
void *data;
void *allocated_data;
unsigned long size;
void *reserve;
void *map;
} DmmBuffer;

DmmBuffer *dmm_buffer_new (DSP_HNODE handle);

void dmm_buffer_free (DmmBuffer *buffer);

void dmm_buffer_allocate (DmmBuffer *buffer, unsigned int size);

void dmm_buffer_use (DmmBuffer *buffer, void *data, unsigned int size);

static inline void
dmm_buffer_map (DmmBuffer *buffer)
{
#ifdef DEBUG
printf ("%s: %p\n", __func__, buffer);
#endif
unsigned int to_reserve;
to_reserve = ROUND_TO_PAGESIZE (buffer->size) + (2 * DMM_PAGE_SIZE);
DSPProcessor_ReserveMemory (buffer->handle, to_reserve, &buffer->reserve);
DSPProcessor_Map (buffer->handle, buffer->data, buffer->size,
buffer->reserve, &buffer->map, 0);
}

static inline void
dmm_buffer_flush (DmmBuffer *buffer)
{
#ifdef DEBUG
printf ("%s: %p\n", __func__, buffer);
#endif
DSPProcessor_FlushMemory (buffer->handle, buffer->data, buffer->size, 0);
}

static inline void
dmm_buffer_invalidate (DmmBuffer *buffer)
{
#ifdef DEBUG
printf ("%s: %p\n", __func__, buffer);
#endif
DSPProcessor_InvalidateMemory (buffer->handle, buffer->data, buffer->size);
}

#endif /* DMM_BUFFER_H */
Loading

0 comments on commit 831cb03

Please sign in to comment.