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

Revert for ADI-Expander #243

Merged
merged 2 commits into from
Aug 29, 2020
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
4 changes: 0 additions & 4 deletions include/pros/apix.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#ifndef _PROS_API_EXTENDED_H_
#define _PROS_API_EXTENDED_H_

#define PROS_KERNEL_PRE_INIT 110

#define PROS_KERNEL_INIT 120

#include "api.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
Expand Down
2 changes: 1 addition & 1 deletion src/display/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static bool vex_read_touch(lv_indev_data_t* data) {
return false;
}

__attribute__((constructor(PROS_KERNEL_INIT-1))) static void display_init(void) {
void display_initialize(void) {
lv_init();

lv_disp_drv_t disp_drv;
Expand Down
30 changes: 14 additions & 16 deletions src/system/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,31 @@
extern void rtos_initialize();
extern void vfs_initialize();
extern void system_daemon_initialize();
// extern void graphical_context_daemon_initialize(void);
extern void display_initialize(void);
extern void rtos_sched_start();
extern void vdml_initialize();
extern void invoke_install_hot_table();

// XXX: pros_pre_init and pros_init happen inside __libc_init_array, and
// before any globalC++ constructors are invoked. This is accomplished by
// instructing GCC to include this function in the __init_array. The macros
// defined in pros/apix.h give the compiler instructions on the priority of the
// constructor, from 0-~65k. The first 0-100 priorities are reserved for
// language implementation.

__attribute__((constructor(PROS_KERNEL_PRE_INIT))) static void pros_pre_init(void) {
// XXX: pros_init happens inside __libc_init_array, and before any global
// C++ constructors are invoked. This is accomplished by instructing
// GCC to include this function in the __init_array. The 101 argument
// gives the compiler instructions on the priority of the constructor,
// from 0-~65k. The first 0-100 priorities are reserved for language
// implementation.
__attribute__((constructor(101))) static void pros_init(void) {
rtos_initialize();

vfs_initialize();

vdml_initialize();
}

// HACK: External templates can hook into initialization process by setting
// their priority between PROS_KERNEL_PRE_INIT and PROS_KERNEL_INIT. For
// exmaple the priority of display initialization is 119. All other initialize
// functions should be called before pros_init function. For an exmaple of
// what could happen if this is not the case, see
// https://github.com/purduesigbots/pros/pull/144/#issuecomment-496901942
display_initialize();

__attribute__((constructor(PROS_KERNEL_INIT))) static void pros_init(void) {
// NOTE: this function should be called after all other initialize
// functions. for an example of what could happen if this is not
// the case, see
// https://github.com/purduesigbots/pros/pull/144/#issuecomment-496901942
system_daemon_initialize();

invoke_install_hot_table();
Expand Down