diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-21 13:09:21 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-21 13:09:21 +0100 |
| commit | 40ffc517e20c381ce8fdb3a881726a26a52e35db (patch) | |
| tree | b969f6e1bc4c400e8c2c8b1d5a18ed75d3f2fd95 /kernel/string.S | |
| parent | d394978a73fce080128dc414e1771d8d89e1e1e0 (diff) | |
| download | fbos-40ffc517e20c381ce8fdb3a881726a26a52e35db.tar.gz fbos-40ffc517e20c381ce8fdb3a881726a26a52e35db.zip | |
Initial parsing of the provided initrd file
We expect a CPIO archive with the 'newc' format for the initrd. Parse
this archive from the given initrd address and fetch the address for
each ELF executable while also pairing which task correspond to which
ELF.
This commit leaves to do the actual parsing of the ELF file for each
task, while also leaving some string utilities to be refined.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'kernel/string.S')
| -rw-r--r-- | kernel/string.S | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/kernel/string.S b/kernel/string.S index afd5985..4fb1ccc 100644 --- a/kernel/string.S +++ b/kernel/string.S @@ -35,12 +35,38 @@ strcmp: 1: lbu t0, 0(a0) lbu t1, 0(a1) - bne t0, t1, 2f addi a0, a0, 1 addi a1, a1, 1 + bne t0, t1, 2f bnez t0, 1b li a0, 0 ret 2: sub a0, t0, t1 ret + +/* + * Defined in include/fbos/string.h + * + * int memcmp(const void *ptr1, const void *ptr2, size_t n) + * + * Returns (a0): comparison result as in stdlib. + * Parameter (a0, a1): strings to compare. + * Clobbers: t0, t1. + */ +.global memcmp +.type memcmp, @function +memcmp: +1: + lbu t0, 0(a0) + lbu t1, 0(a1) + bne t0, t1, 2f + addi a0, a0, 1 + addi a1, a1, 1 + addi a2, a2, -1 + bnez a2, 1b + li a0, 0 + ret +2: + sub a0, t0, t1 + ret |
