Index: arch/v850/Makefile =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/Makefile,v retrieving revision 1.2 diff -u -r1.2 Makefile --- arch/v850/Makefile 2002/01/10 12:36:30 1.2 +++ arch/v850/Makefile 2002/01/29 08:41:11 @@ -17,37 +17,51 @@ CFLAGS += -pipe -ffixed-r16 -mv850e -mno-prolog-function -fno-builtin -DNO_MM -DNO_FPU -D__ELF__ $(UTS_SYSNAME) -D__linux__ +ARCH_DIR = arch/$(ARCH) + + # linker scripts ifdef CONFIG_SIM -LINKFLAGS = -T $(TOPDIR)/arch/v850/sim.ld +LINKFLAGS = -T $(ARCH_DIR)/sim.ld endif ifdef CONFIG_RTE_MA1_CB ifdef CONFIG_ROM_KERNEL -LINKFLAGS = -T $(TOPDIR)/arch/v850/rte_ma1_cb-rom.ld +LINKFLAGS = -T $(ARCH_DIR)/rte_ma1_cb-rom.ld else ifdef CONFIG_RTE_MA1_CB_KSRAM -LINKFLAGS = -T $(TOPDIR)/arch/v850/rte_ma1_cb-ksram.ld +LINKFLAGS = -T $(ARCH_DIR)/rte_ma1_cb-ksram.ld else -LINKFLAGS = -T $(TOPDIR)/arch/v850/rte_ma1_cb.ld +LINKFLAGS = -T $(ARCH_DIR)/rte_ma1_cb.ld endif endif endif -HEAD := arch/$(ARCH)/kernel/head.o +HEAD := $(ARCH_DIR)/kernel/head.o -SUBDIRS += arch/$(ARCH)/kernel arch/$(ARCH)/lib -CORE_FILES := arch/v850/kernel/kernel.o $(CORE_FILES) -LIBS += arch/v850/lib/lib.a +SUBDIRS += $(ARCH_DIR)/kernel $(ARCH_DIR)/lib +CORE_FILES := $(ARCH_DIR)/kernel/kernel.o $(CORE_FILES) +LIBS += $(ARCH_DIR)/lib/lib.a -# Link in root filesystem -ifdef CONFIG_RTE_MA1_CB -CORE_FILES += blkmem0.o +# Deal with the initial contents of the blkmem device +ifdef BLKMEM0_IMAGE +ifndef CONFIG_SIM +# Embed it in the kernel + +BLKMEM0_IMAGE_OBJ = blkmem0.o + +CORE_FILES += $(BLKMEM0_IMAGE_OBJ) + +$(LINUX) : $(BLKMEM0_IMAGE_OBJ) + # Note that we use the build-system's objcopy, as the v850 tools are fairly # old, and don't have the --rename-section option. -blkmem0.o: root.ext2 +$(BLKMEM0_IMAGE_OBJ): $(BLKMEM0_IMAGE) objcopy -I binary -O elf32-little -B i386 --rename-section .data=.blkmem0,alloc,load,readonly,data,contents $< $@ -endif + +endif # !CONFIG_SIM +endif # BLKMEM0_IMAGE + # # If you want the kernel build to build modules outside of the tree @@ -66,6 +80,6 @@ archclean: rm -f $(LINUX) - rm -f arch/v850/kernel/v850_defs.h arch/v850/kernel/v850_defs.d + rm -f $(ARCH_DIR)/kernel/v850_defs.h $(ARCH_DIR)/kernel/v850_defs.d include $(TOPDIR)/Rules.make Index: arch/v850/README =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/README,v retrieving revision 1.1 diff -u -r1.1 README --- arch/v850/README 2001/10/22 13:38:58 1.1 +++ arch/v850/README 2002/01/29 08:41:11 @@ -7,6 +7,8 @@ with untested support for the RTE-V850E/NB85E-CB board (CONFIG_RTE_NB85E_CB). This support has only been tested when running with the Multi-debugger monitor ROM (for the Green Hills Multi debugger). + The optional RTE-MOTHER-A motherboard is also supported, which + allows PCI boards to be used. Porting to anything with a V850E/MA1 or MA2 processor should be simple. See the file and the files it includes for an example of Index: arch/v850/rte_ma1_cb-ksram.ld =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/rte_ma1_cb-ksram.ld,v retrieving revision 1.1 diff -u -r1.1 rte_ma1_cb-ksram.ld --- arch/v850/rte_ma1_cb-ksram.ld 2002/01/10 12:36:30 1.1 +++ arch/v850/rte_ma1_cb-ksram.ld 2002/01/29 08:41:12 @@ -123,9 +123,9 @@ /* `blkmem' device contents for the root filesystem. */ .blkmem : { - __blkmem_0_start = _binary_root_ext2_start ; + __blkmem_0_start = . ; *(.blkmem0) *(=.blkmem0) /* bug in objcopy results in mis-named sections.*/ - __blkmem_0_end = _binary_root_ext2_end ; + __blkmem_0_end = . ; } > SDRAM } Index: arch/v850/rte_ma1_cb-rom.ld =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/rte_ma1_cb-rom.ld,v retrieving revision 1.1 diff -u -r1.1 rte_ma1_cb-rom.ld --- arch/v850/rte_ma1_cb-rom.ld 2001/10/22 13:38:58 1.1 +++ arch/v850/rte_ma1_cb-rom.ld 2002/01/29 08:41:12 @@ -75,10 +75,10 @@ /* `blkmem' device contents for the root filesystem. */ .blkmem { - __blkmem_0_start = _binary_root_ext2_start ; + __blkmem_0_start = . ; *(.blkmem0) *(=.blkmem0) /* bug in objcopy results in mis-named sections.*/ - __blkmem_0_end = _binary_root_ext2_end ; + __blkmem_0_end = . ; } __end = . ; Index: arch/v850/rte_ma1_cb.ld =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/rte_ma1_cb.ld,v retrieving revision 1.2 diff -u -r1.2 rte_ma1_cb.ld --- arch/v850/rte_ma1_cb.ld 2002/01/10 12:36:30 1.2 +++ arch/v850/rte_ma1_cb.ld 2002/01/29 08:41:16 @@ -121,11 +121,11 @@ ___init_end = __intv_end; /* `blkmem' device contents for the root filesystem. */ - .blkmem ALIGN (1024) : { - __blkmem_0_start = _binary_root_ext2_start ; + .blkmem ALIGN (4096) : { + __blkmem_0_start = . ; *(.blkmem0) *(=.blkmem0) /* bug in objcopy results in mis-named sections.*/ - __blkmem_0_end = _binary_root_ext2_end ; + __blkmem_0_end = . ; } > SDRAM __end = . ; Index: arch/v850/kernel/rte_mb_a_pci.c =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/kernel/rte_mb_a_pci.c,v retrieving revision 1.1 diff -u -r1.1 rte_mb_a_pci.c --- arch/v850/kernel/rte_mb_a_pci.c 2002/01/10 12:36:30 1.1 +++ arch/v850/kernel/rte_mb_a_pci.c 2002/01/29 08:41:23 @@ -353,7 +353,7 @@ /* Allocate a memory block at least SIZE bytes long in the Mother-A SRAM space. */ -static void *alloc_mb_sram (unsigned long size) +static void *alloc_mb_sram (size_t size) { struct mb_sram_free_area *prev, *fa; int flags; @@ -394,7 +394,7 @@ } /* Return the memory area MEM of size SIZE to the MB SRAM free pool. */ -static void free_mb_sram (void *mem, unsigned long size) +static void free_mb_sram (void *mem, size_t size) { struct mb_sram_free_area *prev, *fa, *new_fa; int flags; @@ -411,8 +411,20 @@ fa->size += size; goto done; } else if (fa->mem + fa->size == mem) { + struct mb_sram_free_area *next_fa = fa->next; + /* FA is just before MEM, expand to encompass it. */ fa->size += size; + + /* See if FA can now be merged with its successor. */ + if (next_fa && fa->mem + fa->size == next_fa->mem) { + /* Yup; merge NEXT_FA's info into FA. */ + fa->size += next_fa->size; + fa->next = next_fa->next; + /* Free NEXT_FA. */ + next_fa->next = mb_sram_free_free_areas; + mb_sram_free_free_areas = next_fa; + } goto done; } else if (fa->mem > mem) /* We've reached the right spot in the free-list @@ -480,6 +492,7 @@ struct dma_mapping { void *cpu_addr; void *mb_sram_addr; + size_t size; struct dma_mapping *next; }; @@ -540,6 +553,7 @@ /* Initialize the mapping. Other fields should be filled in by caller. */ mapping->mb_sram_addr = mb_sram_block; + mapping->size = size; /* Add it to the list of active mappings. */ mapping->next = active_dma_mappings; @@ -596,10 +610,13 @@ } /* Return MAPPING to the freelist. */ -static inline void free_dma_mapping (struct dma_mapping *mapping) +static inline void +free_dma_mapping (struct dma_mapping *mapping) { int flags; + free_mb_sram (mapping->mb_sram_addr, mapping->size); + spin_lock_irqsave (dma_mappings_lock, flags); mapping->next = free_dma_mappings; @@ -616,7 +633,7 @@ this memory until either pci_unmap_single or pci_dma_sync_single is performed. */ dma_addr_t -pci_map_single (struct pci_dev *pdev, void *cpu_addr, long size, int dir) +pci_map_single (struct pci_dev *pdev, void *cpu_addr, size_t size, int dir) { struct dma_mapping *mapping = new_dma_mapping (size); @@ -639,6 +656,11 @@ void *mb_sram_addr = PCI_TO_MB_SRAM (dma_addr); struct dma_mapping *mapping = deactivate_dma_mapping (mb_sram_addr); + if (size != mapping->size) + panic ("pci_unmap_single: size (%d) doesn't match" + " size of mapping at PCI DMA addr 0x%x (%d)\n", + size, dma_addr, mapping->size); + /* Copy back the DMA'd contents if necessary. */ if (dir == PCI_DMA_BIDIRECTIONAL || dir == PCI_DMA_FROMDEVICE) memcpy (mapping->cpu_addr, mb_sram_addr, size); @@ -656,7 +678,7 @@ point you give the PCI dma address back to the card, the device again owns the buffer. */ void -pci_dma_sync_single (struct pci_dev *pdev, dma_addr_t dma_addr, long size, +pci_dma_sync_single (struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, int dir) { void *mb_sram_addr = PCI_TO_MB_SRAM (dma_addr); @@ -708,7 +730,7 @@ successful and sets *DMA_ADDR to the pci side dma address as well, else DMA_ADDR is undefined. */ void * -pci_alloc_consistent (struct pci_dev *pdev, long size, dma_addr_t *dma_addr) +pci_alloc_consistent (struct pci_dev *pdev, size_t size, dma_addr_t *dma_addr) { void *mb_sram_mem = alloc_mb_sram (size); if (mb_sram_mem) @@ -722,7 +744,7 @@ the memory and mappings assosciated with CPU_ADDR or DMA_ADDR past this call are illegal. */ void -pci_free_consistent (struct pci_dev *pdev, long size, void *cpu_addr, +pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr, dma_addr_t dma_addr) { void *mb_sram_mem = PCI_TO_MB_SRAM (dma_addr); Index: arch/v850/kernel/sim.c =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/kernel/sim.c,v retrieving revision 1.2 diff -u -r1.2 sim.c --- arch/v850/kernel/sim.c 2002/01/10 12:36:30 1.2 +++ arch/v850/kernel/sim.c 2002/01/29 08:41:24 @@ -29,7 +29,7 @@ /* The (arbitrary) size of RAM for our simulated machine. */ #define MEM_SIZE ((long)(8*1024*1024)) /* The name of a file containing the root filesystem. */ -#define ROOT_FS "root.ext2" +#define ROOT_FS "blkmem0.image" extern void simcons_setup (void); extern void simcons_poll_ttys (void); Index: arch/v850/sim/gdb-scripts/example.gdbinit =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/sim/gdb-scripts/example.gdbinit,v retrieving revision 1.1 diff -u -r1.1 example.gdbinit --- arch/v850/sim/gdb-scripts/example.gdbinit 2001/10/22 13:39:00 1.1 +++ arch/v850/sim/gdb-scripts/example.gdbinit 2002/01/29 08:41:24 @@ -1,3 +1,8 @@ +# Copy this file to `.gdbinit' in the directory where you will run linux +# (for instance, the top-level of the kernel build tree). Invoking gdb +# will then start the simulator and load linux into it. You should +# start gdb using a command like `v850e-elf-gdb linux'. + set height 0 set pagination off @@ -10,8 +15,9 @@ sim memory region 0,0x800000 sim memory region 0xFFFF0000,0x10000 -# These addresses are somewhat conservative, but might need to be -# changed if the kernel text-segment shrinks appreciably. +# Protect the kernel's text segment against writing. These addresses +# are somewhat conservative, but might need to be changed if the kernel +# text-segment shrinks appreciably. sim read-protect-low-memory 0x4a000 sim write-protect-low-memory 0x4a000 @@ -20,4 +26,5 @@ sim stdio off +# Change `linux' to match the name of the file containing the kernel. load linux Index: arch/v850/sim/gdb-scripts/trace-loadproc.gdb =================================================================== RCS file: /var/cvs/uClinux-2.4.x/arch/v850/sim/gdb-scripts/trace-loadproc.gdb,v retrieving revision 1.1 diff -u -r1.1 trace-loadproc.gdb --- arch/v850/sim/gdb-scripts/trace-loadproc.gdb 2001/10/22 13:39:00 1.1 +++ arch/v850/sim/gdb-scripts/trace-loadproc.gdb 2002/01/29 08:41:24 @@ -1,4 +1,4 @@ -break binfmt_flat.c:691 +break binfmt_flat.c:727 command silent printf "[loaded process `%s' at 0x%x (text 0x%x-0x%x, data 0x%x-0x%x, bss 0x%x-0x%x)]\n", bprm->filename, textpos, current->mm->start_code, current->mm->end_code, current->mm->start_data, current->mm->end_data, current->mm->end_data, current->mm->brk Index: drivers/char/nb85e_uart.c =================================================================== RCS file: /var/cvs/uClinux-2.4.x/drivers/char/nb85e_uart.c,v retrieving revision 1.1 diff -u -r1.1 nb85e_uart.c --- drivers/char/nb85e_uart.c 2001/10/22 13:39:02 1.1 +++ drivers/char/nb85e_uart.c 2002/01/29 08:41:37 @@ -1,8 +1,8 @@ /* * drivers/char/nb85e_uart.c -- Serial I/O using V850E/NB85E on-chip UART * - * Copyright (C) 2001 NEC Corporation - * Copyright (C) 2001 Miles Bader + * Copyright (C) 2001,2002 NEC Corporation + * Copyright (C) 2001,2002 Miles Bader * * This file is subject to the terms and conditions of the GNU General * Public License. See the file COPYING in the main directory of this @@ -551,9 +551,9 @@ d->driver_name = "nb85e_uart"; #ifdef CONFIG_DEVFS_FS - d->name = "ttu/%d"; + d->name = "tts/%d"; #else - d->name = "ttyU"; + d->name = "ttyS"; #endif d->major = TTY_MAJOR; Index: include/asm-v850/io.h =================================================================== RCS file: /var/cvs/uClinux-2.4.x/include/asm-v850/io.h,v retrieving revision 1.2 diff -u -r1.2 io.h --- include/asm-v850/io.h 2002/01/10 12:36:32 1.2 +++ include/asm-v850/io.h 2002/01/29 08:43:27 @@ -23,19 +23,26 @@ #define readl(addr) \ ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; }) -#define writeb(b,addr) \ +#define writeb(b, addr) \ (void)((*(volatile unsigned char *) (addr)) = (b)) -#define writew(b,addr) \ +#define writew(b, addr) \ (void)((*(volatile unsigned short *) (addr)) = (b)) -#define writel(b,addr) \ +#define writel(b, addr) \ (void)((*(volatile unsigned int *) (addr)) = (b)) #define inb(addr) readb (addr) #define inw(addr) readw (addr) #define inl(addr) readl (addr) -#define outb(x,addr) ((void) writeb (x,addr)) -#define outw(x,addr) ((void) writew (x,addr)) -#define outl(x,addr) ((void) writel (x,addr)) +#define outb(x, addr) ((void) writeb (x, addr)) +#define outw(x, addr) ((void) writew (x, addr)) +#define outl(x, addr) ((void) writel (x, addr)) + +#define inb_p(port) inb((port)) +#define outb_p(val, port) outb((val), (port)) +#define inw_p(port) inw((port)) +#define outw_p(val, port) outw((val), (port)) +#define inl_p(port) inl((port)) +#define outl_p(val, port) outl((val), (port)) static inline void insb (unsigned long port, void *dst, unsigned long count) { Index: include/asm-v850/pci.h =================================================================== RCS file: /var/cvs/uClinux-2.4.x/include/asm-v850/pci.h,v retrieving revision 1.1 diff -u -r1.1 pci.h --- include/asm-v850/pci.h 2002/01/10 12:36:32 1.1 +++ include/asm-v850/pci.h 2002/01/29 08:43:29 @@ -1,8 +1,8 @@ /* * include/asm-v850/pci.h -- PCI support * - * Copyright (C) 2001 NEC Corporation - * Copyright (C) 2001 Miles Bader + * Copyright (C) 2001,2002 NEC Corporation + * Copyright (C) 2001,2002 Miles Bader * * This file is subject to the terms and conditions of the GNU General * Public License. See the file COPYING in the main directory of this @@ -28,7 +28,7 @@ this memory until either pci_unmap_single or pci_dma_sync_single is performed. */ extern dma_addr_t -pci_map_single (struct pci_dev *pdev, void *cpu_addr, long size, int dir); +pci_map_single (struct pci_dev *pdev, void *cpu_addr, size_t size, int dir); /* Return to the CPU the PCI DMA memory block previously `granted' to PDEV, at DMA_ADDR. */ @@ -45,7 +45,7 @@ point you give the PCI dma address back to the card, the device again owns the buffer. */ extern void -pci_dma_sync_single (struct pci_dev *dev, dma_addr_t dma_addr, long size, +pci_dma_sync_single (struct pci_dev *dev, dma_addr_t dma_addr, size_t size, int dir); @@ -63,7 +63,7 @@ successful and sets *DMA_ADDR to the pci side dma address as well, else DMA_ADDR is undefined. */ extern void * -pci_alloc_consistent (struct pci_dev *pdev, long size, dma_addr_t *dma_addr); +pci_alloc_consistent (struct pci_dev *pdev, size_t size, dma_addr_t *dma_addr); /* Free and unmap a consistent DMA buffer. CPU_ADDR and DMA_ADDR must be values that were returned from pci_alloc_consistent. SIZE must be @@ -71,7 +71,7 @@ the memory and mappings assosciated with CPU_ADDR or DMA_ADDR past this call are illegal. */ extern void -pci_free_consistent (struct pci_dev *pdev, long size, void *cpu_addr, +pci_free_consistent (struct pci_dev *pdev, size_t size, void *cpu_addr, dma_addr_t dma_addr); #endif /* __V850_PCI_H__ */