Commit f013d0b7 authored by Pavel Pisa's avatar Pavel Pisa

seminaries/qtmips/fb-simple: example to draw on QtMips LCD display.

Signed-off-by: Pavel Pisa's avatarPavel Pisa <pisa@cmp.felk.cvut.cz>
parent e8cc5155
ARCH=mips-elf
SOURCES = fb-simple.c crt0local.S
TARGET_EXE = fb-simple
CC=$(ARCH)-gcc
CXX=$(ARCH)-g++
AS=$(ARCH)-as
LD=$(ARCH)-ld
OBJCOPY=$(ARCH)-objcopy
#ARCHFLAGS += -march=mips3
ARCHFLAGS += -fno-lto
#ARCHFLAGS += -mno-shared
CFLAGS += -ggdb -O3 -Wall
CXXFLAGS+= -ggdb -O3 -Wall
AFLAGS += -ggdb
LDFLAGS += -ggdb
LDFLAGS += -nostartfiles
LDFLAGS += -static
CFLAGS += $(ARCHFLAGS)
CXXFLAGS+= $(ARCHFLAGS)
AFLAGS += $(ARCHFLAGS)
LDFLAGS += $(ARCHFLAGS)
OBJECTS += $(filter %.o,$(SOURCES:%.c=%.o))
OBJECTS += $(filter %.o,$(SOURCES:%.cpp=%.o))
OBJECTS += $(filter %.o,$(SOURCES:%.S=%.o))
all : default
.PHONY : default clean dep all
%.o:%.S
$(CC) -D__ASSEMBLY__ $(AFLAGS) -c $< -o $@
%.o:%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
%.o:%.cpp
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
%.s:%.c
$(CC) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
default : $(TARGET_EXE)
$(TARGET_EXE) : $(OBJECTS)
$(CC) $(LDFLAGS) $^ -o $@
dep: depend
depend: $(SOURCES) *.h
echo '# autogenerated dependencies' > depend
ifneq ($(filter %.c,$(SOURCES)),)
$(CC) $(CFLAGS) $(CPPFLAGS) -w -E -M $(filter %.c,$(SOURCES)) \
>> depend
endif
ifneq ($(filter %.cpp,$(SOURCES)),)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -w -E -M $(filter %.cpp,$(SOURCES)) \
>> depend
endif
clean:
rm -f *.o *.a $(OBJECTS) $(TARGET_EXE) depend
#mips-elf-objdump --source -M no-aliases,reg-names=numeric exam1-asm
-include depend
/* minimal replacement of crt0.o provided by C library */
#define zero $0
#define AT $1
#define v0 $2
#define v1 $3
#define a0 $4
#define a1 $5
#define a2 $6
#define a3 $7
#define t0 $8
#define t1 $9
#define t2 $10
#define t3 $11
#define t4 $12
#define t5 $13
#define t6 $14
#define t7 $15
#define t8 $24
#define t9 $25
#define k0 $26
#define k1 $27
#define s0 $16
#define s1 $17
#define s2 $18
#define s3 $19
#define s4 $20
#define s5 $21
#define s6 $22
#define s7 $23
#define gp $28
#define sp $29
#define fp $30
#define ra $31
.globl main
.globl __start
.globl _start
.set noat
.set noreorder
.ent __start
.text
__start:
_start:
bal next
nop
next: .set noreorder
.cpload $31
.set reorder
addi a0, zero, 0
addi a1, zero, 0
jal main
quit:
addi a0, zero, 0
addi v0, zero, 4001 /* SYS_exit */
syscall
loop: break
beq zero, zero, loop
nop
.end __start
#include <stdio.h>
#include <stdint.h>
int main(void)
{
volatile uint16_t *fb = (volatile uint16_t *)0xffe00000;
int x, y, i;
int width = 480;
int height = 320;
for (i = 0; i < width; i++) {
x = i;
y = 0;
fb[y * width + x] = 0xf800;
y = height - 1;
fb[y * width + x] = 0xf800;
}
for (i = 1; i < height -1; i++) {
x = 0;
y = i;
fb[y * width + x] = 0xf800;
x = width - 1;
fb[y * width + x] = 0xf800;
}
while (1) {
for (y = 1; y < height - 1; y++) {
for (i = 0; i < 200; i++) {
x = (y & 0xff) + i;
fb[y * width + x] = 0xffff;
}
for (i = 0; i < 10; i++) {
x = (y & 0xff) + i + 200;
fb[y * width + x] = 0xf800;
}
for (i = 0; i < 10; i++) {
x = (y & 0xff) + i + 210;
fb[y * width + x] = 0x07e0;
}
for (i = 0; i < 10; i++) {
x = (y & 0xff) + i + 220;
fb[y * width + x] = 0x001f;
}
}
// no reorder or combine memory accesses over this sequesntial point
//__asm__ __volatile__ ("" : : : "memory");
__asm__ __volatile__ ("break\n" : : : "memory");
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment