forked from randyrossi/bmc64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle_patch.diff
428 lines (381 loc) · 13.5 KB
/
circle_patch.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
diff --git a/addon/fatfs/ff.c b/addon/fatfs/ff.c
index 750eee1..8a156fa 100644
--- a/addon/fatfs/ff.c
+++ b/addon/fatfs/ff.c
@@ -224,6 +224,9 @@
#if FF_MULTI_PARTITION
#define LD2PD(vol) VolToPart[vol].pd /* Get physical drive number */
#define LD2PT(vol) VolToPart[vol].pt /* Get partition index */
+// BEGIN BCM64 Patch
+#define LD2SS(vol) VolToPart[vol].ss /* Get start sector */
+// END BCM64 Patch
#else
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
@@ -3275,12 +3278,26 @@ static FRESULT find_volume ( /* FR_OK(0): successful, !=0: an error occurred */
pt = fs->win + (MBR_Table + i * SZ_PTE);
br[i] = pt[PTE_System] ? ld_dword(pt + PTE_StLba) : 0;
}
- i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */
+ i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced, 5:forced start sector */
+// BEGIN BMC64 Patch
+#if FF_MULTI_PARTITION
+if (i == 5) {
+ // Forced start sector
+ bsect = LD2SS(vol);
+ fmt = bsect ? check_fs(fs, bsect) : 3;
+} else {
+// END BMC64 Patch
+#endif
if (i != 0) i--;
do { /* Find an FAT volume */
bsect = br[i];
fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */
} while (LD2PT(vol) == 0 && fmt >= 2 && ++i < 4);
+// BEGIN BMC64 Patch
+#if FF_MULTI_PARTITION
+}
+#endif
+// END BMC64 Patch
}
if (fmt == 4) return FR_DISK_ERR; /* An error occured in the disk I/O layer */
if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */
diff --git a/addon/fatfs/ff.h b/addon/fatfs/ff.h
index b3d75a9..8990c01 100644
--- a/addon/fatfs/ff.h
+++ b/addon/fatfs/ff.h
@@ -63,7 +63,10 @@ typedef unsigned long DWORD; /* 32-bit unsigned integer */
#if FF_MULTI_PARTITION /* Multiple partition configuration */
typedef struct {
BYTE pd; /* Physical drive number */
- BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
+// BEGIN BMC64 Patch
+ BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition, 5:Forced start sector, use ss) */
+ DWORD ss; /* Forced start sector if pt==5 */
+// END BMC64 Patch
} PARTITION;
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
#endif
diff --git a/addon/fatfs/ffconf.h b/addon/fatfs/ffconf.h
index eae1896..bbf174a 100644
--- a/addon/fatfs/ffconf.h
+++ b/addon/fatfs/ffconf.h
@@ -181,7 +181,7 @@
*/
-#define FF_MULTI_PARTITION 0
+#define FF_MULTI_PARTITION 1
/* This option switches support for multiple volumes on the physical drive.
/ By default (0), each logical drive number is bound to the same physical drive
/ number and only an FAT volume found on the physical drive will be mounted.
diff --git a/addon/linux/bug.h b/addon/linux/bug.h
index 6b80534..0e3e97a 100644
--- a/addon/linux/bug.h
+++ b/addon/linux/bug.h
@@ -9,7 +9,7 @@
extern "C" {
#endif
-#define BUG_ON(exp) assert (!(exp))
+#define BUG_ON(exp) ;
#define BUG() assert (0)
void __warn (const char *file, const int line);
diff --git a/addon/linux/types.h b/addon/linux/types.h
index f5068b4..9fed785 100644
--- a/addon/linux/types.h
+++ b/addon/linux/types.h
@@ -4,7 +4,8 @@
#include <circle/types.h>
#include <stdint.h>
-typedef unsigned long loff_t;
+// BMC64 - Why is this defined twice in our build?
+//typedef unsigned long loff_t;
typedef int gfp_t;
typedef uintptr dma_addr_t;
diff --git a/addon/vc4/interface/bcm_host/bcm_host.c b/addon/vc4/interface/bcm_host/bcm_host.c
index 7b5c415..81d122f 100644
--- a/addon/vc4/interface/bcm_host/bcm_host.c
+++ b/addon/vc4/interface/bcm_host/bcm_host.c
@@ -178,3 +178,14 @@ unsigned bcm_host_get_sdram_address(void)
}
#endif
+
+void bcm_get_sclker(char* buffer, int size) {
+ if (vc_gencmd (buffer, size, "scaling_kernel") != 0 )
+ printk("Failed to restore scaling kernel");
+}
+
+void bcm_set_sclker(const char* buffer) {
+ char tmp[1024];
+ if (vc_gencmd (tmp, sizeof(tmp), buffer) != 0 )
+ printk("Failed to set scaling kernel");
+}
diff --git a/addon/vc4/interface/bcm_host/bcm_host.h b/addon/vc4/interface/bcm_host/bcm_host.h
index cd601a1..89aac5d 100644
--- a/addon/vc4/interface/bcm_host/bcm_host.h
+++ b/addon/vc4/interface/bcm_host/bcm_host.h
@@ -38,6 +38,8 @@ extern "C" {
void bcm_host_init(void);
void bcm_host_deinit(void);
+void bcm_get_sclker(char* buffer, int size);
+void bcm_set_sclker(const char* buffer);
int32_t graphics_get_display_size( const uint16_t display_number,
uint32_t *width,
diff --git a/addon/vc4/interface/khronos/common/khrn_int_common.h b/addon/vc4/interface/khronos/common/khrn_int_common.h
index f8c1d59..487da4b 100644
--- a/addon/vc4/interface/khronos/common/khrn_int_common.h
+++ b/addon/vc4/interface/khronos/common/khrn_int_common.h
@@ -139,7 +139,8 @@ extern "C" {
#endif
#include "interface/vcos/vcos_assert.h"
-#include <string.h> /* size_t */
+// BMC64 - Why does this cause the compiler to choke?
+//#include <string.h> /* size_t */
#ifdef _MSC_VER
#define INLINE __inline
diff --git a/addon/vc4/interface/vmcs_host/vc_vchi_gencmd.c b/addon/vc4/interface/vmcs_host/vc_vchi_gencmd.c
index d4a142e..6c6284e 100644
--- a/addon/vc4/interface/vmcs_host/vc_vchi_gencmd.c
+++ b/addon/vc4/interface/vmcs_host/vc_vchi_gencmd.c
@@ -59,7 +59,7 @@ extern const char *gencmd_get_build_version(void);
/******************************************************************************
Local types and defines.
******************************************************************************/
-#define GENCMD_MAX_LENGTH 512
+#define GENCMD_MAX_LENGTH 511
typedef struct {
VCHI_SERVICE_HANDLE_T open_handle[VCHI_MAX_NUM_CONNECTIONS];
uint32_t msg_flag[VCHI_MAX_NUM_CONNECTIONS];
diff --git a/addon/vc4/vchiq/vchiq_2835_arm.c b/addon/vc4/vchiq/vchiq_2835_arm.c
index 4d716ff..79343b5 100644
--- a/addon/vc4/vchiq/vchiq_2835_arm.c
+++ b/addon/vc4/vchiq/vchiq_2835_arm.c
@@ -508,6 +508,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,
/* Group the pages into runs of contiguous pages */
+#if RASPPI <= 3
base_addr = VCHIQ_ARM_ADDRESS(page_address(pages[0]));
next_addr = base_addr + PAGE_SIZE;
addridx = 0;
@@ -529,6 +530,31 @@ create_pagelist(char __user *buf, size_t count, unsigned short type,
addrs[addridx] = (unsigned int)(uintptr_t)base_addr + run;
addridx++;
+#else
+ base_addr = page_address(pages[0]);
+ next_addr = base_addr + PAGE_SIZE;
+ addridx = 0;
+ run = 0;
+
+ for (i = 1; i < num_pages; i++) {
+ addr = page_address(pages[i]);
+ if ((addr == next_addr) && (run < 255)) {
+ next_addr += PAGE_SIZE;
+ run++;
+ } else {
+ BUG_ON (((uintptr_t)base_addr & 0xFFF) != 0);
+ addrs[addridx] = (unsigned int)((uintptr_t)base_addr >> 4) + run;
+ addridx++;
+ base_addr = addr;
+ next_addr = addr + PAGE_SIZE;
+ run = 0;
+ }
+ }
+
+ BUG_ON (((uintptr_t)base_addr & 0xFFF) != 0);
+ addrs[addridx] = (unsigned int)((uintptr_t)base_addr >> 4) + run;
+ addridx++;
+#endif
#ifndef __circle__
/* Partial cache lines (fragments) require special measures */
diff --git a/include/circle/memorymap.h b/include/circle/memorymap.h
index 3fe23ed..e934688 100644
--- a/include/circle/memorymap.h
+++ b/include/circle/memorymap.h
@@ -33,7 +33,7 @@
#define GIGABYTE 0x40000000ULL
#endif
-#define MEM_SIZE (256 * MEGABYTE) // default size
+#define MEM_SIZE (512 * MEGABYTE) // default size
#define GPU_MEM_SIZE (64 * MEGABYTE) // set in config.txt
#define ARM_MEM_SIZE (MEM_SIZE - GPU_MEM_SIZE) // normally overwritten
diff --git a/include/circle/sysconfig.h b/include/circle/sysconfig.h
index 2ef7052..c45440e 100644
--- a/include/circle/sysconfig.h
+++ b/include/circle/sysconfig.h
@@ -34,7 +34,7 @@
// If your kernel image contains big data areas it may be required to
// increase this value. The value must be a multiple of 16 KByte.
-#define KERNEL_MAX_SIZE (2 * MEGABYTE)
+#define KERNEL_MAX_SIZE (32 * MEGABYTE)
///////////////////////////////////////////////////////////////////////
//
@@ -88,7 +88,7 @@
// single core applications, because this may slow down the system
// because multiple cores may compete for bus time without use.
-//#define ARM_ALLOW_MULTI_CORE
+#define ARM_ALLOW_MULTI_CORE
#endif
@@ -126,7 +126,7 @@
// compatibility with existing applications it is not set by default.
// This option has no influence on the Raspberry Pi 4.
-//#define USE_USB_SOF_INTR
+#define USE_USB_SOF_INTR
#endif
@@ -144,7 +144,7 @@
// this option is that the "SpeedFactor" of your system is displayed.
// You can reduce the time needed for booting, if you disable this.
-#define CALIBRATE_DELAY
+//#define CALIBRATE_DELAY
///////////////////////////////////////////////////////////////////////
//
@@ -170,12 +170,12 @@
// The default keyboard map can be overwritten in with the keymap=
// option in cmdline.txt.
-#define DEFAULT_KEYMAP "DE"
+//#define DEFAULT_KEYMAP "DE"
//#define DEFAULT_KEYMAP "ES"
//#define DEFAULT_KEYMAP "FR"
//#define DEFAULT_KEYMAP "IT"
//#define DEFAULT_KEYMAP "UK"
-//#define DEFAULT_KEYMAP "US"
+#define DEFAULT_KEYMAP "US"
///////////////////////////////////////////////////////////////////////
//
diff --git a/include/circle/usb/usbhiddevice.h b/include/circle/usb/usbhiddevice.h
index 4e7f682..c8173b7 100644
--- a/include/circle/usb/usbhiddevice.h
+++ b/include/circle/usb/usbhiddevice.h
@@ -25,12 +25,15 @@
#include <circle/usb/usbrequest.h>
#include <circle/usb/usbhostcontroller.h>
#include <circle/types.h>
+//#ifdef BMC64_REPORT_THROTTLE
+//#include <circle/timer.h>
+//#endif
class CUSBHIDDevice : public CUSBFunction
{
public:
// nMaxReportSize can be handed-over here or to Configure()
- CUSBHIDDevice (CUSBFunction *pFunction, unsigned nMaxReportSize = 0);
+ CUSBHIDDevice (CUSBFunction *pFunction, unsigned nMaxReportSize = 0, bool bThrottleReports = false);
~CUSBHIDDevice (void);
boolean Configure (unsigned nMaxReportSize = 0);
@@ -68,6 +71,10 @@ private:
CUSBRequest *m_pURB;
u8 *m_pReportBuffer;
+
+ bool m_bThrottleReports;
+ CTimer* pTimer;
+ unsigned long nTimerStart;
};
#endif
diff --git a/lib/alloc.cpp b/lib/alloc.cpp
index eb6fe49..f6e0776 100644
--- a/lib/alloc.cpp
+++ b/lib/alloc.cpp
@@ -76,7 +76,7 @@ static unsigned s_nBlockReserve = 0x40000;
static unsigned char *s_pNextPage;
static unsigned char *s_pPageLimit;
-static TBlockBucket s_BlockBucket[] = {{0x40}, {0x400}, {0x1000}, {0x4000}, {0x10000}, {0x40000}, {0x80000}, {0}};
+static TBlockBucket s_BlockBucket[] = {{0x40}, {0x400}, {0x1000}, {0x4000}, {0x10000}, {0x40000}, {0x80000}, {0x100000}, {0x200000}, {0x400000}, {0x800000}, {0x1000000}, {0x1800000}, {0}};
static TPageBucket s_PageBucket;
diff --git a/lib/sysinit.cpp b/lib/sysinit.cpp
index 3c96caf..e9e4127 100644
--- a/lib/sysinit.cpp
+++ b/lib/sysinit.cpp
@@ -180,12 +180,15 @@ void sysinit (void)
#endif
// clear BSS
- extern unsigned char __bss_start;
- extern unsigned char _end;
- for (unsigned char *pBSS = &__bss_start; pBSS < &_end; pBSS++)
- {
- *pBSS = 0;
- }
+ asm(
+ "ldr r1, =__bss_start\n\t"
+ "ldr r2, =_end\n\t"
+ "mov r3, #0x00\n\t"
+ "_clear_bss:\n\t"
+ "cmp r1,r2\n\t"
+ "strne r3,[r1],#+4\n\t"
+ "bne _clear_bss\n\t"
+ );
CMachineInfo MachineInfo;
diff --git a/lib/usb/usbgamepad.cpp b/lib/usb/usbgamepad.cpp
index ff011e8..c6a0e8f 100644
--- a/lib/usb/usbgamepad.cpp
+++ b/lib/usb/usbgamepad.cpp
@@ -32,8 +32,14 @@ unsigned CUSBGamePadDevice::s_nDeviceNumber = 1;
static const char FromUSBPad[] = "usbpad";
static const char DevicePrefix[] = "upad";
+#ifdef BMC64_REPORT_THROTTLE
+#define THROTTLE_FLAG true
+#else
+#define THROTTLE_FLAG false
+#endif
+
CUSBGamePadDevice::CUSBGamePadDevice (CUSBFunction *pFunction)
-: CUSBHIDDevice (pFunction),
+: CUSBHIDDevice (pFunction, 0, THROTTLE_FLAG),
m_pStatusHandler (0),
m_usReportSize (0),
m_nDeviceNumber (0) // not assigned
diff --git a/lib/usb/usbgamepadxbox360.cpp b/lib/usb/usbgamepadxbox360.cpp
index 71b0af5..29632d2 100644
--- a/lib/usb/usbgamepadxbox360.cpp
+++ b/lib/usb/usbgamepadxbox360.cpp
@@ -36,7 +36,7 @@ struct TXbox360Report
#define REPORT_HEADER 0x1400
u16 Buttons;
-#define REPORT_BUTTONS 16
+#define REPORT_BUTTONS 17
#define REPORT_ANALOG_BUTTONS 2
u8 AnalogButton[REPORT_ANALOG_BUTTONS];
diff --git a/lib/usb/usbhiddevice.cpp b/lib/usb/usbhiddevice.cpp
index 2893a86..9aac786 100644
--- a/lib/usb/usbhiddevice.cpp
+++ b/lib/usb/usbhiddevice.cpp
@@ -25,19 +25,23 @@
static const char FromUSBHID[] = "usbhid";
-CUSBHIDDevice::CUSBHIDDevice (CUSBFunction *pFunction, unsigned nMaxReportSize)
+CUSBHIDDevice::CUSBHIDDevice (CUSBFunction *pFunction, unsigned nMaxReportSize, bool bThrottleReports)
: CUSBFunction (pFunction),
m_nMaxReportSize (nMaxReportSize),
m_pReportEndpoint (0),
m_pEndpointOut (0),
m_pURB (0),
- m_pReportBuffer (0)
+ m_pReportBuffer (0),
+ m_bThrottleReports (bThrottleReports)
{
if (m_nMaxReportSize > 0)
{
m_pReportBuffer = new u8[m_nMaxReportSize];
assert (m_pReportBuffer != 0);
}
+
+ pTimer = CTimer::Get();
+ nTimerStart = pTimer->GetClockTicks();
}
CUSBHIDDevice::~CUSBHIDDevice (void)
@@ -214,14 +218,18 @@ void CUSBHIDDevice::CompletionRoutine (CUSBRequest *pURB)
assert (pURB != 0);
assert (m_pURB == pURB);
- if (pURB->GetStatus () != 0)
- {
+ if (!m_bThrottleReports || (pTimer->GetClockTicks() - nTimerStart >= 20000L)) {
+ nTimerStart = pTimer->GetClockTicks();
+
+ if (pURB->GetStatus () != 0)
+ {
ReportHandler (m_pReportBuffer, pURB->GetResultLength ());
- }
- else
- {
+ }
+ else
+ {
ReportHandler (0, 0);
- }
+ }
+ }
delete m_pURB;
m_pURB = 0;