generated from RISC-OS-Community/StandardRepoTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added build scripts and fixed few issues
- Loading branch information
Showing
19 changed files
with
374 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
| Lib DTB for RISC OS | ||
| by Paolo Fabio Zaino 2023 | ||
|
||
IconSprites <Obey$Dir>.!Sprites | ||
If "<LibDTB$Dir>" = "" Then Set LibDTB$Dir <Obey$Dir> | ||
Set LibDTB$Path <LibDTB$Dir>. |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
| Lib DTB for RISC OS | ||
| by Paolo Fabio Zaino 2023 | ||
|
||
IconSprites <Obey$Dir>.!Sprites | ||
Set LibDTB$Dir <Obey$Dir> | ||
Set LibDTB$Path <LibDTB$Dir>. |
Binary file not shown.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
| Generic Library builder for DDE on RISC OS | ||
| by Paolo Fabio Zaino | ||
|
||
echo ++++++++++++++++++++++++ | ||
echo ++ Building using DDE ++ | ||
echo ++++++++++++++++++++++++ | ||
|
||
Set Build$Root <Obey$Dir> | ||
|
||
WimpSlot -min 6144K | ||
|
||
echo --------------------- | ||
echo Building the Library: | ||
echo --------------------- | ||
|
||
Dir <Build$Root>.src | ||
amu all THROWBACK=-throwback -f MakeFileDDE | ||
|
||
up | ||
|
||
IfThere @.!LibDTB Then Else CDir @.!LibDTB | ||
IfThere @.!LibDTB.o Then Else CDir @.!LibDTB.o | ||
IfThere @.!LibDTB.a Then Else CDir @.!LibDTB.a | ||
IfThere @.!LibDTB.h Then Else CDir @.!LibDTB.h | ||
|
||
IFthere @.src.dtblib.o.dtblib Then copy @.src.dtblib.o.dtblib @.!LibDTB.o.dtblib ~C N | ||
IFthere @.src.dtblib.o.dtblibzm Then copy @.src.dtblib.o.dtblibzm @.!LibDTB.o.dtblibzm ~C N | ||
IFthere @.src.dtblib.h.dtb Then copy @.src.dtblib.h.dtb @.!LibDTB.h.dtblib ~C N | ||
|
||
echo | ||
echo --------------------- | ||
echo | ||
|
||
echo --------------------- | ||
echo Building Tests: | ||
echo --------------------- | ||
|
||
Dir <Build$Root>.tests | ||
|
||
Set CanRunTests$Flag 0 | ||
IfThere @.^.!LibDTB.o.dtblib Then Set CanRunTests$Flag 1 | ||
If "<CanRunTests$Flag>" = "1" Then IfThere @.MakefileDDE Then Set CanRunTests$Flag 2 | ||
If "<CanRunTests$Flag>" = "2" Then make all THROWBACK=-throwback -f MakeFileDDE | ||
|
||
Unset CanRunTests$Flag | ||
|
||
echo | ||
echo --------------------- | ||
echo | ||
|
||
Dir <Build$Root> |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Dir <Obey$Dir>.src | ||
WimpSlot -min 2048k | ||
amu clean -f MakeFileDDE | ||
stripdepnd MakeFileDDE | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Dir <Obey$Dir> | ||
WimpSlot -min 2048K | ||
amu export_hdrs LIBDIR=Export -f MakeFileDDE | ||
amu export_libs LIBDIR=Export THROWBACK=-throwback -f MakeFileDDE |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
| Generic Library builder for GCC on RISC OS | ||
| by Paolo Fabio Zaino | ||
|
||
echo ++++++++++++++++++++++++ | ||
echo ++ Building using GCC ++ | ||
echo ++++++++++++++++++++++++ | ||
|
||
Set Build$Root <Obey$Dir> | ||
|
||
WimpSlot -min 16384K | ||
|
||
echo --------------------- | ||
echo Building the Library: | ||
echo --------------------- | ||
|
||
Dir <Build$Root>.src | ||
make all THROWBACK=-throwback OS=RISC_OS -f MakeFileGCC | ||
|
||
|IFthere @.o.ezinilib Then copy @.o.libezini @.^.!LibEzINI.a.libezini ~C N | ||
|IFthere @.h.ezini Then copy @.h.ezini @.^.!LibEzINI.h.ezini ~C N | ||
|
||
echo | ||
echo --------------------- | ||
echo | ||
|
||
echo --------------------- | ||
echo Building Tests: | ||
echo --------------------- | ||
|
||
Dir <Build$Root>.tests | ||
make all THROWBACK=-throwback -f MakeFileGCC | ||
|
||
echo | ||
echo --------------------- | ||
echo | ||
|
||
Dir <Build$Root> |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Dir <Obey$Dir>.src | ||
WimpSlot -min 16384K | ||
make clean -f MakeFileGCC | ||
|
||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Master Makefile | ||
|
||
OBJS=dtblib | ||
|
||
.PHONY: $(OBJS) | ||
$(OBJS): | ||
dir @.$@ | ||
amu all_libs THROWBACK=-throwback -f MakefileDDE | ||
up | ||
|
||
.PHONY: all | ||
all: $(OBJS) | ||
|
||
.PHONY: clean | ||
clean: | ||
# dir @.$< | ||
# @.MkCleanDDE |
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Variables | ||
ifeq ($(OS),) | ||
OS := RISC_OS | ||
endif | ||
|
||
# Set variables based on the detected OS | ||
ifeq ($(OS),Linux) | ||
CD_CMD = cd | ||
RM_CMD = rm -f | ||
DIR_SYM =/ | ||
LOCAL_DIR=. | ||
UP_DIR=.. | ||
EXT_SYM =. | ||
MAKE_FLAGS = -j4 | ||
else ifeq ($(OS),Darwin) # macOS | ||
CD_CMD = cd | ||
RM_CMD = rm -f | ||
DIR_SYM =/ | ||
LOCAL_DIR=. | ||
UP_DIR=.. | ||
EXT_SYM =. | ||
MAKE_FLAGS = -j4 | ||
else ifeq ($(OS),Windows) | ||
CD_CMD = cd | ||
RM_CMD = del | ||
DIR_SYM =/ | ||
LOCAL_DIR=. | ||
UP_DIR=.. | ||
EXT_SYM =. | ||
MAKE_FLAGS = -j4 | ||
else ifeq ($(OS),RISC_OS) | ||
CD_CMD = cdir | ||
RM_CMD = remove | ||
DIR_SYM =. | ||
LOCAL_DIR=@ | ||
UP_DIR=^ | ||
EXT_SYM =/ | ||
MAKE_FLAGS = -mthrowback | ||
else | ||
$(error Unknown operating system: $(UNAME)) | ||
endif | ||
|
||
CC = gcc | ||
MAKE = make | ||
|
||
LIB_DIR = libs | ||
# If needed add more libraries in the following format: | ||
# LIBS = $(LIB_DIR)$(DIR_SYM)lib1 $(LIB_DIR)$(DIR_SYM)lib2 $(LIB_DIR)$(DIR_SYM)lib3 | ||
LIBS = | ||
LIB_NAME = DTBLib | ||
MAIN_DIR = DTBLib | ||
MAIN_LIB = $(LIB_NAME) | ||
ifeq ($(OS),RISC_OS) | ||
MAIN_SRC = c.$(LIB_NAME) | ||
MAIN_OBJ = o.$(LIB_NAME) | ||
else | ||
MAIN_SRC = $(LIB_NAME).c | ||
MAIN_OBJ = $(LIB_NAME).o | ||
endif | ||
|
||
# Setup CFLAGS | ||
CFLAGS = -Wall -Wextra -pedantic | ||
CFLAGS += -ansi -std=c99 -Wno-gnu-label-as-value | ||
# reduce code size: | ||
#CFLAGS += -Os -ffunction-sections -fdata-sections -flto | ||
# compile for maximum speed | ||
CFLAGS += -Ofast -fno-stack-protector -fno-strict-aliasing -fomit-frame-pointer -flto | ||
#LDFLAGS += -Wl,--gc-sections | ||
LDFLAGS += -flto | ||
|
||
# Add -I flags for each library to CFLAGS | ||
CFLAGS += -I$(LIB_DIR) $(foreach dir,$(LIBS),-I$(dir) -I$(dir)$(DIR_SYM)src) | ||
|
||
# Targets | ||
all: $(MAIN_LIB) | ||
|
||
# Building the main application | ||
$(MAIN_LIB): libs | ||
$(MAKE) -C $(LOCAL_DIR)$(DIR_SYM)$(MAIN_DIR) all OS=$(OS) -f MakefileGCC | ||
|
||
# Building the libraries by invoking their own Makefiles | ||
libs: $(LIBS) | ||
|
||
$(LIBS): | ||
$(MAKE) -C $(LOCAL_DIR)$(DIR_SYM)$@$(DIR_SYM)src all OS=$(OS) -f MakefileGCC | ||
|
||
# To initialize and update git submodules | ||
init-submodules: | ||
git submodule init | ||
git submodule update | ||
|
||
# Clean up | ||
clean: | ||
$(RM_CMD) $(MAIN_LIB) | ||
for dir in $(LIBS); do \ | ||
($(CD_CMD) $$dir && $(MAKE) clean OS=$(OS) -f MakefileGCC); \ | ||
done | ||
|
||
# To force rebuild everything | ||
rebuild: clean all | ||
|
||
.PHONY: all clean rebuild init-submodules libs $(LIBS) |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Makefile for dtblib | ||
|
||
COMPONENT = dtblib | ||
OBJS = krnllib strlib dtb | ||
|
||
include CLibrary | ||
LIBS = | ||
#LDFLAGS = -bin | ||
|
||
# Dynamic dependencies: | ||
|
||
oz.dtb: c.dtb | ||
oz.dtb: h.krnllib | ||
oz.dtb: h.strlib | ||
oz.dtb: h.krnllib | ||
oz.dtb: h.dtb | ||
o.krnllib: c.krnllib | ||
o.krnllib: h.krnllib | ||
o.strlib: c.strlib | ||
o.strlib: h.krnllib | ||
o.strlib: h.strlib | ||
o.strlib: h.krnllib | ||
o.dtb: c.dtb | ||
o.dtb: h.krnllib | ||
o.dtb: h.strlib | ||
o.dtb: h.krnllib | ||
o.dtb: h.dtb |
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* DTBLib: Device Tree Blob Parsing Library | ||
* | ||
* Copyright (c) 2023 by Paolo Fabio Zaino, all rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* Limitations: | ||
* - Redistribution and use of this software in source and binary | ||
* forms, with or without modification, are permitted provided that | ||
* the following conditions are met: | ||
* - Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions, and the following disclaimer. | ||
* - Redistributions in binary form must reproduce the above | ||
* copyright notice, this list of conditions, and the following | ||
* disclaimer in the documentation and/or other materials | ||
* provided with the distribution. | ||
* - Neither the name of Paolo Fabio Zaino, nor the names | ||
* of its contributors may be used to endorse or promote products | ||
* derived from this software without specific prior written | ||
* permission. | ||
* - Users of this software are prohibited from misrepresenting | ||
* themselves as the authors or original contributors of this | ||
* software. | ||
* | ||
* This software is provided by the copyright holders and contributors | ||
* "as is" and any express or implied warranties, including, but not | ||
* limited to, the implied warranties of merchantability and fitness | ||
* for a particular purpose are disclaimed. In no event shall the | ||
* copyright owner or contributors be liable for any direct, | ||
* indirect, incidental, special, exemplary, or consequential damages | ||
* (including, but not limited to, procurement of substitute goods or | ||
* services; loss of use, data, or profits; or business interruption) | ||
* however caused and on any theory of liability, whether in | ||
* contract, strict liability, or tort (including negligence or | ||
* otherwise) arising in any way out of the use of this software, | ||
* even if advised of the possibility of such damage. | ||
* | ||
* For more details and the full text of the license, refer to the | ||
* Apache 2.0 License file included with this project or available at | ||
* the above URL. | ||
*/ | ||
|
||
#ifndef DTBLIB_H_ | ||
#define DTBLIB_H_ | ||
|
||
#define FDT_MAGIC 0xd00dfeed | ||
#define FDT_BEGIN_NODE 1 | ||
#define FDT_END_NODE 2 | ||
#define FDT_PROP 3 | ||
#define FDT_NOP 4 | ||
#define FDT_END 9 | ||
|
||
#define MIN_DTB_VERSION 1 | ||
#define MAX_DTB_VERSION 17 | ||
|
||
struct dt_node { | ||
char* name; // Name of the node | ||
struct dt_property* props; // Pointer to the first property of the node | ||
int prop_count; // Count of properties in the node | ||
struct dt_node* parent; // Pointer to the parent node (NULL for root) | ||
struct dt_node* children; // Pointer to the first child node | ||
struct dt_node* next_sibling; // Pointer to the next sibling node | ||
}; | ||
|
||
struct dt_property { | ||
char* name; // Name of the property | ||
void* value; // Pointer to the value of the property | ||
unsigned int size; // Size of the value in bytes | ||
struct dt_property* next; // Pointer to the next property | ||
}; | ||
|
||
struct dt_node* parse_dtb( | ||
const char* dtb_data, | ||
const char* strings_block, | ||
int offset | ||
); | ||
|
||
#endif /* DTBLIB_H_ */ |
Oops, something went wrong.