Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pushing in more work done from last night #3

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MkDDE,fd7
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ 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
IFthere @.src.dtblib.h.krnllib Then copy @.src.dtblib.h.krnllib @.!LibDTB.h.krnllib ~C N
IFthere @.src.dtblib.h.strlib Then copy @.src.dtblib.h.strlib @.!LibDTB.h.strlib ~C N

echo
echo ---------------------
Expand Down
10 changes: 8 additions & 2 deletions src/dtblib/MakefileDDE
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ LIBS =

# Dynamic dependencies:

oz.krnllib: c.krnllib
oz.krnllib: h.krnllib
o.krnllib: c.krnllib
o.krnllib: h.krnllib
oz.strlib: c.strlib
oz.strlib: h.krnllib
oz.strlib: h.strlib
oz.strlib: h.krnllib
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
Expand Down
8 changes: 8 additions & 0 deletions src/dtblib/c/strlib
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ size_t str_len(const char* str) {
return length;
}

int str_cmp(const char* str1, const char* str2) {
while (*str1 && (*str1 == *str2)) {
str1++;
str2++;
}
return *(const unsigned char*)str1 - *(const unsigned char*)str2;
}

char* str_read(const char* data, int offset) {
int length = 0;
// Calculate the length of the string
Expand Down
1 change: 1 addition & 0 deletions src/dtblib/h/strlib
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "krnllib.h"

size_t str_len(const char* str);
int str_cmp(const char* str1, const char* str2);
char* str_read(const char* data, int offset);

#endif /* STRLIB_H_ */
4 changes: 4 additions & 0 deletions tests/001BasicDTBParse/MakefileDDE
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ LDFLAGS = -util
# Dynamic dependencies:

o.main: c.main
o.main: LibDTB:h.krnllib
o.main: LibDTB:h.strlib
o.main: LibDTB:h.krnllib
o.main: LibDTB:h.dtblib
o.main: h.main
20 changes: 15 additions & 5 deletions tests/001BasicDTBParse/c/main
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,29 @@

#include <assert.h>

#include "LibDTB:krnllib.h"
#include "LibDTB:strlib.h"
#include "LibDTB:dtblib.h"
#include "main.h"

void test_simple_dtb() {
const char* load_dtb(const char* filename) {
// Function to load a DTB file
(void)filename;
return NULL;
}

void test_simple_dtb(void) {
const char* simple_dtb = load_dtb("simple.dtb"); // Function to load a DTB file
struct dt_node* root = parse_dtb(simple_dtb);
char *string_block = (char *)krnl_malloc(1024);
struct dt_node* root = parse_dtb(simple_dtb, string_block, 0);

assert(root != NULL); // Replace with your own assert function
assert(strcmp(root->name, "root_node_name") == 0);
assert(str_cmp(root->name, "root_node_name") == 0);

// Further checks for children, properties, etc.

free_tree(root); // Clean up
free_dtb(simple_dtb); // Function to free DTB data
krnl_free((void *)root); // Clean up
krnl_free((void *)simple_dtb); // Function to free DTB data
}

int main() {
Expand Down
10 changes: 10 additions & 0 deletions tests/001BasicDTBParse/h/main
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
*/

#ifndef MAIN_H_
#define MAIN_H_

const char* load_dtb(const char* filename);
void test_simple_dtb(void);

#endif /* MAIN_H_ */
Loading