Skip to content

Commit 5b8791d

Browse files
committed
Updated kernel API
Added variable arguments console print functions Added generic usb and keyboard initialization functions Keyboard mappings moved to kernel Log functions moved to kernel
1 parent d95bb8d commit 5b8791d

File tree

14 files changed

+428
-229
lines changed

14 files changed

+428
-229
lines changed

SDL2/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OBJCOPY := $(TOOLCHAIN)-objcopy
1111
DEPDIR := .deps
1212

1313
ASFLAGS = --warn -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp
14-
CFLAGS = -O3 -Iinclude -Isrc -I../uspi/include -ffreestanding -fvisibility=hidden -marm -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp -D_REENTRANT -D__RASPBERRY_PI__
14+
CFLAGS = -O3 -Iinclude -Isrc -I../uspi/include -ffreestanding -fvisibility=hidden -marm -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp -D_REENTRANT -D__RASPBERRY_PI__ -DHAVE_USPI
1515
CPPFLAGS = $(CFLAGS) -fno-exceptions -fno-unwind-tables -fno-rtti
1616

1717
all: libSDL2.a

SDL2/include/SDL_config_raspberry.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1
147147
#endif
148148

149-
#define HAVE_USPI
150149
#define HAVE_NES
151150

152151
/* SDL internal assertion support */

SDL2/src/core/raspberry/SDL_raspberry.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,6 @@ void Raspberry_digitalWrite(int pin, int value) {
179179
}
180180
}
181181

182-
#ifdef HAVE_USPI
183-
184-
void LogWrite (const char *pSource, unsigned Severity, const char *pMessage, ...)
185-
{
186-
// Do nothing
187-
}
188-
189-
void uspi_assertion_failed (const char *pExpr, const char *pFile, unsigned nLine)
190-
{
191-
while(1);
192-
}
193-
194-
void DebugHexdump (const void *pBuffer, unsigned nBufLen, const char *pSource /* = 0 */)
195-
{
196-
// Do nothing
197-
}
198-
199-
#endif // HAVE_USPI
200-
201182
void SDL_Interrupt_Handler() {
202183
if ((IRQ->irq1Pending & INTERRUPT_DMA0) != 0)
203184
RASPBERRYAUD_DmaInterruptHandler();
@@ -206,8 +187,3 @@ void SDL_Interrupt_Handler() {
206187
USPiInterruptHandler ();
207188
#endif
208189
}
209-
210-
void log_printf (const char *ptr, ...)
211-
{
212-
// Do nothing
213-
}

kernel/.cproject

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@
1414
</extensions>
1515
</storageModule>
1616
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
17-
<configuration artifactName="${ProjName}" buildProperties="" id="cdt.managedbuild.toolchain.gnu.cross.base.299000108" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
17+
<configuration artifactName="${ProjName}" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.cross.base.299000108" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
1818
<folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.299000108.1748345975" name="/" resourcePath="">
1919
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.base.1355025596" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.base">
2020
<option id="cdt.managedbuild.option.gnu.cross.prefix.1520318216" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix"/>
2121
<option id="cdt.managedbuild.option.gnu.cross.path.470053298" name="Path" superClass="cdt.managedbuild.option.gnu.cross.path"/>
2222
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1030335959" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
23-
<builder id="cdt.managedbuild.builder.gnu.cross.1500447050" managedBuildOn="false" name="Gnu Make Builder.Default" superClass="cdt.managedbuild.builder.gnu.cross"/>
23+
<builder id="cdt.managedbuild.builder.gnu.cross.1500447050" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
2424
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1465669417" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
25+
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1958204956" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
26+
<listOptionValue builtIn="false" value="HAVE_USPI"/>
27+
</option>
28+
<option id="gnu.c.compiler.option.include.paths.461836132" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
29+
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/uspi/include}&quot;"/>
30+
</option>
2531
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.460505247" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
2632
</tool>
2733
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.2044554671" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler"/>
@@ -46,10 +52,13 @@
4652
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
4753
<project id="kernel.null.1901389621" name="kernel"/>
4854
</storageModule>
49-
<storageModule moduleId="scannerConfiguration">
50-
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
51-
</storageModule>
5255
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
5356
<storageModule moduleId="refreshScope"/>
5457
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
58+
<storageModule moduleId="scannerConfiguration">
59+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
60+
<scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.299000108;cdt.managedbuild.toolchain.gnu.cross.base.299000108.1748345975;cdt.managedbuild.tool.gnu.cross.c.compiler.1465669417;cdt.managedbuild.tool.gnu.c.compiler.input.460505247">
61+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
62+
</scannerConfigBuildInfo>
63+
</storageModule>
5564
</cproject>

kernel/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ OBJS = \
88
fb.o \
99
ff.o \
1010
platform.o \
11-
wiring.o
11+
usb.o \
12+
wiring.o \
1213

1314
-include common.mk
1415
-include $(DEPDIR)/*.Po
@@ -17,5 +18,5 @@ libkernel.a: $(OBJS) start.o syscalls.o Makefile raspberry.ld
1718
$(AR) rcs -o $@ $(OBJS)
1819

1920
clean:
20-
rm -f *.o libkernel.a
21+
rm -f $(OBJS) libkernel.a
2122
rm -rf $(DEPDIR)

kernel/common.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OBJCOPY := $(TOOLCHAIN)-objcopy
1111
DEPDIR := .deps
1212

1313
ASFLAGS = --warn -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp
14-
CFLAGS = -Wall -O2 -ffreestanding -marm -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp -fsigned-char -D__RASPBERRY_PI__ -I../kernel -I../uspi/include
14+
CFLAGS = -Wall -O2 -ffreestanding -marm -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp -fsigned-char -D__RASPBERRY_PI__ -DHAVE_USPI -I../kernel -I../uspi/include
1515
CPPFLAGS = $(CFLAGS) -fno-exceptions -fno-unwind-tables -fno-rtti
1616
LDFLAGS = -T ../kernel/raspberry.ld -nostartfiles -fno-exceptions -fno-unwind-tables -fno-rtti -Wl,-Map=kernel.map -o kernel.elf
1717

kernel/console.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18+
#include <stdio.h>
19+
#include <stdarg.h>
1820
#include <string.h>
1921

2022
#include "console.h"
@@ -343,6 +345,7 @@ int mvaddch(int y, int x, int c) {
343345

344346
void refresh() {
345347
// Do nothing, updates are immediate
348+
fb_flip();
346349
}
347350

348351
void toggle_cursor() {
@@ -387,3 +390,25 @@ void hide_cursor() {
387390
cursor_visible = 0;
388391
}
389392
}
393+
394+
int addstrf(const char *ptr, ...) {
395+
va_list var;
396+
char buffer[256];
397+
398+
va_start (var, ptr);
399+
vsnprintf (buffer, sizeof(buffer) - 1, ptr, var);
400+
va_end (var);
401+
402+
return addstr(buffer);
403+
}
404+
405+
int mvaddstrf(int y, int x, const char *ptr, ...) {
406+
va_list var;
407+
char buffer[256];
408+
409+
va_start (var, ptr);
410+
vsnprintf (buffer, sizeof(buffer) - 1, ptr, var);
411+
va_end (var);
412+
413+
return mvaddstr(y, x, buffer);
414+
}

kernel/console.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,32 @@
2020

2121
#include "fb.h"
2222

23+
#define KEY_ESC 0x2900
24+
25+
#define KEY_F1 0x3A00
26+
#define KEY_F2 0x3B00
27+
#define KEY_F3 0x3C00
28+
#define KEY_F4 0x3D00
29+
#define KEY_F5 0x3E00
30+
#define KEY_F6 0x3F00
31+
#define KEY_F7 0x4000
32+
#define KEY_F8 0x4100
33+
#define KEY_F9 0x4200
34+
#define KEY_F10 0x4300
35+
#define KEY_F11 0x4400
36+
#define KEY_F12 0x4500
37+
38+
#define KEY_CANC 0x4C00
39+
#define KEY_INS 0x4900
40+
#define KEY_PGDN 0x4E00
41+
#define KEY_PGUP 0x4B00
42+
#define KEY_END 0x4D00
43+
#define KEY_HOME 0x4A00
44+
#define KEY_RIGHT 0x4F00
45+
#define KEY_LEFT 0x5000
46+
#define KEY_DOWN 0x5100
47+
#define KEY_UP 0x5200
48+
2349
extern int con_width;
2450
extern int con_height;
2551
extern int txt_width;
@@ -43,6 +69,11 @@ int addstr(const char *s);
4369
int mvaddch(int y, int x, int c);
4470
int mvaddstr(int y, int x, const char *s);
4571

72+
int addstrf(const char *ptr, ...);
73+
int mvaddstrf(int y, int x, const char *ptr, ...);
74+
75+
int getch();
76+
4677
void refresh();
4778

4879
#define getyx(y,x) y = cur_y; x = cur_x

kernel/kernel.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2014 Marco Maccaferri and Others
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#ifndef KERNEL_H_
19+
#define KERNEL_H_
20+
21+
#include "fb.h"
22+
#include "console.h"
23+
#include "audio.h"
24+
#include "emmc.h"
25+
#include "ff.h"
26+
27+
#ifdef HAVE_USPI
28+
#include "uspi.h"
29+
#endif
30+
31+
#if defined(__cplusplus)
32+
extern "C" {
33+
#endif
34+
35+
int usb_init();
36+
37+
int keyboard_init();
38+
39+
#if defined(__cplusplus)
40+
}
41+
#endif
42+
43+
#endif /* KERNEL_H_ */

kernel/syscalls.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525

2626
#include "emmc.h"
2727
#include "ff.h"
28+
29+
#ifdef HAVE_USPI
2830
#include "uspi.h"
31+
#endif
2932

3033
extern struct emmc_block_dev emmc_dev;
3134

@@ -306,12 +309,14 @@ DSTATUS disk_status (
306309
case MMC :
307310
return 0;
308311

312+
#ifdef HAVE_USPI
309313
default :
310314
if (!USPiMassStorageDeviceAvailable())
311315
{
312316
return STA_NOINIT;
313317
}
314318
return 0;
319+
#endif
315320
}
316321
return STA_NOINIT;
317322
}
@@ -330,12 +335,14 @@ DSTATUS disk_initialize (
330335
case MMC :
331336
return 0;
332337

338+
#ifdef HAVE_USPI
333339
default :
334340
if (!USPiMassStorageDeviceAvailable())
335341
{
336342
return STA_NOINIT;
337343
}
338344
return 0;
345+
#endif
339346
}
340347
return STA_NOINIT;
341348
}
@@ -365,6 +372,7 @@ DRESULT disk_read (
365372
return RES_OK;
366373
}
367374

375+
#ifdef HAVE_USPI
368376
default :
369377
{
370378
if (!USPiMassStorageDeviceAvailable())
@@ -380,6 +388,7 @@ DRESULT disk_read (
380388

381389
return RES_OK;
382390
}
391+
#endif
383392
}
384393

385394
return RES_PARERR;
@@ -410,6 +419,7 @@ DRESULT disk_write (
410419
return RES_OK;
411420
}
412421

422+
#ifdef HAVE_USPI
413423
default :
414424
{
415425
if (!USPiMassStorageDeviceAvailable())
@@ -425,6 +435,7 @@ DRESULT disk_write (
425435

426436
return RES_OK;
427437
}
438+
#endif
428439
}
429440

430441
return RES_PARERR;
@@ -464,6 +475,7 @@ DRESULT disk_ioctl (
464475
}
465476
return RES_PARERR;
466477

478+
#ifdef HAVE_USPI
467479
default :
468480
if (!USPiMassStorageDeviceAvailable())
469481
{
@@ -489,6 +501,7 @@ DRESULT disk_ioctl (
489501
return RES_OK;
490502
}
491503
return RES_PARERR;
504+
#endif
492505
}
493506

494507
return RES_PARERR;
@@ -508,3 +521,23 @@ DWORD get_fattime (void)
508521
| ((DWORD)ltm->tm_sec >> 1);
509522
}
510523
#endif
524+
525+
void LogWrite (const char *pSource, unsigned Severity, const char *pMessage, ...)
526+
{
527+
// Do nothing
528+
}
529+
530+
void uspi_assertion_failed (const char *pExpr, const char *pFile, unsigned nLine)
531+
{
532+
// Do nothing
533+
}
534+
535+
void DebugHexdump (const void *pBuffer, unsigned nBufLen, const char *pSource /* = 0 */)
536+
{
537+
// Do nothing
538+
}
539+
540+
void log_printf (const char *ptr, ...)
541+
{
542+
// Do nothing
543+
}

0 commit comments

Comments
 (0)