@@ -6,16 +6,14 @@ const app = @import("app");
66// Use microzig panic handler if not defined by an application
77pub const panic = if (! @hasDecl (app , "panic" )) microzig .panic else app .panic ;
88
9- pub const microzig_options : microzig.Options = if (@hasDecl (app , "microzig_options" )) app .microzig_options else .{};
10-
119// Conditionally provide a default no-op logFn if app does not have one
1210// defined. Parts of microzig use the stdlib logging facility and
1311// compilations will now fail on freestanding systems that use it but do
1412// not explicitly set `root.std_options.logFn`
1513pub const std_options : std.Options = .{
16- .log_level = microzig_options .log_level ,
17- .log_scope_levels = microzig_options .log_scope_levels ,
18- .logFn = microzig_options .logFn ,
14+ .log_level = microzig . options .log_level ,
15+ .log_scope_levels = microzig . options .log_scope_levels ,
16+ .logFn = microzig . options .logFn ,
1917};
2018
2119// Startup logic:
@@ -72,7 +70,7 @@ export fn microzig_main() noreturn {
7270
7371 const msg_base = "main() returned error." ;
7472
75- if (! builtin . strip_debug_info ) {
73+ if (! microzig . options . simple_panic_if_main_errors ) {
7674 const max_error_size = comptime blk : {
7775 var max_error_size : usize = 0 ;
7876 const err_type = @typeInfo (return_type ).error_union .error_set ;
@@ -98,37 +96,3 @@ export fn microzig_main() noreturn {
9896 // Main returned, just hang around here a bit.
9997 microzig .hang ();
10098}
101-
102- /// Contains references to the microzig .data and .bss sections, also
103- /// contains the initial load address for .data if it is in flash.
104- pub const sections = struct {
105- // it looks odd to just use a u8 here, but in C it's common to use a
106- // char when linking these values from the linkerscript. What's
107- // important is the addresses of these values.
108- extern var microzig_data_start : u8 ;
109- extern var microzig_data_end : u8 ;
110- extern var microzig_bss_start : u8 ;
111- extern var microzig_bss_end : u8 ;
112- extern const microzig_data_load_start : u8 ;
113- };
114-
115- pub fn initialize_system_memories () void {
116- // fill .bss with zeroes
117- {
118- const bss_start : [* ]u8 = @ptrCast (& sections .microzig_bss_start );
119- const bss_end : [* ]u8 = @ptrCast (& sections .microzig_bss_end );
120- const bss_len = @intFromPtr (bss_end ) - @intFromPtr (bss_start );
121-
122- @memset (bss_start [0.. bss_len ], 0 );
123- }
124-
125- // load .data from flash
126- {
127- const data_start : [* ]u8 = @ptrCast (& sections .microzig_data_start );
128- const data_end : [* ]u8 = @ptrCast (& sections .microzig_data_end );
129- const data_len = @intFromPtr (data_end ) - @intFromPtr (data_start );
130- const data_src : [* ]const u8 = @ptrCast (& sections .microzig_data_load_start );
131-
132- @memcpy (data_start [0.. data_len ], data_src [0.. data_len ]);
133- }
134- }
0 commit comments