# Makefile - make rules for bsp/config/p910
#
# Copyright 1984-1998 Wind River Systems, Inc.
#
# modification history
# --------------------
# 01a,27aug98,hk  written based on hy7709/Makefile version (01a,29jun98,hk)
#
# DESCRIPTION
# This file contains rules for building VxWorks for the
# Ishida P-910/SH7709 board.
#
# INCLUDES
#     makeTarget
#*/

CPU             = SH7700
TOOL            = gnu
TGT_DIR		= $(WIND_BASE)/target

include $(TGT_DIR)/h/make/defs.bsp
include $(TGT_DIR)/h/make/make.$(CPU)$(TOOL)
LDFLAGS		= -X -N -S -Map $@.map
include $(TGT_DIR)/h/make/defs.$(WIND_HOST_TYPE)

## Only redefine make definitions below this point, or your definitions will
## be overwritten by the makefile stubs above.

TARGET_DIR      = p910
VENDOR          = Ishida
BOARD           = P-910

#
# The constants ROM_TEXT_ADRS, ROM_SIZE, and RAM_HIGH_ADRS are defined
# in config.h, Makefile, SH7700.LDH, SH7700.RES_LDH, and SH7700.RES_LDL.
# Also the constant RAM_LOW_ADRS is defined in Makefile, SH7700.LDL, and
# SH7700.RES_LDL.  All definitions for these constants must be identical.
#

ROM_TEXT_ADRS   = 00000000 # ROM entry address
ROM_SIZE        = 00100000 # number of bytes of ROM space : 1024KB

RAM_LOW_ADRS    = 0c002000 # RAM text/data address (DRAM)
# /*--- ISHIDA TOP 03.02.19 ---*/
# RAM_HIGH_ADRS   = 0c0b0000 # RAM text/data address (DRAM)
RAM_HIGH_ADRS   = 0c400000 # RAM text/data address (DRAM)
# /*--- ISHIDA END 03.02.19 ---*/

HEX_FLAGS       = -a $(ROM_TEXT_ADRS) -l


USRCONFIG	= .\config\usrConfig.c
BOOTCONFIG	= .\config\bootConfig.c
BOOTINIT	= .\config\bootInit.c

#------------------------------
#	[X
#------------------------------
ADDED_CFLAGS	= -DBOOT_SOFT_ISHIDA
#------------------------------
#	Jp
#------------------------------
# ADDED_CFLAGS	= -DBOOT_SOFT_ISHIDA -DDEVELOP_ISHIDA
#------------------------------
#	Wind Wiew
#------------------------------
# ADDED_CFLAGS	= -DBOOT_SOFT_ISHIDA -DLOAD_SOFT_ISHIDA -DDEVELOP_ISHIDA -DWINDVIEW_ISHIDA
# ADDED_CFLAGS	= -DDEVELOP_ISHIDA


EXTRA_INCLUDE	= -Ic:/tornado/target/config/ishida/h

# P910G 
MACH_EXTRA      = cacheSh7709aLib.o p910SciSio.o dosFsLib.o \
				if_lnc.o \
				c:/tornado/target/config/ishida/bootg/p910boot.o

LIB_EXTRA		= pcmcia/cs.a

RELEASE         = vxWorks vxWorks_rom.hex vxWorks_rom.bin vxWorks.st \
                      vxWorks.st_rom.bin 

## Only redefine make definitions above this point, or the expansion of
## makefile target dependencies may be incorrect.

include $(TGT_DIR)/h/make/rules.bsp
include $(TGT_DIR)/h/make/rules.$(WIND_HOST_TYPE)

#######################################################################
# Rules for making vxWorks_rom.bin and vxWorks.st_rom.bin targets
# DO NOT edit below this line

# vxWorks_rom.bin - rommable version of VxWorks(without standalone symbol table)
#   For this BSP this is used in place of 
#   include the shell and the symbol table.  Since these applications are
#   usually smaller, this version  uses ROM compression.

vxWorks_rom.bin: depend.$(BSP_NAME) vxWorks_rom_high $(IMI)
	- @ $(RM) $@
	$(EXTRACT_BIN)<vxWorks_rom_high>$@

vxWorks_rom_high: depend.$(BSP_NAME) bootInit_rom_high.o romInit_rom_high.o \
		vxWorks.Z.o $(MACH_DEP) $(LDDEPS) $(LIBS)
	- @ $(RM) $@ 
	- @ $(RM) $(IMI) 
	- @ $(RM) $(IBR)
	- @ $(RM) version.o
	$(CC) -c $(CFLAGS) -o version.o $(CONFIG_ALL)/version.c
	$(LD) $(LDFLAGS) -e $(ROM_ENTRY) $(LD_HIGH_FLAGS) \
		-o $@ romInit_rom_high.o bootInit_rom_high.o version.o \
		$(BOOT_EXTRA) $(LIBS) vxWorks.Z.o
	$(ROMSIZEPROG) -b $(ROM_SIZE) $@
	$(LDOUT_CONV) $@

vxWorks.st_rom.bin : depend.$(BSP_NAME) vxWorks.st_rom_high $(IMI)
	- @ $(RM) $@
	$(EXTRACT_BIN)<vxWorks.st_rom_high>$@

vxWorks.st_rom_high : depend.$(BSP_NAME) bootInit_rom_high.o \
		romInit_rom_high.o vxWorks.st.Z.o \
		$(LDDEPS) $(LIBS) $(BOOT_EXTRA)
	- @ $(RM) $(IMI) 
	- @ $(RM) $(IBR)
	- @ $(RM) version.o
	$(CC) -c $(CFLAGS) -o version.o $(CONFIG_ALL)/version.c
	$(LD) $(LDFLAGS) -e $(ROM_ENTRY) $(LD_HIGH_FLAGS) \
		-o $@ romInit_rom_high.o bootInit_rom_high.o version.o \
		$(BOOT_EXTRA) $(LIBS) vxWorks.st.Z.o
	$(ROMSIZEPROG) -b $(ROM_SIZE) $@
	$(LDOUT_CONV) $@

bootInit_rom_high.o : depend.$(BSP_NAME) $(BOOTINIT) bootInit.o
	- @ $(RM) $@
	$(CC) -c $(CFLAGS) -DRAM_DST_ADRS=0x$(RAM_LOW_ADRS) -DROM_HIGH \
		$(BOOTINIT) -o $@ 

romInit_rom_high.o: depend.$(BSP_NAME) romInit.s romInit.o
	- @ $(RM) $@
	$(CC) $(CFLAGS_AS) -DROM_HIGH -c -o $@ romInit.s

vxWorks.Z.s :	vxWorks dataSegPad.o
	$(EXTRACT_BIN) < vxWorks | $(COMPRESS) -f -b 15 >tmp.Z
	$(BINTOASM) tmp.Z > $@
	- @ $(RM) tmp.o
	- @ $(RM) tmp.Z

################################################################################
#
# for PCMCIA module
#
pcmcia/cs.a: ./*.h pcmcia/*.[ch]
	make -C pcmcia -f Makefile cs.a

################################################################################
#
# for ROM write image
#
romWriter.hex:bootrom.hex ramDisk
	$(RM) romWriter.hex
	objcopysh --adjust-vma=0x00100000 -I binary -O srec ramDisk ramDisk.hex
	sed -e "/S8/d" bootrom.hex > temp1.hex
	sed -e "/S0/d" ramDisk.hex > temp2.hex
	$(CP) temp1.hex+temp2.hex romwriter.hex
	$(RM) temp1.hex
	$(RM) temp2.hex
	$(RM) ramDisk.hex

romWriter_res.hex:bootrom_res.hex ramDisk
	$(RM) romWriter_res.hex
	objcopysh --adjust-vma=0x00100000 -I binary -O srec ramDisk ramDisk.hex
	sed -e "/S8/d" bootrom_res.hex > temp1.hex
	sed -e "/S0/d" ramDisk.hex > temp2.hex
	$(CP) temp1.hex+temp2.hex romwriter_res.hex
	$(RM) temp1.hex
	$(RM) temp2.hex
	$(RM) ramDisk.hex
