Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/misoc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0a14c3714b26
Choose a base ref
...
head repository: m-labs/misoc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2315544b36f4
Choose a head ref
  • 3 commits
  • 7 files changed
  • 1 contributor

Commits on Mar 21, 2013

  1. software/bios: change boot order

    Sebastien Bourdeauducq committed Mar 21, 2013
    Copy the full SHA
    bb566c9 View commit details
  2. software: add videomixer base files

    Sebastien Bourdeauducq committed Mar 21, 2013
    Copy the full SHA
    a6a3d93 View commit details
  3. software/videomixer: quick hack for phase detection

    Sebastien Bourdeauducq committed Mar 21, 2013
    Copy the full SHA
    2315544 View commit details
Showing with 418 additions and 2 deletions.
  1. +2 −2 software/bios/main.c
  2. +35 −0 software/include/hw/dvisampler.h
  3. +44 −0 software/videomixer/Makefile
  4. +167 −0 software/videomixer/crt0.S
  5. +15 −0 software/videomixer/isr.c
  6. +56 −0 software/videomixer/linker.ld
  7. +99 −0 software/videomixer/main.c
4 changes: 2 additions & 2 deletions software/bios/main.c
Original file line number Diff line number Diff line change
@@ -498,13 +498,13 @@ static void boot_sequence(void)
{
if(test_user_abort()) {
if(rescue) {
netboot();
serialboot();
netboot();
flashboot();
} else {
flashboot();
netboot();
serialboot();
netboot();
}
printf("No boot medium found\n");
}
35 changes: 35 additions & 0 deletions software/include/hw/dvisampler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef __HW_DVISAMPLER_H
#define __HW_DVISAMPLER_H

#include <hw/common.h>
#include <csrbase.h>

#define DVISAMPLER0_CSR(x) MMPTR(DVISAMPLER0_BASE+(x))

#define CSR_DVISAMPLER0_PLL_RESET DVISAMPLER0_CSR(0x00)
#define CSR_DVISAMPLER0_PLL_LOCKED DVISAMPLER0_CSR(0x04)

#define CSR_DVISAMPLER0_D0_DELAY_CTL DVISAMPLER0_CSR(0x08)
#define CSR_DVISAMPLER0_D0_DELAY_BUSY DVISAMPLER0_CSR(0x0C)
#define CSR_DVISAMPLER0_D0_PHASE DVISAMPLER0_CSR(0x10)
#define CSR_DVISAMPLER0_D0_PHASE_RESET DVISAMPLER0_CSR(0x14)

#define CSR_DVISAMPLER0_D1_DELAY_CTL DVISAMPLER0_CSR(0x18)
#define CSR_DVISAMPLER0_D1_DELAY_BUSY DVISAMPLER0_CSR(0x1C)
#define CSR_DVISAMPLER0_D1_PHASE DVISAMPLER0_CSR(0x20)
#define CSR_DVISAMPLER0_D1_PHASE_RESET DVISAMPLER0_CSR(0x24)

#define CSR_DVISAMPLER0_D2_DELAY_CTL DVISAMPLER0_CSR(0x28)
#define CSR_DVISAMPLER0_D2_DELAY_BUSY DVISAMPLER0_CSR(0x2C)
#define CSR_DVISAMPLER0_D2_PHASE DVISAMPLER0_CSR(0x30)
#define CSR_DVISAMPLER0_D2_PHASE_RESET DVISAMPLER0_CSR(0x34)

#define DVISAMPLER_DELAY_CAL 0x01
#define DVISAMPLER_DELAY_RST 0x02
#define DVISAMPLER_DELAY_INC 0x04
#define DVISAMPLER_DELAY_DEC 0x08

#define DVISAMPLER_TOO_LATE 0x01
#define DVISAMPLER_TOO_EARLY 0x02

#endif /* __HW_DVISAMPLER_H */
44 changes: 44 additions & 0 deletions software/videomixer/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
M2DIR=../..
include $(M2DIR)/software/common.mak

OBJECTS=crt0.o isr.o main.o

all: videomixer.bin

# pull in dependency info for *existing* .o files
-include $(OBJECTS:.o=.d)

%.bin: %.elf
$(OBJCOPY) -O binary $< $@
chmod -x $@

videomixer.elf: linker.ld $(OBJECTS) libs

%.elf:
$(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) \
-L$(M2DIR)/software/libbase \
-L$(M2DIR)/software/libcompiler-rt \
-lbase -lcompiler-rt
chmod -x $@

main.o: main.c
$(compile-dep)

%.o: %.c
$(compile-dep)

%.o: %.S
$(assemble)

libs:
make -C $(M2DIR)/software/libcompiler-rt
make -C $(M2DIR)/software/libbase

load: videomixer.bin
make -C $(M2DIR)/tools
$(M2DIR)/tools/flterm --port /dev/ttyUSB0 --kernel videomixer.bin

clean:
rm -f $(OBJECTS) $(OBJECTS:.o=.d) videomixer.elf videomixer.bin .*~ *~

.PHONY: main.o clean libs load
167 changes: 167 additions & 0 deletions software/videomixer/crt0.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* LatticeMico32 C startup code.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/

/* Exception handlers - Must be 32 bytes long. */
.section .text, "ax", @progbits
.global _start
_start:
_reset_handler:
xor r0, r0, r0
wcsr IE, r0
mvhi r1, hi(_reset_handler)
ori r1, r1, lo(_reset_handler)
wcsr EBA, r1
bi _crt0
nop
nop

_breakpoint_handler:
bi _breakpoint_handler
nop
nop
nop
nop
nop
nop
nop

_instruction_bus_error_handler:
bi _instruction_bus_error_handler
nop
nop
nop
nop
nop
nop
nop

_watchpoint_hander:
bi _watchpoint_hander
nop
nop
nop
nop
nop
nop
nop

_data_bus_error_handler:
bi _data_bus_error_handler
nop
nop
nop
nop
nop
nop
nop

_divide_by_zero_handler:
bi _divide_by_zero_handler
nop
nop
nop
nop
nop
nop
nop

_interrupt_handler:
sw (sp+0), ra
calli .save_all
calli isr
bi .restore_all_and_eret
nop
nop
nop
nop

macaddress:
.byte 0x10
.byte 0xe2
.byte 0xd5
.byte 0x00
.byte 0x00
.byte 0x00

/* padding to align to a 32-bit boundary */
.byte 0x00
.byte 0x00

_crt0:
/* Setup stack and global pointer */
mvhi sp, hi(_fstack)
ori sp, sp, lo(_fstack)
mvhi gp, hi(_gp)
ori gp, gp, lo(_gp)

/* Clear BSS */
mvhi r1, hi(_fbss)
ori r1, r1, lo(_fbss)
mvhi r3, hi(_ebss)
ori r3, r3, lo(_ebss)
.clearBSS:
be r1, r3, .callMain
sw (r1+0), r0
addi r1, r1, 4
bi .clearBSS

.callMain:
bi main

.save_all:
addi sp, sp, -56
sw (sp+4), r1
sw (sp+8), r2
sw (sp+12), r3
sw (sp+16), r4
sw (sp+20), r5
sw (sp+24), r6
sw (sp+28), r7
sw (sp+32), r8
sw (sp+36), r9
sw (sp+40), r10
sw (sp+48), ea
sw (sp+52), ba
/* ra needs to be moved from initial stack location */
lw r1, (sp+56)
sw (sp+44), r1
ret

.restore_all_and_eret:
lw r1, (sp+4)
lw r2, (sp+8)
lw r3, (sp+12)
lw r4, (sp+16)
lw r5, (sp+20)
lw r6, (sp+24)
lw r7, (sp+28)
lw r8, (sp+32)
lw r9, (sp+36)
lw r10, (sp+40)
lw ra, (sp+44)
lw ea, (sp+48)
lw ba, (sp+52)
addi sp, sp, 56
eret
15 changes: 15 additions & 0 deletions software/videomixer/isr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <hw/uart.h>
#include <interrupt.h>
#include <irq.h>
#include <uart.h>

void isr(void);
void isr(void)
{
unsigned int irqs;

irqs = irq_pending() & irq_getmask();

if(irqs & (1 << UART_INTERRUPT))
uart_isr();
}
56 changes: 56 additions & 0 deletions software/videomixer/linker.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
OUTPUT_FORMAT("elf32-lm32")
ENTRY(_start)

__DYNAMIC = 0;

MEMORY {
sdram : ORIGIN = 0x40000000, LENGTH = 0x08000000 /* 128M */
}

SECTIONS
{
.text :
{
_ftext = .;
*(.text .stub .text.* .gnu.linkonce.t.*)
_etext = .;
} > sdram

.rodata :
{
. = ALIGN(4);
_frodata = .;
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.rodata1)
_erodata = .;
} > sdram

.data :
{
. = ALIGN(4);
_fdata = .;
*(.data .data.* .gnu.linkonce.d.*)
*(.data1)
_gp = ALIGN(16);
*(.sdata .sdata.* .gnu.linkonce.s.*)
_edata = .;
} > sdram

.bss :
{
. = ALIGN(4);
_fbss = .;
*(.dynsbss)
*(.sbss .sbss.* .gnu.linkonce.sb.*)
*(.scommon)
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
. = ALIGN(8);
_heapstart = .;
} > sdram
}

PROVIDE(_fstack = ORIGIN(sdram) + LENGTH(sdram) - 4);
Loading