Skip to content

Commit 01fb7b4

Browse files
committed
Merge branch 'develop'
2 parents 893c298 + fb8545f commit 01fb7b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1316
-1014
lines changed

CREDITS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ Spanish keymap (taken from Circle)
1414
Joshua Otto
1515
Providing support for framebuffers where pitch != width * bytes per pixel
1616
USB MIDI device class support
17+
18+
Paolo Franchetti
19+
Suggesting improvements for the HID class device support and testing

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ Another option (NDEBUG) can be defined in Rules.mk to build the release version.
5858
Building
5959
--------
6060

61-
Building is normally done on PC Linux. If building for the Raspberry Pi 1 you need a [toolchain](http://elinux.org/Rpi_Software#ARM) for the ARM1176JZF core. For Raspberry Pi 2/3 you need a toolchain with Cortex-A7/-A53 support. A toolchain, which works for all of these, can be downloaded [here](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads). USPi has been tested with the version *6-2017-q1-update* from this website. You can also build USPi on the Raspberry Pi itself on Raspbian.
61+
> For AArch64 support go to the end of this file.
62+
63+
Building is normally done on PC Linux. If building for the Raspberry Pi 1 you need a [toolchain](http://elinux.org/Rpi_Software#ARM) for the ARM1176JZF core. For Raspberry Pi 2/3 you need a toolchain with Cortex-A7/-A53 support. A toolchain, which works for all of these, can be downloaded [here](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads). USPi has been tested with the version *7-2018-q2-update* from this website. You can also build USPi on the Raspberry Pi itself on Raspbian.
6264

6365
First edit the file *Rules.mk* and set the Raspberry Pi version (*RASPPI*, 1, 2 or 3) and the *PREFIX* of your toolchain commands. Alternatively you can create a *Config.mk* file (which is ignored by git) and set the Raspberry Pi version and the *PREFIX* variable to the prefix of your compiler like this (don't forget the dash at the end):
6466

Rules.mk

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@ AR = $(PREFIX)ar
4242
ifeq ($(strip $(AARCH64)),0)
4343
ifeq ($(strip $(RASPPI)),1)
4444
ARCH ?= -march=armv6j -mtune=arm1176jzf-s -mfloat-abi=hard
45+
TARGET ?= kernel
4546
else ifeq ($(strip $(RASPPI)),2)
4647
ARCH ?= -march=armv7-a -mtune=cortex-a7 -mfloat-abi=hard
48+
TARGET ?= kernel7
4749
else
4850
ARCH ?= -march=armv8-a -mtune=cortex-a53 -mfloat-abi=hard
51+
TARGET ?= kernel8-32
4952
endif
5053
else
5154
ARCH ?= -march=armv8-a -mtune=cortex-a53 -mlittle-endian -mcmodel=small -DAARCH64=1
@@ -58,10 +61,23 @@ CFLAGS += $(ARCH) -Wall -Wno-psabi -fsigned-char -fno-builtin -nostdinc -nostdli
5861
-std=gnu99 -undef -DRASPPI=$(RASPPI) -I $(USPIHOME)/include $(OPTIMIZE) #-DNDEBUG
5962

6063
%.o: %.S
61-
$(AS) $(AFLAGS) -c -o $@ $<
64+
@echo " AS $@"
65+
@$(AS) $(AFLAGS) -c -o $@ $<
6266

6367
%.o: %.c
64-
$(CC) $(CFLAGS) -c -o $@ $<
68+
@echo " CC $@"
69+
@$(CC) $(CFLAGS) -c -o $@ $<
70+
71+
$(TARGET).img: $(OBJS) $(LIBS)
72+
@echo " LD $(TARGET).elf"
73+
@$(LD) -o $(TARGET).elf -Map $(TARGET).map -T $(USPIHOME)/env/uspienv.ld \
74+
$(USPIHOME)/env/lib/startup.o $(OBJS) $(LIBS)
75+
@echo " DUMP $(TARGET).lst"
76+
@$(PREFIX)objdump -D $(TARGET).elf > $(TARGET).lst
77+
@echo " COPY $(TARGET).img"
78+
@$(PREFIX)objcopy $(TARGET).elf -O binary $(TARGET).img
79+
@echo -n " WC $(TARGET).img => "
80+
@wc -c < $(TARGET).img
6581

6682
clean:
6783
rm -f *.o *.a *.elf *.lst *.img *.cir *.map *~ $(EXTRACLEAN)

env/include/uspienv/armv6mmu.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// armv6mmu.h
33
//
44
// USPi - An USB driver for Raspberry Pi written in C
5-
// Copyright (C) 2014-2015 R. Stange <[email protected]>
5+
// Copyright (C) 2014-2018 R. Stange <[email protected]>
66
//
77
// This program is free software: you can redistribute it and/or modify
88
// it under the terms of the GNU General Public License as published by
@@ -66,6 +66,11 @@ typedef struct TARMV6MMU_LEVEL1_SECTION_DESCRIPTOR // subpages disabled
6666
}
6767
PACKED TARMV6MMU_LEVEL1_SECTION_DESCRIPTOR;
6868

69+
#define ARMV6MMUL1SECTION_NORMAL 0x0040E // outer and inner write back, no write allocate
70+
#define ARMV6MMUL1SECTION_NORMAL_XN 0x0041E // + execute never
71+
#define ARMV6MMUL1SECTION_DEVICE 0x10416 // shared device
72+
#define ARMV6MMUL1SECTION_COHERENT 0x10412 // strongly ordered
73+
6974
#define ARMV6MMUL1SECTIONBASE(addr) (((addr) >> 20) & 0xFFF)
7075
#define ARMV6MMUL1SECTIONPTR(base) ((void *) ((base) << 20))
7176

env/include/uspienv/memory.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// memory.h
33
//
44
// USPi - An USB driver for Raspberry Pi written in C
5-
// Copyright (C) 2014-2015 R. Stange <[email protected]>
5+
// Copyright (C) 2014-2018 R. Stange <[email protected]>
66
//
77
// This program is free software: you can redistribute it and/or modify
88
// it under the terms of the GNU General Public License as published by
@@ -32,8 +32,7 @@ typedef struct TMemorySystem
3232
boolean m_bEnableMMU;
3333
u32 m_nMemSize;
3434

35-
TPageTable *m_pPageTable0Default;
36-
TPageTable *m_pPageTable1;
35+
TPageTable *m_pPageTable;
3736
}
3837
TMemorySystem;
3938

env/include/uspienv/pagetable.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// pagetable.h
33
//
44
// USPi - An USB driver for Raspberry Pi written in C
5-
// Copyright (C) 2014-2015 R. Stange <[email protected]>
5+
// Copyright (C) 2014-2018 R. Stange <[email protected]>
66
//
77
// This program is free software: you can redistribute it and/or modify
88
// it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
2020
#ifndef _uspienv_pagetable_h
2121
#define _uspienv_pagetable_h
2222

23-
#include <uspienv/armv6mmu.h>
2423
#include <uspienv/types.h>
2524

2625
#ifdef __cplusplus
@@ -29,17 +28,11 @@ extern "C" {
2928

3029
typedef struct TPageTable
3130
{
32-
boolean m_bTableAllocated;
33-
TARMV6MMU_LEVEL1_SECTION_DESCRIPTOR *m_pTable;
31+
u32 *m_pTable;
3432
}
3533
TPageTable;
3634

37-
// 4GB shared device
38-
void PageTable (TPageTable *pThis);
39-
40-
// 0..nMemSize: normal,
41-
// nMemSize..512MB: shared device (1024MB on Raspberry Pi 2)
42-
void PageTable2 (TPageTable *pThis, u32 nMemSize);
35+
void PageTable (TPageTable *pThis, u32 nMemSize);
4336

4437
void _PageTable (TPageTable *pThis);
4538

env/include/uspienv/sysconfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// sysconfig.h
33
//
44
// USPi - An USB driver for Raspberry Pi written in C
5-
// Copyright (C) 2014-2016 R. Stange <[email protected]>
5+
// Copyright (C) 2014-2018 R. Stange <[email protected]>
66
//
77
// This program is free software: you can redistribute it and/or modify
88
// it under the terms of the GNU General Public License as published by
@@ -52,7 +52,7 @@
5252
// system options
5353
#if RASPPI == 1 // valid on Raspberry Pi 1 only
5454
//#define ARM_DISABLE_MMU
55-
#define ARM_STRICT_ALIGNMENT
55+
//#define ARM_STRICT_ALIGNMENT
5656
#define GPU_L2_CACHE_ENABLED
5757
#else
5858
#define CORES 4 // must be a power of 2

env/lib/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Makefile
33
#
44
# USPi - An USB driver for Raspberry Pi written in C
5-
# Copyright (C) 2014-2015 R. Stange <[email protected]>
5+
# Copyright (C) 2014-2018 R. Stange <[email protected]>
66
#
77
# This program is free software: you can redistribute it and/or modify
88
# it under the terms of the GNU General Public License as published by
@@ -33,7 +33,12 @@ all: startup.o libuspienv.a
3333
startup.o: startup.S
3434

3535
libuspienv.a: $(OBJS)
36-
rm -f $@
37-
$(AR) cr $@ $(OBJS)
36+
@echo " AR $@"
37+
@rm -f $@
38+
@$(AR) cr $@ $(OBJS)
3839

3940
include $(USPIHOME)/Rules.mk
41+
42+
ifneq ($(strip $(AARCH64)),0)
43+
$(error AARCH64 is not supported in lib/env/)
44+
endif

env/lib/memory.c

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// memory.c
33
//
44
// USPi - An USB driver for Raspberry Pi written in C
5-
// Copyright (C) 2014-2015 R. Stange <[email protected]>
5+
// Copyright (C) 2014-2018 R. Stange <[email protected]>
66
//
77
// This program is free software: you can redistribute it and/or modify
88
// it under the terms of the GNU General Public License as published by
@@ -31,17 +31,15 @@
3131
| ARM_CONTROL_L1_INSTRUCTION_CACHE \
3232
| ARM_CONTROL_BRANCH_PREDICTION \
3333
| ARM_CONTROL_EXTENDED_PAGE_TABLE)
34-
35-
#define TTBCR_SPLIT 3
3634
#else
3735
#define MMU_MODE ( ARM_CONTROL_MMU \
3836
| ARM_CONTROL_L1_CACHE \
3937
| ARM_CONTROL_L1_INSTRUCTION_CACHE \
4038
| ARM_CONTROL_BRANCH_PREDICTION)
41-
42-
#define TTBCR_SPLIT 2
4339
#endif
4440

41+
#define TTBCR_SPLIT 0
42+
4543
void MemorySystemEnableMMU (TMemorySystem *pThis);
4644

4745
void MemorySystem (TMemorySystem *pThis, boolean bEnableMMU)
@@ -50,8 +48,7 @@ void MemorySystem (TMemorySystem *pThis, boolean bEnableMMU)
5048

5149
pThis->m_bEnableMMU = bEnableMMU;
5250
pThis->m_nMemSize = 0;
53-
pThis->m_pPageTable0Default = 0;
54-
pThis->m_pPageTable1 = 0;
51+
pThis->m_pPageTable = 0;
5552

5653
TBcmPropertyTags Tags;
5754
BcmPropertyTags (&Tags);
@@ -69,13 +66,9 @@ void MemorySystem (TMemorySystem *pThis, boolean bEnableMMU)
6966

7067
if (pThis->m_bEnableMMU)
7168
{
72-
pThis->m_pPageTable0Default = (TPageTable *) malloc (sizeof (TPageTable));
73-
assert (pThis->m_pPageTable0Default != 0);
74-
PageTable2 (pThis->m_pPageTable0Default, pThis->m_nMemSize);
75-
76-
pThis->m_pPageTable1 = (TPageTable *) malloc (sizeof (TPageTable));
77-
assert (pThis->m_pPageTable1 != 0);
78-
PageTable (pThis->m_pPageTable1);
69+
pThis->m_pPageTable = (TPageTable *) malloc (sizeof (TPageTable));
70+
assert (pThis->m_pPageTable != 0);
71+
PageTable (pThis->m_pPageTable, pThis->m_nMemSize);
7972

8073
MemorySystemEnableMMU (pThis);
8174
}
@@ -99,13 +92,9 @@ void _MemorySystem (TMemorySystem *pThis)
9992
asm volatile ("mcr p15, 0, %0, c8, c7, 0" : : "r" (0) : "memory");
10093
}
10194

102-
_PageTable (pThis->m_pPageTable1);
103-
free (pThis->m_pPageTable1);
104-
pThis->m_pPageTable1 = 0;
105-
106-
_PageTable (pThis->m_pPageTable0Default);
107-
free (pThis->m_pPageTable0Default);
108-
pThis->m_pPageTable0Default = 0;
95+
_PageTable (pThis->m_pPageTable);
96+
free (pThis->m_pPageTable);
97+
pThis->m_pPageTable = 0;
10998
}
11099

111100
u32 MemorySystemGetMemSize (TMemorySystem *pThis)
@@ -138,16 +127,11 @@ void MemorySystemEnableMMU (TMemorySystem *pThis)
138127
asm volatile ("mcr p15, 0, %0, c2, c0, 2" : : "r" (TTBCR_SPLIT));
139128

140129
// set TTBR0
141-
assert (pThis->m_pPageTable0Default != 0);
142-
asm volatile ("mcr p15, 0, %0, c2, c0, 0" : : "r" (PageTableGetBaseAddress (pThis->m_pPageTable0Default)));
130+
assert (pThis->m_pPageTable != 0);
131+
asm volatile ("mcr p15, 0, %0, c2, c0, 0" : : "r" (PageTableGetBaseAddress (pThis->m_pPageTable)));
143132

144-
// set TTBR1
145-
assert (pThis->m_pPageTable1 != 0);
146-
asm volatile ("mcr p15, 0, %0, c2, c0, 1" : : "r" (PageTableGetBaseAddress (pThis->m_pPageTable1)));
147-
148133
// set Domain Access Control register (Domain 0 and 1 to client)
149-
asm volatile ("mcr p15, 0, %0, c3, c0, 0" : : "r" ( DOMAIN_CLIENT << 0
150-
| DOMAIN_CLIENT << 2));
134+
asm volatile ("mcr p15, 0, %0, c3, c0, 0" : : "r" (DOMAIN_CLIENT << 0));
151135

152136
InvalidateDataCache ();
153137
FlushPrefetchBuffer ();

0 commit comments

Comments
 (0)