-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,316 additions
and
1,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// armv6mmu.h | ||
// | ||
// USPi - An USB driver for Raspberry Pi written in C | ||
// Copyright (C) 2014-2015 R. Stange <[email protected]> | ||
// Copyright (C) 2014-2018 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// 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 | |
} | ||
PACKED TARMV6MMU_LEVEL1_SECTION_DESCRIPTOR; | ||
|
||
#define ARMV6MMUL1SECTION_NORMAL 0x0040E // outer and inner write back, no write allocate | ||
#define ARMV6MMUL1SECTION_NORMAL_XN 0x0041E // + execute never | ||
#define ARMV6MMUL1SECTION_DEVICE 0x10416 // shared device | ||
#define ARMV6MMUL1SECTION_COHERENT 0x10412 // strongly ordered | ||
|
||
#define ARMV6MMUL1SECTIONBASE(addr) (((addr) >> 20) & 0xFFF) | ||
#define ARMV6MMUL1SECTIONPTR(base) ((void *) ((base) << 20)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// memory.h | ||
// | ||
// USPi - An USB driver for Raspberry Pi written in C | ||
// Copyright (C) 2014-2015 R. Stange <[email protected]> | ||
// Copyright (C) 2014-2018 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -32,8 +32,7 @@ typedef struct TMemorySystem | |
boolean m_bEnableMMU; | ||
u32 m_nMemSize; | ||
|
||
TPageTable *m_pPageTable0Default; | ||
TPageTable *m_pPageTable1; | ||
TPageTable *m_pPageTable; | ||
} | ||
TMemorySystem; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// pagetable.h | ||
// | ||
// USPi - An USB driver for Raspberry Pi written in C | ||
// Copyright (C) 2014-2015 R. Stange <[email protected]> | ||
// Copyright (C) 2014-2018 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -20,7 +20,6 @@ | |
#ifndef _uspienv_pagetable_h | ||
#define _uspienv_pagetable_h | ||
|
||
#include <uspienv/armv6mmu.h> | ||
#include <uspienv/types.h> | ||
|
||
#ifdef __cplusplus | ||
|
@@ -29,17 +28,11 @@ extern "C" { | |
|
||
typedef struct TPageTable | ||
{ | ||
boolean m_bTableAllocated; | ||
TARMV6MMU_LEVEL1_SECTION_DESCRIPTOR *m_pTable; | ||
u32 *m_pTable; | ||
} | ||
TPageTable; | ||
|
||
// 4GB shared device | ||
void PageTable (TPageTable *pThis); | ||
|
||
// 0..nMemSize: normal, | ||
// nMemSize..512MB: shared device (1024MB on Raspberry Pi 2) | ||
void PageTable2 (TPageTable *pThis, u32 nMemSize); | ||
void PageTable (TPageTable *pThis, u32 nMemSize); | ||
|
||
void _PageTable (TPageTable *pThis); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// sysconfig.h | ||
// | ||
// USPi - An USB driver for Raspberry Pi written in C | ||
// Copyright (C) 2014-2016 R. Stange <[email protected]> | ||
// Copyright (C) 2014-2018 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -52,7 +52,7 @@ | |
// system options | ||
#if RASPPI == 1 // valid on Raspberry Pi 1 only | ||
//#define ARM_DISABLE_MMU | ||
#define ARM_STRICT_ALIGNMENT | ||
//#define ARM_STRICT_ALIGNMENT | ||
#define GPU_L2_CACHE_ENABLED | ||
#else | ||
#define CORES 4 // must be a power of 2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# Makefile | ||
# | ||
# USPi - An USB driver for Raspberry Pi written in C | ||
# Copyright (C) 2014-2015 R. Stange <[email protected]> | ||
# Copyright (C) 2014-2018 R. Stange <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
|
@@ -33,7 +33,12 @@ all: startup.o libuspienv.a | |
startup.o: startup.S | ||
|
||
libuspienv.a: $(OBJS) | ||
rm -f $@ | ||
$(AR) cr $@ $(OBJS) | ||
@echo " AR $@" | ||
@rm -f $@ | ||
@$(AR) cr $@ $(OBJS) | ||
|
||
include $(USPIHOME)/Rules.mk | ||
|
||
ifneq ($(strip $(AARCH64)),0) | ||
$(error AARCH64 is not supported in lib/env/) | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
// memory.c | ||
// | ||
// USPi - An USB driver for Raspberry Pi written in C | ||
// Copyright (C) 2014-2015 R. Stange <[email protected]> | ||
// Copyright (C) 2014-2018 R. Stange <[email protected]> | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
|
@@ -31,17 +31,15 @@ | |
| ARM_CONTROL_L1_INSTRUCTION_CACHE \ | ||
| ARM_CONTROL_BRANCH_PREDICTION \ | ||
| ARM_CONTROL_EXTENDED_PAGE_TABLE) | ||
|
||
#define TTBCR_SPLIT 3 | ||
#else | ||
#define MMU_MODE ( ARM_CONTROL_MMU \ | ||
| ARM_CONTROL_L1_CACHE \ | ||
| ARM_CONTROL_L1_INSTRUCTION_CACHE \ | ||
| ARM_CONTROL_BRANCH_PREDICTION) | ||
|
||
#define TTBCR_SPLIT 2 | ||
#endif | ||
|
||
#define TTBCR_SPLIT 0 | ||
|
||
void MemorySystemEnableMMU (TMemorySystem *pThis); | ||
|
||
void MemorySystem (TMemorySystem *pThis, boolean bEnableMMU) | ||
|
@@ -50,8 +48,7 @@ void MemorySystem (TMemorySystem *pThis, boolean bEnableMMU) | |
|
||
pThis->m_bEnableMMU = bEnableMMU; | ||
pThis->m_nMemSize = 0; | ||
pThis->m_pPageTable0Default = 0; | ||
pThis->m_pPageTable1 = 0; | ||
pThis->m_pPageTable = 0; | ||
|
||
TBcmPropertyTags Tags; | ||
BcmPropertyTags (&Tags); | ||
|
@@ -69,13 +66,9 @@ void MemorySystem (TMemorySystem *pThis, boolean bEnableMMU) | |
|
||
if (pThis->m_bEnableMMU) | ||
{ | ||
pThis->m_pPageTable0Default = (TPageTable *) malloc (sizeof (TPageTable)); | ||
assert (pThis->m_pPageTable0Default != 0); | ||
PageTable2 (pThis->m_pPageTable0Default, pThis->m_nMemSize); | ||
|
||
pThis->m_pPageTable1 = (TPageTable *) malloc (sizeof (TPageTable)); | ||
assert (pThis->m_pPageTable1 != 0); | ||
PageTable (pThis->m_pPageTable1); | ||
pThis->m_pPageTable = (TPageTable *) malloc (sizeof (TPageTable)); | ||
assert (pThis->m_pPageTable != 0); | ||
PageTable (pThis->m_pPageTable, pThis->m_nMemSize); | ||
|
||
MemorySystemEnableMMU (pThis); | ||
} | ||
|
@@ -99,13 +92,9 @@ void _MemorySystem (TMemorySystem *pThis) | |
asm volatile ("mcr p15, 0, %0, c8, c7, 0" : : "r" (0) : "memory"); | ||
} | ||
|
||
_PageTable (pThis->m_pPageTable1); | ||
free (pThis->m_pPageTable1); | ||
pThis->m_pPageTable1 = 0; | ||
|
||
_PageTable (pThis->m_pPageTable0Default); | ||
free (pThis->m_pPageTable0Default); | ||
pThis->m_pPageTable0Default = 0; | ||
_PageTable (pThis->m_pPageTable); | ||
free (pThis->m_pPageTable); | ||
pThis->m_pPageTable = 0; | ||
} | ||
|
||
u32 MemorySystemGetMemSize (TMemorySystem *pThis) | ||
|
@@ -138,16 +127,11 @@ void MemorySystemEnableMMU (TMemorySystem *pThis) | |
asm volatile ("mcr p15, 0, %0, c2, c0, 2" : : "r" (TTBCR_SPLIT)); | ||
|
||
// set TTBR0 | ||
assert (pThis->m_pPageTable0Default != 0); | ||
asm volatile ("mcr p15, 0, %0, c2, c0, 0" : : "r" (PageTableGetBaseAddress (pThis->m_pPageTable0Default))); | ||
assert (pThis->m_pPageTable != 0); | ||
asm volatile ("mcr p15, 0, %0, c2, c0, 0" : : "r" (PageTableGetBaseAddress (pThis->m_pPageTable))); | ||
|
||
// set TTBR1 | ||
assert (pThis->m_pPageTable1 != 0); | ||
asm volatile ("mcr p15, 0, %0, c2, c0, 1" : : "r" (PageTableGetBaseAddress (pThis->m_pPageTable1))); | ||
|
||
// set Domain Access Control register (Domain 0 and 1 to client) | ||
asm volatile ("mcr p15, 0, %0, c3, c0, 0" : : "r" ( DOMAIN_CLIENT << 0 | ||
| DOMAIN_CLIENT << 2)); | ||
asm volatile ("mcr p15, 0, %0, c3, c0, 0" : : "r" (DOMAIN_CLIENT << 0)); | ||
|
||
InvalidateDataCache (); | ||
FlushPrefetchBuffer (); | ||
|
Oops, something went wrong.