ifdef TARGET_PLATFORM_BEAGLEBONE

# support for ARM335x PRU (Programmable Realtime Unit) components and
SUPPORT_DIR := hal/support
#PRU_SRC_DIR := $(SUPPORT_DIR)/pru-src/

# The PRU assembler proper
PASM_HOST := ../bin/pasm
PASM_SRCS := $(addprefix $(SUPPORT_DIR)/pasm/, \
	pasm.c pasmpp.c pasmexp.c pasmop.c pasmdot.c pasmstruct.c pasmmacro.c)

$(call TOOBJSDEPS, $(PASM_SRCS)) : EXTRAFLAGS=-Wall -D_UNIX_

../bin/pasm: $(call TOOBJS, $(PASM_SRCS))
	$(ECHO) Linking $(notdir $@)
	$(Q)$(CC) $(CPPFLAGS) -o $@ $^

USERSRCS += $(PASM_SRCS)
TARGETS += $(PASM_HOST)

ifeq ($(CROSS_COMPILING),no)
PASM := $(PASM_HOST)
else
# The PRU assembler for cross-compiling
PASM_BUILD := ../bin/pasm_build
PASM := $(PASM_BUILD)

$(call TOOBJSDEPS,$(PASM_SRCS),_build) : EXTRAFLAGS=-Wall -D_UNIX_
$(call TOOBJSDEPS,$(PASM_SRCS),_build) : CC=$(CC_FOR_BUILD)

$(PASM_BUILD): $(call TOOBJS,$(PASM_SRCS),_build)
	$(ECHO) Linking $(notdir $@)
	$(Q)$(CC_FOR_BUILD) -o $@ $^

USERSRCS_BUILD += $(PASM_SRCS)
TARGETS += $(PASM_BUILD)
endif

## basic peek/poke utility
#DEVMEM2 = ../bin/devmem2
#DEVMEM2_SRCS := $(addprefix $(SUPPORT_DIR)/, devmem2.c)
#$(DEVMEM2): $(call TOOBJS, $(DEVMEM2_SRCS))
#	$(ECHO) Linking $(notdir $@)
#	$(Q)$(CC) -o $@ $^
#
#USERSRCS += $(DEVMEM2_SRCS)
#TARGETS += $(DEVMEM2)


# application loader UIO interface
# the matching uio_pruss kernel module is part of the
# kernel build
PRUSS_INC :=  $(SUPPORT_DIR)/pru
PRUSSDRV_SRCS := $(addprefix $(SUPPORT_DIR)/pru/, \
	prussdrv.c)
$(call TOOBJSDEPS, $(PRUSSDRV_SRCS)) : EXTRAFLAGS= -D__DEBUG -I$(BASEPWD)/hal/support/pru #-fPIC
USERSRCS += $(PRUSSDRV_SRCS)

## install PRU, prussdrv includes
## not needed for now
##../include/%.h: $(SUPPORT_DIR)/%.h
##	cp $^ $@
#
## Assembly of PRU code
## the list of assembly source files
#PRU_SRCS := $(wildcard $(PRU_SRC_DIR)/*.p)
#
## .bin files produced by PASM -b go in rtlib
#PRU_BINS := $(patsubst $(PRU_SRC_DIR)/%.p, ../rtlib/%.bin, $(PRU_SRCS))
#
## .bin files are targets
#TARGETS +=  $(PRU_BINS)
#USERSRCS += $(PRU_SRCS)
#
## .bin output, create listing
#PASM_BINFLAGS := -b -L
#
## conversion rules for the above
## assemble .p  into .bin object files
#../rtlib/%.bin: $(PRU_SRC_DIR)/%.p
#	$(ECHO) Assembling PRU code $@
#	$(Q)$(PASM) $(PASM_BINFLAGS) $^ $(basename $@)


endif
