Skip to content

Commit de9cf43

Browse files
fix application support
1 parent e5e1386 commit de9cf43

5 files changed

Lines changed: 56 additions & 35 deletions

File tree

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ install: all $(addprefix install-,$(SRCS)) $(addprefix install-,$(LIBS))
5959
$(Q)$(call COPY,$(call NATIVEPATH,src/linker_script_app.ld),$(INSTALL_META))
6060
$(Q)$(call COPY,$(call NATIVEEXE,tools/convfont/convfont),$(INSTALL_BIN))
6161
$(Q)$(call COPY,$(call NATIVEEXE,tools/convimg/bin/convimg),$(INSTALL_BIN))
62-
$(Q)$(call COPY,$(call NATIVEEXE,tools/convbin/bin/convbin),$(INSTALL_BIN))
62+
#$(Q)$(call COPY,$(call NATIVEEXE,tools/convbin/bin/convbin),$(INSTALL_BIN))
6363
$(Q)$(call COPY,$(call NATIVEEXE,tools/cedev-config/bin/cedev-config),$(INSTALL_BIN))
6464
$(Q)$(call COPY,$(call NATIVEEXE,tools/cedev-obj/bin/cedev-obj),$(INSTALL_BIN))
6565
$(Q)$(WINDOWS_COPY)

src/crt/crt0.S

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@
3838
.equ ti.MovFrOP1, 0x02032C
3939
.equ ti.ClrLCDFull, 0x020808
4040

41-
#if !HAS_APPLICATION
4241
.section .header,"ax",@progbits
4342

4443
.local __header
4544
__header:
45+
#if HAS_APPLICATION
46+
.db 0x00 ; 0x00 is signifier for C applications (also force includes icon/description)
47+
#else
4648
.db 0xEF, 0x7B, 0x00 ; 0x00 is signifier for C programs
4749
#endif
4850

@@ -62,14 +64,21 @@ __header:
6264
.equ ti.MemClear, 0x0210DC
6365
.equ ti.ClrTxtShd, 0x020818
6466

67+
.global __start
68+
__start:
6569
ld iy, ti.flags
6670
ld sp, (ti.onSP) ; reset stacks
6771
call ti.ResetStacks
72+
ld bc, ___data_len
73+
or a, a
74+
sbc hl, hl
75+
adc hl, bc
76+
jr z, .L.skip_data_copy
6877
ld hl, ___data_lma
6978
ld de, ___data_vma
70-
ld bc, ___data_len
71-
ldir ; there is always .data, no need for zero check
72-
call __start
79+
ldir
80+
.L.skip_data_copy:
81+
call ___app_start
7382
ld de, (ti.asm_prgm_size)
7483
ld hl, ti.userMem
7584
call ti.DelMem
@@ -86,11 +95,13 @@ __header:
8695
ldir
8796
ld a, ti.kClear
8897
jp ti.JForceCmd
89-
#endif
90-
98+
.local ___app_start
99+
___app_start:
100+
#else
91101
.global __start
92102
__start:
93103
ld iy, ti.flags
104+
#endif
94105

95106
#if HAS_RUN_PRGM
96107
ld de, ___prgm_caller
@@ -158,6 +169,26 @@ ___libload_libs:
158169
call ti.RunIndicOff ; assumes iy = flags
159170
call ti.usb_DisableTimer
160171
di
172+
173+
.L.bss_zeroize:
174+
ld hl, ___bss_len
175+
ld bc, 0
176+
xor a, a
177+
sbc hl, bc
178+
jr z, .L.bss_done
179+
ld de, ___bss_low
180+
push de
181+
ld (de), a
182+
dec hl
183+
sbc hl, bc
184+
pop hl
185+
jr z, .L.bss_done
186+
ld bc, ___bss_len
187+
dec bc
188+
inc de
189+
ldir
190+
.L.bss_done:
191+
161192
res 1, (iy + 0x0D) ; no text buffer
162193
res 3, (iy + 0x4A) ; use first shadow buffer
163194
set 5, (iy + 0x4C) ; only display
@@ -250,25 +281,6 @@ ___libload_libs:
250281
call ti.PopRealO1
251282
#endif
252283

253-
.L.bss_zeroize:
254-
ld hl, ___bss_len
255-
ld bc, 0
256-
xor a, a
257-
sbc hl, bc
258-
jr z, .L.bss_done
259-
ld de, ___bss_low
260-
push de
261-
ld (de), a
262-
dec hl
263-
sbc hl, bc
264-
pop hl
265-
jr z, .L.bss_done
266-
ld bc, ___bss_len
267-
dec bc
268-
inc de
269-
ldir
270-
.L.bss_done:
271-
272284
#if HAS_CLOCK
273285
ld hl, ti.mpTmrCtrl + 1
274286
set ti.bTmr1CountUp - 8, (hl)

src/linker_script.ld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ SECTIONS
1313
KEEP (*(.header))
1414
KEEP (*(.header.icon))
1515
} >prgm
16+
1617
.init :
1718
{
1819
*(.init)
1920
} >prgm
21+
2022
.text :
2123
{
2224
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
@@ -27,6 +29,7 @@ SECTIONS
2729
*(.text .stub .text.* .gnu.linkonce.t.*)
2830
*(.gnu.warning)
2931
} >prgm
32+
3033
.rodata :
3134
{
3235
*(.rodata .rodata.* .gnu.linkonce.r.*)

src/linker_script_app.ld

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ MEMORY
44
bss : ORIGIN = BSSHEAP_LOW, LENGTH = BSSHEAP_HIGH - BSSHEAP_LOW
55
}
66

7+
PHDRS
8+
{
9+
prgm PT_LOAD;
10+
}
11+
712
SECTIONS
813
{
914
. = LOAD_ADDR;
1015

1116
.header :
1217
{
1318
KEEP (*(.header))
19+
PROVIDE_HIDDEN (___icon_optional = .);
1420
KEEP (*(.header.icon))
15-
} >prgm
21+
} >prgm :prgm
1622

1723
.init :
1824
{
1925
*(.init)
20-
} >prgm
26+
} >prgm :prgm
2127

2228
.text :
2329
{
@@ -28,12 +34,12 @@ SECTIONS
2834
*(SORT(.text.sorted.*))
2935
*(.text .stub .text.* .gnu.linkonce.t.*)
3036
*(.gnu.warning)
31-
} >prgm
37+
} >prgm :prgm
3238

3339
.rodata :
3440
{
3541
*(.rodata .rodata.* .gnu.linkonce.r.*)
36-
} >prgm
42+
} >prgm :prgm
3743

3844
.init_array :
3945
{
@@ -42,15 +48,15 @@ SECTIONS
4248
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*)))
4349
KEEP (*(.init_array))
4450
PROVIDE_HIDDEN (__init_array_end = .);
45-
} >prgm
51+
} >prgm :prgm
4652

4753
.fini_array :
4854
{
4955
PROVIDE_HIDDEN (__fini_array_start = .);
5056
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*)))
5157
KEEP (*(.fini_array))
5258
PROVIDE_HIDDEN (__fini_array_end = .);
53-
} >prgm
59+
} >prgm :prgm
5460

5561
.data :
5662
{
@@ -59,7 +65,7 @@ SECTIONS
5965
SORT(CONSTRUCTORS)
6066
*(.data1)
6167
___data_vma_end = .;
62-
} >bss AT>prgm
68+
} >bss AT>prgm :prgm
6369
___data_lma = LOADADDR(.data);
6470
___data_len = ___data_vma_end - ___data_vma;
6571

@@ -70,7 +76,7 @@ SECTIONS
7076
*(.bss .bss.* .gnu.linkonce.b.*)
7177
*(COMMON)
7278
___bss_high = .;
73-
} >bss
79+
} >bss :NONE
7480
___bss_len = ___bss_high - ___bss_low;
7581

7682
ASSERT(. <= BSSHEAP_HIGH, "Error: BSS exceed BSSHEAP_HIGH limit")

tools/convbin

0 commit comments

Comments
 (0)