Skip to content

Commit

Permalink
z8: get things to build
Browse files Browse the repository at this point in the history
It's way too big still
  • Loading branch information
EtchedPixels committed Feb 15, 2024
1 parent e6a3c19 commit 3d730bd
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Kernel/cpu-z8/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern void *memmove(void *dest, const void *src, size_t n);

extern int16_t strlen(const char *p);

#define regptr register
#define staticfast

/* User's structure for times() system call */
Expand All @@ -39,9 +40,8 @@ typedef union { /* this structure is endian dependent */

#define cpu_to_le16(x) swab(x)
#define le16_to_cpu(x) swab(x)
#define cpu_to_le32(x) ((((uint32_t)cpu_to_le16((x) & 0xFFFF)) << 16) | \
(uint32_t)cpu_to_le16((x) >> 16))
#define le32_to_cpu(x) cpu_to_le32(x)
#define cpu_to_le32(x) swab32(x)
#define le32_to_cpu(x) swab32(x)

#define ntohs(x) (x)
#define ntohl(x) (x)
Expand Down
95 changes: 92 additions & 3 deletions Kernel/cpu-z8/lowlevel-z8.S
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ _sys_stubs:
callr0:
push r1
push r0
justret:
ret

deliver_signals:
Expand Down Expand Up @@ -96,7 +97,7 @@ raced:
ld 254,#>kstack_top
ld 255,#<kstack_top

clr int_disabled ; we keep this in register space as its asm only
clr _int_disabled ; we keep this in register space as its asm only
call map_kernel_di
call _chksigs
call map_proc_always_di
Expand Down Expand Up @@ -638,7 +639,7 @@ ___hard_irqrestore:
incw r14
incw r14
lde r3,@rr14
ld _init_disabled,r3
ld _int_disabled,r3
di
cp _int_disabled,#0
jr nz, diret
Expand All @@ -665,6 +666,8 @@ _cpu_detect:
; For speed critical cases you need asm stubs, for the others these
; will do.
;
; TODO: I/O mapping is board specific so this belongs in the platform
;
.export _in
.export _out

Expand All @@ -674,7 +677,7 @@ _cpu_detect:
;
_in:
ld r15,#2
call _gargr2
call __gargr2
ld r12,2
push r12
and 2,#0xBF ; I/O on
Expand All @@ -699,3 +702,89 @@ _out:

_set_cpu_type:
ret

.export _memcpy
.export _memset
.export _strlen
.export _swab
.export _swab32

_memcpy:
ld r15,#4
call __gargr4
ld r15,#6
call __garg12r2
; r12 is length
; r0/r1 dest
; r2/r3 src
incw r12
push r1
push r0
jr mcnext
mcloop:
lde r14,@rr2
lde @rr0,r14
incw rr0
incw rr2
mcnext:
decw rr12
jr nz,mcloop
pop r2
pop r3
ret

_memset:
ld r15,#4
call __gargr4
ld r15,#6
call __garg12r2
; r12 is length
; r0/r1 ptr
push r1
push r0
; r3 value
incw r12
jr msnext
msloop:
lde @rr0,r3
incw rr0
msnext:
decw rr2
jr nz, msloop
pop r2
pop r3
ret

_strlen:
ld r15,#2
call __garg12r2
; r1,r13 is now ptr
clr r2
clr r3
count:
lde r0,@rr12
jr z,strlen_done
incw rr12
incw rr2
jr count
strlen_done:
ret

_swab:
ld r15,#2
call __gargr2
ld r0,r3
ld r3,r2
ld r2,r0
ret

_swab32:
ld r15,#2
call __gargr4
ld r12,r3
ld r3,r0
ld r0,r12
ld r12,r2
ld r2,r1
ld r1,r12
ret
10 changes: 5 additions & 5 deletions Kernel/cpu-z8/usermem_std-z8.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

__uputc:
ld r15,#2
call gargr4 ; r0-r1 val, r2-r3 ptr
call __gargr4 ; r0-r1 val, r2-r3 ptr
call map_proc_always
lde @rr2,r1
clr r2
Expand All @@ -21,7 +21,7 @@ __uputc:

__uputw:
ld r15,#2
call gargr4 ; r0-r1 val, r2-r3 ptr
call __gargr4 ; r0-r1 val, r2-r3 ptr
call map_proc_always
lde @rr2,r0
incw rr2
Expand All @@ -34,7 +34,7 @@ __uputw:

__ugetc:
ld r15,#2
call gargr2
call __gargr2
call map_proc_always
lde r3,@rr2
clr r2
Expand All @@ -44,7 +44,7 @@ __ugetc:

__ugetw:
ld r15,#2
call gargr2
call __gargr2
ld r14,r2
ld r15,r3
call map_proc_always
Expand Down Expand Up @@ -149,7 +149,7 @@ nowork:

__uzero:
ld r3,#2
call gargr4 ; 0-1 ptr 2-3 length
call __gargr4 ; 0-1 ptr 2-3 length

ld r12,r2
or r12,r3
Expand Down

0 comments on commit 3d730bd

Please sign in to comment.