split kernel lib sources into their own directory and handled the section
differences with a partial link and a special link script
This commit is contained in:
parent
9c655d1fb0
commit
622b4cfe3c
|
@ -50,7 +50,7 @@ AFLAGS := -mcpu=arm1176jzf-s -mfloat-abi=hard
|
||||||
ASM_CPP_FLAGS := $(INCLUDES) $(DEFS) -D__ASM__
|
ASM_CPP_FLAGS := $(INCLUDES) $(DEFS) -D__ASM__
|
||||||
|
|
||||||
# Standard rule for pre-processing linker script files.
|
# Standard rule for pre-processing linker script files.
|
||||||
%.lds: %.Lds
|
%.lds: %.ldi
|
||||||
$(CPP) $(ASM_CPP_FLAGS) -P -o $@ $<
|
$(CPP) $(ASM_CPP_FLAGS) -P -o $@ $<
|
||||||
|
|
||||||
# Standard rule for preprocessing and assembling assembler files.
|
# Standard rule for preprocessing and assembling assembler files.
|
||||||
|
|
|
@ -49,8 +49,6 @@
|
||||||
#define SEG_INIT_DATA __attribute__((__section__(".prestart.data")))
|
#define SEG_INIT_DATA __attribute__((__section__(".prestart.data")))
|
||||||
#define SEG_INIT_RODATA __attribute__((__section__(".prestart.rodata")))
|
#define SEG_INIT_RODATA __attribute__((__section__(".prestart.rodata")))
|
||||||
#define SEG_RODATA SEG_INIT_RODATA
|
#define SEG_RODATA SEG_INIT_RODATA
|
||||||
#define SEG_LIB_CODE SEG_INIT_CODE
|
|
||||||
#define SEG_LIB_RODATA SEG_INIT_RODATA
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -58,8 +56,6 @@
|
||||||
#define SEG_INIT_DATA __attribute__((__section__(".init.data")))
|
#define SEG_INIT_DATA __attribute__((__section__(".init.data")))
|
||||||
#define SEG_INIT_RODATA __attribute__((__section__(".init.rodata")))
|
#define SEG_INIT_RODATA __attribute__((__section__(".init.rodata")))
|
||||||
#define SEG_RODATA __attribute__((__section__(".rodata")))
|
#define SEG_RODATA __attribute__((__section__(".rodata")))
|
||||||
#define SEG_LIB_CODE __attribute__((__section__(".lib.text")))
|
|
||||||
#define SEG_LIB_RODATA __attribute__((__section__(".lib.rodata")))
|
|
||||||
|
|
||||||
#endif /* __COMROGUE_PRESTART__ */
|
#endif /* __COMROGUE_PRESTART__ */
|
||||||
|
|
||||||
|
@ -70,7 +66,6 @@
|
||||||
|
|
||||||
#define DECLARE_STRING8_CONST_STGCLASS(name, value, stgclass) const CHAR stgclass name [] = value
|
#define DECLARE_STRING8_CONST_STGCLASS(name, value, stgclass) const CHAR stgclass name [] = value
|
||||||
#define DECLARE_INIT_STRING8_CONST(name, value) DECLARE_STRING8_CONST_STGCLASS(name, value, SEG_INIT_RODATA)
|
#define DECLARE_INIT_STRING8_CONST(name, value) DECLARE_STRING8_CONST_STGCLASS(name, value, SEG_INIT_RODATA)
|
||||||
#define DECLARE_LIB_STRING8_CONST(name, value) DECLARE_STRING8_CONST_STGCLASS(name, value, SEG_LIB_RODATA)
|
|
||||||
#define DECLARE_STRING8_CONST(name, value) DECLARE_STRING8_CONST_STGCLASS(name, value, SEG_RODATA)
|
#define DECLARE_STRING8_CONST(name, value) DECLARE_STRING8_CONST_STGCLASS(name, value, SEG_RODATA)
|
||||||
|
|
||||||
#endif /* __ASM__ */
|
#endif /* __ASM__ */
|
||||||
|
|
|
@ -90,12 +90,8 @@ CDECL_END
|
||||||
#if defined(__COMROGUE_PRESTART__) || defined(__COMROGUE_INIT__)
|
#if defined(__COMROGUE_PRESTART__) || defined(__COMROGUE_INIT__)
|
||||||
#define DECLARE_THIS_FILE static DECLARE_INIT_STRING8_CONST(THIS_FILE, __FILE__);
|
#define DECLARE_THIS_FILE static DECLARE_INIT_STRING8_CONST(THIS_FILE, __FILE__);
|
||||||
#else
|
#else
|
||||||
#if defined(__COMROGUE_KERNEL_LIB__)
|
|
||||||
#define DECLARE_THIS_FILE static DECLARE_LIB_STRING8_CONST(THIS_FILE, __FILE__);
|
|
||||||
#else
|
|
||||||
#define DECLARE_THIS_FILE static DECLARE_STRING8_CONST(THIS_FILE, __FILE__);
|
#define DECLARE_THIS_FILE static DECLARE_STRING8_CONST(THIS_FILE, __FILE__);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ASSERT(x) ((x) ? (void)0 : ASSERT_FAIL_FUNC(THIS_FILE, __LINE__))
|
#define ASSERT(x) ((x) ? (void)0 : ASSERT_FAIL_FUNC(THIS_FILE, __LINE__))
|
||||||
#define VERIFY(x) ASSERT(x)
|
#define VERIFY(x) ASSERT(x)
|
||||||
|
|
|
@ -33,14 +33,16 @@ CRBASEDIR := $(abspath ..)
|
||||||
include $(CRBASEDIR)/armcompile.mk
|
include $(CRBASEDIR)/armcompile.mk
|
||||||
|
|
||||||
PRESTART_OBJS = prestart.o early_trace.o collect_startup.o early_mm.o
|
PRESTART_OBJS = prestart.o early_trace.o collect_startup.o early_mm.o
|
||||||
LIB_OBJS = divide.o qdivrem.o intlib.o objhelp.o rbtree.o str.o strcopymem.o strcomparemem.o strsetmem.o lib_guids.o
|
|
||||||
RES_OBJS = lowlevel.o trace.o memmgr.o vmmap.o pagealloc.o kernel_space.o
|
RES_OBJS = lowlevel.o trace.o memmgr.o vmmap.o pagealloc.o kernel_space.o
|
||||||
INIT_OBJS = start.o kistart.o init_heap.o
|
INIT_OBJS = start.o kistart.o init_heap.o
|
||||||
|
|
||||||
all: kernel.img
|
all: kernel.img
|
||||||
|
|
||||||
kernel.elf: $(PRESTART_OBJS) $(LIB_OBJS) $(RES_OBJS) $(INIT_OBJS) kernel.lds
|
kernel.elf: $(PRESTART_OBJS) lib/kernel-lib.o $(RES_OBJS) $(INIT_OBJS) kernel.lds
|
||||||
$(LD) -T kernel.lds $(PRESTART_OBJS) $(LIB_OBJS) $(RES_OBJS) $(INIT_OBJS) -o kernel.elf
|
$(LD) -T kernel.lds $(PRESTART_OBJS) lib/kernel-lib.o $(RES_OBJS) $(INIT_OBJS) -o kernel.elf
|
||||||
|
|
||||||
|
lib/kernel-lib.o:
|
||||||
|
make -C lib
|
||||||
|
|
||||||
kernel.img: kernel.elf
|
kernel.img: kernel.elf
|
||||||
$(OBJDUMP) -D kernel.elf > kernel.list
|
$(OBJDUMP) -D kernel.elf > kernel.list
|
||||||
|
@ -50,3 +52,4 @@ kernel.img: kernel.elf
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm *.o *.s *.lds kernel.img kernel.elf kernel.list kernel.syms*
|
-rm *.o *.s *.lds kernel.img kernel.elf kernel.list kernel.syms*
|
||||||
|
make -C lib clean
|
43
kernel/lib/Makefile
Normal file
43
kernel/lib/Makefile
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#
|
||||||
|
# This file is part of the COMROGUE Operating System for Raspberry Pi
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013, Eric J. Bowersox / Erbosoft Enterprises
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free for commercial and non-commercial use as long as the following conditions are
|
||||||
|
# adhered to.
|
||||||
|
#
|
||||||
|
# Copyright in this file remains Eric J. Bowersox and/or Erbosoft, and as such any copyright notices
|
||||||
|
# in the code are not to be removed.
|
||||||
|
#
|
||||||
|
# Redistribution and use 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.
|
||||||
|
#
|
||||||
|
# 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 HOLDER 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.
|
||||||
|
#
|
||||||
|
# "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
||||||
|
MAKEFLAGS += -rR
|
||||||
|
CRBASEDIR := $(abspath ../..)
|
||||||
|
include $(CRBASEDIR)/armcompile.mk
|
||||||
|
|
||||||
|
LIB_OBJS = divide.o qdivrem.o intlib.o objhelp.o rbtree.o str.o strcopymem.o strcomparemem.o strsetmem.o lib_guids.o
|
||||||
|
|
||||||
|
all: kernel-lib.o
|
||||||
|
|
||||||
|
kernel-lib.o: $(LIB_OBJS) kernel-lib.lds
|
||||||
|
$(LD) -r -T kernel-lib.lds $(LIB_OBJS) -o kernel-lib.o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm *.o *.s *.lds
|
|
@ -32,8 +32,6 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* Derived from FreeBSD libkern divsi3.S, uldivmod.S, and ldivmod.S, munged by Erbo to COMROGUE standards */
|
/* Derived from FreeBSD libkern divsi3.S, uldivmod.S, and ldivmod.S, munged by Erbo to COMROGUE standards */
|
||||||
.section ".lib.text"
|
|
||||||
|
|
||||||
.globl __aeabi_uidiv
|
.globl __aeabi_uidiv
|
||||||
.globl __aeabi_uidivmod
|
.globl __aeabi_uidivmod
|
||||||
__aeabi_uidiv:
|
__aeabi_uidiv:
|
|
@ -29,10 +29,8 @@
|
||||||
*
|
*
|
||||||
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
||||||
*/
|
*/
|
||||||
#define __COMROGUE_KERNEL_LIB__
|
|
||||||
#include <comrogue/types.h>
|
#include <comrogue/types.h>
|
||||||
#include <comrogue/intlib.h>
|
#include <comrogue/intlib.h>
|
||||||
#include <comrogue/internals/seg.h>
|
|
||||||
#include "quad.h"
|
#include "quad.h"
|
||||||
|
|
||||||
/*---------------------------
|
/*---------------------------
|
||||||
|
@ -55,7 +53,7 @@
|
||||||
* Returns:
|
* Returns:
|
||||||
* Standard SUCCEEDED/FAILED HRESULT.
|
* Standard SUCCEEDED/FAILED HRESULT.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE HRESULT IntLDiv(PLDIV pResult, INT64 num, INT64 denom)
|
HRESULT IntLDiv(PLDIV pResult, INT64 num, INT64 denom)
|
||||||
{
|
{
|
||||||
UINT32 mode = 0;
|
UINT32 mode = 0;
|
||||||
if (denom == 0)
|
if (denom == 0)
|
182
kernel/lib/kernel-lib.ldi
Normal file
182
kernel/lib/kernel-lib.ldi
Normal file
|
@ -0,0 +1,182 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the COMROGUE Operating System for Raspberry Pi
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013, Eric J. Bowersox / Erbosoft Enterprises
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This program is free for commercial and non-commercial use as long as the following conditions are
|
||||||
|
* adhered to.
|
||||||
|
*
|
||||||
|
* Copyright in this file remains Eric J. Bowersox and/or Erbosoft, and as such any copyright notices
|
||||||
|
* in the code are not to be removed.
|
||||||
|
*
|
||||||
|
* Redistribution and use 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.
|
||||||
|
*
|
||||||
|
* 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 HOLDER 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.
|
||||||
|
*
|
||||||
|
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
||||||
|
*/
|
||||||
|
/* Copied from default linker script for relocatable linking under ARM & modified */
|
||||||
|
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
/* Read-only sections, merged into text segment: */
|
||||||
|
.interp 0 : { *(.interp) }
|
||||||
|
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||||
|
.hash 0 : { *(.hash) }
|
||||||
|
.gnu.hash 0 : { *(.gnu.hash) }
|
||||||
|
.dynsym 0 : { *(.dynsym) }
|
||||||
|
.dynstr 0 : { *(.dynstr) }
|
||||||
|
.gnu.version 0 : { *(.gnu.version) }
|
||||||
|
.gnu.version_d 0: { *(.gnu.version_d) }
|
||||||
|
.gnu.version_r 0: { *(.gnu.version_r) }
|
||||||
|
.rel.init 0 : { *(.rel.init) }
|
||||||
|
.rela.init 0 : { *(.rela.init) }
|
||||||
|
.rel.text 0 : { *(.rel.text) }
|
||||||
|
.rela.text 0 : { *(.rela.text) }
|
||||||
|
.rel.fini 0 : { *(.rel.fini) }
|
||||||
|
.rela.fini 0 : { *(.rela.fini) }
|
||||||
|
.rel.rodata 0 : { *(.rel.rodata) }
|
||||||
|
.rela.rodata 0 : { *(.rela.rodata) }
|
||||||
|
.rel.ctors 0 : { *(.rel.ctors) }
|
||||||
|
.rela.ctors 0 : { *(.rela.ctors) }
|
||||||
|
.rel.dtors 0 : { *(.rel.dtors) }
|
||||||
|
.rela.dtors 0 : { *(.rela.dtors) }
|
||||||
|
.rel.got 0 : { *(.rel.got) }
|
||||||
|
.rela.got 0 : { *(.rela.got) }
|
||||||
|
.rel.bss 0 : { *(.rel.bss) }
|
||||||
|
.rela.bss 0 : { *(.rela.bss) }
|
||||||
|
.rel.iplt 0 :
|
||||||
|
{
|
||||||
|
*(.rel.iplt)
|
||||||
|
}
|
||||||
|
.rela.iplt 0 :
|
||||||
|
{
|
||||||
|
*(.rela.iplt)
|
||||||
|
}
|
||||||
|
.rel.plt 0 :
|
||||||
|
{
|
||||||
|
*(.rel.plt)
|
||||||
|
}
|
||||||
|
.rela.plt 0 :
|
||||||
|
{
|
||||||
|
*(.rela.plt)
|
||||||
|
}
|
||||||
|
.init 0 :
|
||||||
|
{
|
||||||
|
KEEP (*(.init))
|
||||||
|
} =0
|
||||||
|
.plt 0 : { *(.plt) }
|
||||||
|
.iplt 0 : { *(.iplt) }
|
||||||
|
.lib.text 0 :
|
||||||
|
{
|
||||||
|
*(.text .stub)
|
||||||
|
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||||
|
*(.gnu.warning)
|
||||||
|
} =0
|
||||||
|
.fini 0 :
|
||||||
|
{
|
||||||
|
KEEP (*(.fini))
|
||||||
|
} =0
|
||||||
|
.lib.rodata 0 : { *(.rodata) }
|
||||||
|
.lib.rodata1 0 : { *(.rodata1) }
|
||||||
|
.ARM.extab 0 : { *(.ARM.extab) }
|
||||||
|
.ARM.exidx 0 : { *(.ARM.exidx) }
|
||||||
|
.eh_frame_hdr : { *(.eh_frame_hdr) }
|
||||||
|
.eh_frame 0 : ONLY_IF_RO { KEEP (*(.eh_frame)) }
|
||||||
|
.gcc_except_table 0 : ONLY_IF_RO { *(.gcc_except_table
|
||||||
|
.gcc_except_table.*) }
|
||||||
|
/* These sections are generated by the Sun/Oracle C++ compiler. */
|
||||||
|
.exception_ranges 0 : ONLY_IF_RO { *(.exception_ranges
|
||||||
|
.exception_ranges*) }
|
||||||
|
/* Adjust the address for the data segment. We want to adjust up to
|
||||||
|
the same address within the page on the next page up. */
|
||||||
|
/* Exception handling */
|
||||||
|
.eh_frame 0 : ONLY_IF_RW { KEEP (*(.eh_frame)) }
|
||||||
|
.gcc_except_table 0 : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
|
||||||
|
.exception_ranges 0 : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
|
||||||
|
/* Thread Local Storage sections */
|
||||||
|
.preinit_array 0 :
|
||||||
|
{
|
||||||
|
KEEP (*(.preinit_array))
|
||||||
|
}
|
||||||
|
.jcr 0 : { KEEP (*(.jcr)) }
|
||||||
|
.dynamic 0 : { *(.dynamic) }
|
||||||
|
.got 0 : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
|
||||||
|
/* Stabs debugging sections. */
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
/* DWARF debug sections.
|
||||||
|
Symbols in the DWARF debugging sections are relative to the beginning
|
||||||
|
of the section so we begin them at 0. */
|
||||||
|
/* DWARF 1 */
|
||||||
|
.debug 0 : { *(.debug) }
|
||||||
|
.line 0 : { *(.line) }
|
||||||
|
/* GNU DWARF 1 extensions */
|
||||||
|
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||||
|
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||||
|
/* DWARF 1.1 and DWARF 2 */
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
/* DWARF 2 */
|
||||||
|
.debug_info 0 : { *(.debug_info) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_frame 0 : { *(.debug_frame) }
|
||||||
|
.debug_str 0 : { *(.debug_str) }
|
||||||
|
.debug_loc 0 : { *(.debug_loc) }
|
||||||
|
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||||
|
/* SGI/MIPS DWARF 2 extensions */
|
||||||
|
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||||
|
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||||
|
.debug_typenames 0 : { *(.debug_typenames) }
|
||||||
|
.debug_varnames 0 : { *(.debug_varnames) }
|
||||||
|
/* DWARF 3 */
|
||||||
|
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||||
|
.debug_ranges 0 : { *(.debug_ranges) }
|
||||||
|
.stack 0 :
|
||||||
|
{
|
||||||
|
*(.stack)
|
||||||
|
}
|
||||||
|
.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }
|
||||||
|
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
|
||||||
|
|
||||||
|
/* we don't allow data in the library section, so discard all data segments */
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.rel.data.rel.ro)
|
||||||
|
*(.rela.data.rel.ro)
|
||||||
|
*(.rel.data)
|
||||||
|
*(.rela.data)
|
||||||
|
*(.data)
|
||||||
|
*(.data1)
|
||||||
|
*(.dynbss)
|
||||||
|
*(.bss)
|
||||||
|
*(COMMON)
|
||||||
|
*(.rel.tdata)
|
||||||
|
*(.rela.tdata)
|
||||||
|
*(.rel.tbss)
|
||||||
|
*(.rela.tbss)
|
||||||
|
*(.tdata)
|
||||||
|
*(.tbss)
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,9 +35,8 @@
|
||||||
* AND in this order.
|
* AND in this order.
|
||||||
*------------------------------------------------------------------------------------------------------
|
*------------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#define __COMROGUE_KERNEL_LIB__
|
|
||||||
#include <comrogue/internals/seg.h>
|
#include <comrogue/internals/seg.h>
|
||||||
#define GUIDATTR SEG_LIB_RODATA
|
#define GUIDATTR SEG_RODATA
|
||||||
#define INITGUID
|
#define INITGUID
|
||||||
#include <comrogue/object_definition_macros.h>
|
#include <comrogue/object_definition_macros.h>
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
*
|
*
|
||||||
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
||||||
*/
|
*/
|
||||||
#define __COMROGUE_KERNEL_LIB__
|
|
||||||
#include <comrogue/types.h>
|
#include <comrogue/types.h>
|
||||||
#include <comrogue/scode.h>
|
#include <comrogue/scode.h>
|
||||||
#include <comrogue/str.h>
|
#include <comrogue/str.h>
|
||||||
|
@ -38,7 +37,6 @@
|
||||||
#include <comrogue/allocator.h>
|
#include <comrogue/allocator.h>
|
||||||
#include <comrogue/stdobj.h>
|
#include <comrogue/stdobj.h>
|
||||||
#include <comrogue/objhelp.h>
|
#include <comrogue/objhelp.h>
|
||||||
#include <comrogue/internals/seg.h>
|
|
||||||
|
|
||||||
/*--------------------------------------------
|
/*--------------------------------------------
|
||||||
* Standard object functions (API-type calls)
|
* Standard object functions (API-type calls)
|
||||||
|
@ -55,7 +53,7 @@
|
||||||
* Returns:
|
* Returns:
|
||||||
* TRUE if the GUIDs are equal, FALSE otherwise.
|
* TRUE if the GUIDs are equal, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE BOOL IsEqualGUID(REFGUID guid1, REFGUID guid2)
|
BOOL IsEqualGUID(REFGUID guid1, REFGUID guid2)
|
||||||
{
|
{
|
||||||
return MAKEBOOL(StrCompareMem(guid1, guid2, sizeof(GUID)) == 0);
|
return MAKEBOOL(StrCompareMem(guid1, guid2, sizeof(GUID)) == 0);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +81,7 @@ SEG_LIB_CODE BOOL IsEqualGUID(REFGUID guid1, REFGUID guid2)
|
||||||
*/
|
*/
|
||||||
/* This macro makes a ObjHlpStandardQueryInterface_IXXX function for any interface directly derived from IUnknown */
|
/* This macro makes a ObjHlpStandardQueryInterface_IXXX function for any interface directly derived from IUnknown */
|
||||||
#define MAKE_BASE_QI(iface) \
|
#define MAKE_BASE_QI(iface) \
|
||||||
SEG_LIB_CODE HRESULT ObjHlpStandardQueryInterface_ ## iface (IUnknown *pThis, REFIID riid, PPVOID ppvObject) \
|
HRESULT ObjHlpStandardQueryInterface_ ## iface (IUnknown *pThis, REFIID riid, PPVOID ppvObject) \
|
||||||
{ \
|
{ \
|
||||||
if (!ppvObject) return E_POINTER; \
|
if (!ppvObject) return E_POINTER; \
|
||||||
*ppvObject = NULL; \
|
*ppvObject = NULL; \
|
||||||
|
@ -105,7 +103,7 @@ MAKE_BASE_QI(IMalloc)
|
||||||
* Returns:
|
* Returns:
|
||||||
* 1.
|
* 1.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE UINT32 ObjHlpStaticAddRefRelease(IUnknown *pThis)
|
UINT32 ObjHlpStaticAddRefRelease(IUnknown *pThis)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +117,7 @@ SEG_LIB_CODE UINT32 ObjHlpStaticAddRefRelease(IUnknown *pThis)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Nothing.
|
* Nothing.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE void ObjHlpDoNothingReturnVoid(IUnknown *pThis)
|
void ObjHlpDoNothingReturnVoid(IUnknown *pThis)
|
||||||
{
|
{
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
}
|
}
|
|
@ -31,7 +31,6 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* Derived from FreeBSD libkern qdivrem.c, munged by Erbo to COMROGUE standards */
|
/* Derived from FreeBSD libkern qdivrem.c, munged by Erbo to COMROGUE standards */
|
||||||
#define __COMROGUE_KERNEL_LIB__
|
|
||||||
#include <comrogue/types.h>
|
#include <comrogue/types.h>
|
||||||
#include <comrogue/internals/seg.h>
|
#include <comrogue/internals/seg.h>
|
||||||
#include "quad.h"
|
#include "quad.h"
|
||||||
|
@ -54,7 +53,7 @@ typedef UINT16 DIGIT;
|
||||||
* `fall out' the left (there never will be any such anyway).
|
* `fall out' the left (there never will be any such anyway).
|
||||||
* We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS.
|
* We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static void __shl(register DIGIT *p, register INT32 len, register INT32 sh)
|
static void __shl(register DIGIT *p, register INT32 len, register INT32 sh)
|
||||||
{
|
{
|
||||||
register INT32 i;
|
register INT32 i;
|
||||||
|
|
||||||
|
@ -71,7 +70,7 @@ SEG_LIB_CODE static void __shl(register DIGIT *p, register INT32 len, register I
|
||||||
* divisor are 4 `digits' in this base (they are shorter if they have
|
* divisor are 4 `digits' in this base (they are shorter if they have
|
||||||
* leading zeros).
|
* leading zeros).
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE UINT64 __qdivrem(UINT64 uq, UINT64 vq, PUINT64 pRem)
|
UINT64 __qdivrem(UINT64 uq, UINT64 vq, PUINT64 pRem)
|
||||||
{
|
{
|
||||||
UU tmp;
|
UU tmp;
|
||||||
DIGIT *u, *v, *q;
|
DIGIT *u, *v, *q;
|
||||||
|
@ -85,7 +84,7 @@ SEG_LIB_CODE UINT64 __qdivrem(UINT64 uq, UINT64 vq, PUINT64 pRem)
|
||||||
*/
|
*/
|
||||||
if (vq == 0)
|
if (vq == 0)
|
||||||
{ /* divide by zero. */
|
{ /* divide by zero. */
|
||||||
SEG_LIB_RODATA static volatile const unsigned int zero = 0;
|
SEG_RODATA static volatile const unsigned int zero = 0;
|
||||||
|
|
||||||
tmp.ul[H] = tmp.ul[L] = 1 / zero;
|
tmp.ul[H] = tmp.ul[L] = 1 / zero;
|
||||||
if (pRem)
|
if (pRem)
|
|
@ -29,10 +29,8 @@
|
||||||
*
|
*
|
||||||
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
||||||
*/
|
*/
|
||||||
#define __COMROGUE_KERNEL_LIB__
|
|
||||||
#include <comrogue/types.h>
|
#include <comrogue/types.h>
|
||||||
#include <comrogue/internals/rbtree.h>
|
#include <comrogue/internals/rbtree.h>
|
||||||
#include <comrogue/internals/seg.h>
|
|
||||||
#include <comrogue/internals/trace.h>
|
#include <comrogue/internals/trace.h>
|
||||||
|
|
||||||
#ifdef THIS_FILE
|
#ifdef THIS_FILE
|
||||||
|
@ -62,7 +60,7 @@ DECLARE_THIS_FILE
|
||||||
* 0 if the keys are equal; an integer less than 0 if k1 is less than k2; an integer greater than 0 if
|
* 0 if the keys are equal; an integer less than 0 if k1 is less than k2; an integer greater than 0 if
|
||||||
* k1 is greater than k2.
|
* k1 is greater than k2.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE INT32 RbtStdCompareByValue(TREEKEY k1, TREEKEY k2)
|
INT32 RbtStdCompareByValue(TREEKEY k1, TREEKEY k2)
|
||||||
{
|
{
|
||||||
if (k1 == k2)
|
if (k1 == k2)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -81,7 +79,7 @@ SEG_LIB_CODE INT32 RbtStdCompareByValue(TREEKEY k1, TREEKEY k2)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to the new root node of the subtree after the rotation.
|
* Pointer to the new root node of the subtree after the rotation.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE rotate_left(PRBTREENODE ptn)
|
static PRBTREENODE rotate_left(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
register PRBTREENODE ptnNewRoot = rbtNodeRight(ptn);
|
register PRBTREENODE ptnNewRoot = rbtNodeRight(ptn);
|
||||||
ASSERT(ptnNewRoot);
|
ASSERT(ptnNewRoot);
|
||||||
|
@ -102,7 +100,7 @@ SEG_LIB_CODE static PRBTREENODE rotate_left(PRBTREENODE ptn)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to the new root node of the subtree after the rotation.
|
* Pointer to the new root node of the subtree after the rotation.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE rotate_right(PRBTREENODE ptn)
|
static PRBTREENODE rotate_right(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
register PRBTREENODE ptnNewRoot = ptn->ptnLeft;
|
register PRBTREENODE ptnNewRoot = ptn->ptnLeft;
|
||||||
ASSERT(ptnNewRoot);
|
ASSERT(ptnNewRoot);
|
||||||
|
@ -122,7 +120,7 @@ SEG_LIB_CODE static PRBTREENODE rotate_right(PRBTREENODE ptn)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Nothing.
|
* Nothing.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static void color_flip(PRBTREENODE ptn)
|
static void color_flip(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
rbtToggleColor(ptn);
|
rbtToggleColor(ptn);
|
||||||
rbtToggleColor(ptn->ptnLeft);
|
rbtToggleColor(ptn->ptnLeft);
|
||||||
|
@ -139,7 +137,7 @@ SEG_LIB_CODE static void color_flip(PRBTREENODE ptn)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to the new root node of the subtree after fixup is performed.
|
* Pointer to the new root node of the subtree after fixup is performed.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE fix_up(PRBTREENODE ptn)
|
static PRBTREENODE fix_up(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
if (rbtIsRed(rbtNodeRight(ptn)) && !rbtIsRed(ptn->ptnLeft))
|
if (rbtIsRed(rbtNodeRight(ptn)) && !rbtIsRed(ptn->ptnLeft))
|
||||||
ptn = rotate_left(ptn);
|
ptn = rotate_left(ptn);
|
||||||
|
@ -167,7 +165,7 @@ SEG_LIB_CODE static PRBTREENODE fix_up(PRBTREENODE ptn)
|
||||||
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
||||||
* by its stack frames will be O(log n).
|
* by its stack frames will be O(log n).
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE insert_under(PRBTREE ptree, PRBTREENODE ptnCurrent, PRBTREENODE ptnNew)
|
static PRBTREENODE insert_under(PRBTREE ptree, PRBTREENODE ptnCurrent, PRBTREENODE ptnNew)
|
||||||
{
|
{
|
||||||
register int cmp; /* compare result */
|
register int cmp; /* compare result */
|
||||||
|
|
||||||
|
@ -194,7 +192,7 @@ SEG_LIB_CODE static PRBTREENODE insert_under(PRBTREE ptree, PRBTREENODE ptnCurre
|
||||||
* Returns:
|
* Returns:
|
||||||
* Nothing.
|
* Nothing.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE void RbtInsert(PRBTREE ptree, PRBTREENODE ptnNew)
|
void RbtInsert(PRBTREE ptree, PRBTREENODE ptnNew)
|
||||||
{
|
{
|
||||||
ptree->ptnRoot = insert_under(ptree, ptree->ptnRoot, ptnNew);
|
ptree->ptnRoot = insert_under(ptree, ptree->ptnRoot, ptnNew);
|
||||||
rbtSetNodeColor(ptree->ptnRoot, BLACK);
|
rbtSetNodeColor(ptree->ptnRoot, BLACK);
|
||||||
|
@ -210,7 +208,7 @@ SEG_LIB_CODE void RbtInsert(PRBTREE ptree, PRBTREENODE ptnNew)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to the node where the key is found, or NULL if not found.
|
* Pointer to the node where the key is found, or NULL if not found.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE PRBTREENODE RbtFind(PRBTREE ptree, TREEKEY key)
|
PRBTREENODE RbtFind(PRBTREE ptree, TREEKEY key)
|
||||||
{
|
{
|
||||||
register PRBTREENODE ptn = ptree->ptnRoot; /* current node */
|
register PRBTREENODE ptn = ptree->ptnRoot; /* current node */
|
||||||
register int cmp; /* compare result */
|
register int cmp; /* compare result */
|
||||||
|
@ -241,7 +239,7 @@ SEG_LIB_CODE PRBTREENODE RbtFind(PRBTREE ptree, TREEKEY key)
|
||||||
* Pointer to the node where the key is found, or pointer to the predecessor node, or NULL if the key
|
* Pointer to the node where the key is found, or pointer to the predecessor node, or NULL if the key
|
||||||
* is less than every key in the tree and hence has no predecessor.
|
* is less than every key in the tree and hence has no predecessor.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE PRBTREENODE RbtFindPredecessor(PRBTREE ptree, TREEKEY key)
|
PRBTREENODE RbtFindPredecessor(PRBTREE ptree, TREEKEY key)
|
||||||
{
|
{
|
||||||
register PRBTREENODE ptn = ptree->ptnRoot; /* current node */
|
register PRBTREENODE ptn = ptree->ptnRoot; /* current node */
|
||||||
register int cmp; /* compare result */
|
register int cmp; /* compare result */
|
||||||
|
@ -276,7 +274,7 @@ SEG_LIB_CODE PRBTREENODE RbtFindPredecessor(PRBTREE ptree, TREEKEY key)
|
||||||
* Pointer to the node where the key is found, or pointer to the successor node, or NULL if the key
|
* Pointer to the node where the key is found, or pointer to the successor node, or NULL if the key
|
||||||
* is greater than every key in the tree and hence has no successor.
|
* is greater than every key in the tree and hence has no successor.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE PRBTREENODE RbtFindSuccessor(PRBTREE ptree, TREEKEY key)
|
PRBTREENODE RbtFindSuccessor(PRBTREE ptree, TREEKEY key)
|
||||||
{
|
{
|
||||||
register PRBTREENODE ptn = ptree->ptnRoot; /* current node */
|
register PRBTREENODE ptn = ptree->ptnRoot; /* current node */
|
||||||
register int cmp; /* compare result */
|
register int cmp; /* compare result */
|
||||||
|
@ -308,7 +306,7 @@ SEG_LIB_CODE PRBTREENODE RbtFindSuccessor(PRBTREE ptree, TREEKEY key)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to the leftmost node in the subtree.
|
* Pointer to the leftmost node in the subtree.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE find_min(PRBTREENODE ptn)
|
static PRBTREENODE find_min(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
while (ptn->ptnLeft)
|
while (ptn->ptnLeft)
|
||||||
ptn = ptn->ptnLeft;
|
ptn = ptn->ptnLeft;
|
||||||
|
@ -324,7 +322,7 @@ SEG_LIB_CODE static PRBTREENODE find_min(PRBTREENODE ptn)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to the leftmost node in the tree. If the tree has no nodes, NULL is returned.
|
* Pointer to the leftmost node in the tree. If the tree has no nodes, NULL is returned.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE PRBTREENODE RbtFindMin(PRBTREE ptree)
|
PRBTREENODE RbtFindMin(PRBTREE ptree)
|
||||||
{
|
{
|
||||||
return ptree->ptnRoot ? find_min(ptree->ptnRoot) : NULL;
|
return ptree->ptnRoot ? find_min(ptree->ptnRoot) : NULL;
|
||||||
}
|
}
|
||||||
|
@ -340,7 +338,7 @@ SEG_LIB_CODE PRBTREENODE RbtFindMin(PRBTREE ptree)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to root of subtree after fixup.
|
* Pointer to root of subtree after fixup.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE move_red_left(PRBTREENODE ptn)
|
static PRBTREENODE move_red_left(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
color_flip(ptn);
|
color_flip(ptn);
|
||||||
if (rbtNodeRight(ptn) && rbtIsRed(rbtNodeRight(ptn)->ptnLeft))
|
if (rbtNodeRight(ptn) && rbtIsRed(rbtNodeRight(ptn)->ptnLeft))
|
||||||
|
@ -361,7 +359,7 @@ SEG_LIB_CODE static PRBTREENODE move_red_left(PRBTREENODE ptn)
|
||||||
* Returns:
|
* Returns:
|
||||||
* Pointer to root of subtree after fixup.
|
* Pointer to root of subtree after fixup.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE move_red_right(PRBTREENODE ptn)
|
static PRBTREENODE move_red_right(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
color_flip(ptn);
|
color_flip(ptn);
|
||||||
if (ptn->ptnLeft && rbtIsRed(ptn->ptnLeft->ptnLeft))
|
if (ptn->ptnLeft && rbtIsRed(ptn->ptnLeft->ptnLeft))
|
||||||
|
@ -386,7 +384,7 @@ SEG_LIB_CODE static PRBTREENODE move_red_right(PRBTREENODE ptn)
|
||||||
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
||||||
* by its stack frames will be O(log n).
|
* by its stack frames will be O(log n).
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE delete_min(PRBTREENODE ptn)
|
static PRBTREENODE delete_min(PRBTREENODE ptn)
|
||||||
{
|
{
|
||||||
if (!(ptn->ptnLeft))
|
if (!(ptn->ptnLeft))
|
||||||
return rbtNodeRight(ptn);
|
return rbtNodeRight(ptn);
|
||||||
|
@ -412,7 +410,7 @@ SEG_LIB_CODE static PRBTREENODE delete_min(PRBTREENODE ptn)
|
||||||
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
||||||
* by its stack frames (and those of delete_min, where we call it) will be O(log n).
|
* by its stack frames (and those of delete_min, where we call it) will be O(log n).
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PRBTREENODE delete_from_under(PRBTREE ptree, PRBTREENODE ptnCurrent, TREEKEY key)
|
static PRBTREENODE delete_from_under(PRBTREE ptree, PRBTREENODE ptnCurrent, TREEKEY key)
|
||||||
{
|
{
|
||||||
register int cmp = (*(ptree->pfnTreeCompare))(key, ptnCurrent->treekey);
|
register int cmp = (*(ptree->pfnTreeCompare))(key, ptnCurrent->treekey);
|
||||||
if (cmp < 0)
|
if (cmp < 0)
|
||||||
|
@ -467,7 +465,7 @@ SEG_LIB_CODE static PRBTREENODE delete_from_under(PRBTREE ptree, PRBTREENODE ptn
|
||||||
* Returns:
|
* Returns:
|
||||||
* Nothing.
|
* Nothing.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE void RbtDelete(PRBTREE ptree, TREEKEY key)
|
void RbtDelete(PRBTREE ptree, TREEKEY key)
|
||||||
{
|
{
|
||||||
ptree->ptnRoot = delete_from_under(ptree, ptree->ptnRoot, key);
|
ptree->ptnRoot = delete_from_under(ptree, ptree->ptnRoot, key);
|
||||||
if (ptree->ptnRoot)
|
if (ptree->ptnRoot)
|
||||||
|
@ -491,7 +489,7 @@ SEG_LIB_CODE void RbtDelete(PRBTREE ptree, TREEKEY key)
|
||||||
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
* This function is recursive; however, the nature of the tree guarantees that the stack space consumed
|
||||||
* by its stack frames will be O(log n).
|
* by its stack frames will be O(log n).
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static BOOL do_walk(PRBTREE ptree, PRBTREENODE ptn, PFNRBTWALK pfnWalk, PVOID pData)
|
static BOOL do_walk(PRBTREE ptree, PRBTREENODE ptn, PFNRBTWALK pfnWalk, PVOID pData)
|
||||||
{
|
{
|
||||||
register BOOL rc = TRUE;
|
register BOOL rc = TRUE;
|
||||||
if (ptn->ptnLeft)
|
if (ptn->ptnLeft)
|
||||||
|
@ -515,7 +513,7 @@ SEG_LIB_CODE static BOOL do_walk(PRBTREE ptree, PRBTREENODE ptn, PFNRBTWALK pfnW
|
||||||
* Returns:
|
* Returns:
|
||||||
* TRUE if the tree was entirely traversed, FALSE if the tree walk was interrupted.
|
* TRUE if the tree was entirely traversed, FALSE if the tree walk was interrupted.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE BOOL RbtWalk(PRBTREE ptree, PFNRBTWALK pfnWalk, PVOID pData)
|
BOOL RbtWalk(PRBTREE ptree, PFNRBTWALK pfnWalk, PVOID pData)
|
||||||
{
|
{
|
||||||
return (ptree->ptnRoot ? do_walk(ptree, ptree->ptnRoot, pfnWalk, pData) : TRUE);
|
return (ptree->ptnRoot ? do_walk(ptree, ptree->ptnRoot, pfnWalk, pData) : TRUE);
|
||||||
}
|
}
|
|
@ -29,7 +29,6 @@
|
||||||
*
|
*
|
||||||
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
* "Raspberry Pi" is a trademark of the Raspberry Pi Foundation.
|
||||||
*/
|
*/
|
||||||
#define __COMROGUE_KERNEL_LIB__
|
|
||||||
#include <comrogue/types.h>
|
#include <comrogue/types.h>
|
||||||
#include <comrogue/scode.h>
|
#include <comrogue/scode.h>
|
||||||
#include <comrogue/intlib.h>
|
#include <comrogue/intlib.h>
|
||||||
|
@ -50,7 +49,7 @@
|
||||||
* Returns:
|
* Returns:
|
||||||
* TRUE if the character is a digit, FALSE otherwise.
|
* TRUE if the character is a digit, FALSE otherwise.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE BOOL StrIsDigit8(CHAR ch)
|
BOOL StrIsDigit8(CHAR ch)
|
||||||
{
|
{
|
||||||
/* TODO: replace with something nicer later */
|
/* TODO: replace with something nicer later */
|
||||||
return MAKEBOOL((ch >= '0') && (ch <= '9'));
|
return MAKEBOOL((ch >= '0') && (ch <= '9'));
|
||||||
|
@ -65,7 +64,7 @@ SEG_LIB_CODE BOOL StrIsDigit8(CHAR ch)
|
||||||
* Returns:
|
* Returns:
|
||||||
* The length of the string in characters.
|
* The length of the string in characters.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE INT32 StrLength8(PCSTR psz)
|
INT32 StrLength8(PCSTR psz)
|
||||||
{
|
{
|
||||||
register PCSTR p = psz;
|
register PCSTR p = psz;
|
||||||
while (*p)
|
while (*p)
|
||||||
|
@ -83,7 +82,7 @@ SEG_LIB_CODE INT32 StrLength8(PCSTR psz)
|
||||||
* Returns:
|
* Returns:
|
||||||
* NULL if character was not found, otherwise pointer to character within string.
|
* NULL if character was not found, otherwise pointer to character within string.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE PCHAR StrChar8(PCSTR psz, INT32 ch)
|
PCHAR StrChar8(PCSTR psz, INT32 ch)
|
||||||
{
|
{
|
||||||
const CHAR mych = ch;
|
const CHAR mych = ch;
|
||||||
for (; *psz; psz++)
|
for (; *psz; psz++)
|
||||||
|
@ -113,11 +112,10 @@ SEG_LIB_CODE PCHAR StrChar8(PCSTR psz, INT32 ch)
|
||||||
* A pointer to the first digit of the converted value, which will be somewhere in the interval
|
* A pointer to the first digit of the converted value, which will be somewhere in the interval
|
||||||
* [pchBuf, pchBuf + nBytes).
|
* [pchBuf, pchBuf + nBytes).
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE static PCHAR convert_number_engine8(UINT64 value, PCHAR pchBuf, INT32 nBytes, INT32 nBase,
|
static PCHAR convert_number_engine8(UINT64 value, PCHAR pchBuf, INT32 nBytes, INT32 nBase, BOOL fUppercase)
|
||||||
BOOL fUppercase)
|
|
||||||
{
|
{
|
||||||
static DECLARE_LIB_STRING8_CONST(szDigitsUppercase, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
static DECLARE_STRING8_CONST(szDigitsUppercase, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
static DECLARE_LIB_STRING8_CONST(szDigitsLowercase, "0123456789abcdefghijklmnopqrstuvwxyz");
|
static DECLARE_STRING8_CONST(szDigitsLowercase, "0123456789abcdefghijklmnopqrstuvwxyz");
|
||||||
PCSTR pszDigits = (fUppercase ? szDigitsUppercase : szDigitsLowercase); /* digit set to use */
|
PCSTR pszDigits = (fUppercase ? szDigitsUppercase : szDigitsLowercase); /* digit set to use */
|
||||||
PCHAR p = pchBuf + nBytes; /* output pointer */
|
PCHAR p = pchBuf + nBytes; /* output pointer */
|
||||||
INT64 accumulator; /* accumulator of quotients */
|
INT64 accumulator; /* accumulator of quotients */
|
||||||
|
@ -154,8 +152,8 @@ SEG_LIB_CODE static PCHAR convert_number_engine8(UINT64 value, PCHAR pchBuf, INT
|
||||||
else { errorFlag = SEVERITY_ERROR; goto error; } } } while (0)
|
else { errorFlag = SEVERITY_ERROR; goto error; } } } while (0)
|
||||||
|
|
||||||
/* Strings used for padding */
|
/* Strings used for padding */
|
||||||
static DECLARE_LIB_STRING8_CONST(szPadSpace, " ");
|
static DECLARE_STRING8_CONST(szPadSpace, " ");
|
||||||
static DECLARE_LIB_STRING8_CONST(szPadZero, "0000000000000000000000000000000000000000000000000000000000");
|
static DECLARE_STRING8_CONST(szPadZero, "0000000000000000000000000000000000000000000000000000000000");
|
||||||
|
|
||||||
#define PAD_SIZE (sizeof(szPadSpace) - 1) /* number of characters available in pad string */
|
#define PAD_SIZE (sizeof(szPadSpace) - 1) /* number of characters available in pad string */
|
||||||
|
|
||||||
|
@ -183,12 +181,12 @@ static DECLARE_LIB_STRING8_CONST(szPadZero, "0000000000000000000000000000000000
|
||||||
* Notes:
|
* Notes:
|
||||||
* Floating-point conversion formats are not supported at this time.
|
* Floating-point conversion formats are not supported at this time.
|
||||||
*/
|
*/
|
||||||
SEG_LIB_CODE HRESULT StrFormatV8(PFNFORMAT8 pfnFormat, PVOID pArg, PCSTR pszFormat, va_list pargs)
|
HRESULT StrFormatV8(PFNFORMAT8 pfnFormat, PVOID pArg, PCSTR pszFormat, va_list pargs)
|
||||||
{
|
{
|
||||||
static DECLARE_LIB_STRING8_CONST(szFlagChars, "0+- #"); /* flag characters and values */
|
static DECLARE_STRING8_CONST(szFlagChars, "0+- #"); /* flag characters and values */
|
||||||
static const UINT32 SEG_LIB_RODATA auiFlagValues[] =
|
static const UINT32 SEG_RODATA auiFlagValues[] =
|
||||||
{ FLAG_ZEROPAD, FLAG_LEFTJUST, FLAG_PLUSSIGN, FLAG_SPACESIGN, FLAG_ALTMODE, 0 };
|
{ FLAG_ZEROPAD, FLAG_LEFTJUST, FLAG_PLUSSIGN, FLAG_SPACESIGN, FLAG_ALTMODE, 0 };
|
||||||
static DECLARE_LIB_STRING8_CONST(szConversionChars, "hl"); /* conversion characters */
|
static DECLARE_STRING8_CONST(szConversionChars, "hl"); /* conversion characters */
|
||||||
PCSTR p; /* pointer used to walk the format string */
|
PCSTR p; /* pointer used to walk the format string */
|
||||||
PCHAR pFlag; /* pointer to flag character/temp buffer pointer */
|
PCHAR pFlag; /* pointer to flag character/temp buffer pointer */
|
||||||
PCHAR pchOutput; /* pointer to characters actually output */
|
PCHAR pchOutput; /* pointer to characters actually output */
|
|
@ -60,8 +60,6 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* Taken from FreeBSD memcmp.S, munged by Erbo to COMROGUE standards */
|
/* Taken from FreeBSD memcmp.S, munged by Erbo to COMROGUE standards */
|
||||||
.section ".lib.text"
|
|
||||||
|
|
||||||
/* Func: INT32 StrCompareMem(PCVOID pMem1, PCVOID pMem2, SSIZE_T cb); */
|
/* Func: INT32 StrCompareMem(PCVOID pMem1, PCVOID pMem2, SSIZE_T cb); */
|
||||||
/*
|
/*
|
||||||
* Compares two memory blocks as bytes, returning a value for comparison between the two.
|
* Compares two memory blocks as bytes, returning a value for comparison between the two.
|
|
@ -27,8 +27,6 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* Taken from FreeBSD memcpy_arm.S, munged by Erbo to COMROGUE standards */
|
/* Taken from FreeBSD memcpy_arm.S, munged by Erbo to COMROGUE standards */
|
||||||
.section ".lib.text"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is one fun bit of code ...
|
* This is one fun bit of code ...
|
||||||
* Some easy listening music is suggested while trying to understand this
|
* Some easy listening music is suggested while trying to understand this
|
|
@ -64,8 +64,6 @@
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
/* Taken from FreeBSD memset.S, munged by Erbo to COMROGUE standards */
|
/* Taken from FreeBSD memset.S, munged by Erbo to COMROGUE standards */
|
||||||
.section ".lib.text"
|
|
||||||
|
|
||||||
/* FUNC: PVOID StrSetMem(PVOID pMem, INT32 ch, SSIZE_T cb); */
|
/* FUNC: PVOID StrSetMem(PVOID pMem, INT32 ch, SSIZE_T cb); */
|
||||||
/*
|
/*
|
||||||
* Fills a block of memory with a constant byte value.
|
* Fills a block of memory with a constant byte value.
|
Loading…
Reference in New Issue
Block a user