Skip to content

Instantly share code, notes, and snippets.

@Oipo
Last active July 21, 2019 17:08
Show Gist options
  • Save Oipo/a30b3db18802ca2e23bb3523310b1073 to your computer and use it in GitHub Desktop.
Save Oipo/a30b3db18802ca2e23bb3523310b1073 to your computer and use it in GitHub Desktop.
// call one (EXECUTE_TASK_WITH_INIT)
400414: 52800033 mov w19, #0x1 // #1
400418: b9004bb3 str w19, [x29, #72]
40041c: b9004fbf str wzr, [x29, #76]
400420: b90053b3 str w19, [x29, #80]
400424: b90057b3 str w19, [x29, #84]
400428: b9005bbf str wzr, [x29, #88]
40042c: b9005fbf str wzr, [x29, #92]
400430: 90000475 adrp x21, 48c000 <__FRAME_END__+0x10334>
400434: f947b2b5 ldr x21, [x21, #3936]
400438: f9400aa2 ldr x2, [x21, #16]
40043c: 910123b4 add x20, x29, #0x48
400440: aa1403e1 mov x1, x20
400444: 52800080 mov w0, #0x4 // #4
400448: d63f0040 blr x2
// here is the supposedly identical code
40044c: d2800001 mov x1, #0x0 // #0
400450: d2800000 mov x0, #0x0 // #0
400454: 94000104 bl 400864 <m5_dump_stats>
400458: f94006a0 ldr x0, [x21, #8]
40045c: d63f0000 blr x0
400460: d2800001 mov x1, #0x0 // #0
400464: d2800000 mov x0, #0x0 // #0
400468: 940000ff bl 400864 <m5_dump_stats>
// call two (EXECUTE_TASK)
400460: d2800001 mov x1, #0x0 // #0
400464: d2800000 mov x0, #0x0 // #0
4005dc: 940000a2 bl 400864 <m5_dump_stats>
4005e0: 90000460 adrp x0, 48c000 <__FRAME_END__+0x10334> // What is this frame end variable?
4005e4: f946c800 ldr x0, [x0, #3472] // Where does this come from?
4005e8: f9400400 ldr x0, [x0, #8]
4005ec: d63f0000 blr x0
4005f0: d2800001 mov x1, #0x0 // #0
4005f4: d2800000 mov x0, #0x0 // #0
4005f8: 9400009b bl 400864 <m5_dump_stats>
000000000047bccc <__FRAME_END__>:
47bccc: 00000000 .word 0x00000000
// MIT license applies
#include "gem5/m5ops.h"
#include <stdio.h>
typedef int (*functionPtr)();
typedef int (*initFunctionPtr)(int count, int *task_args);
typedef struct task {
char *name;
functionPtr function;
initFunctionPtr init;
struct task* next_task;
} task;
// these are all defined in a library
void program_init(void);
extern task _altitude_control_task;
extern task _climb_control_task;
extern task _link_fbw_send;
extern task _navigation_task;
extern task _radio_control_task;
extern task _receive_gps_data_task;
extern task _reporting_task;
extern task _stabilisation_task;
extern task _check_failsafe_task;
extern task _check_mega128_values_task;
extern task _send_data_to_autopilot_task;
extern task _servo_transmit;
extern task _test_ppm_task;
#define EXECUTE_TASK_WITH_INIT(task, valcount, valone, valtwo, valthree, valfour, valfive, valsix) \
values[0] = valone; values[1] = valtwo; values[2] = valthree; values[3] = valfour; values[4] = valfive; values[5] = valsix; \
/*printf("running " #task " with %i count %i %i %i %i %i %i\n", valcount, valone, valtwo, valthree, valfour, valfive, valsix);*/ \
task.init(valcount, values); \
m5_dump_stats(0, 0); task.function(); m5_dump_stats(0, 0); \
#define EXECUTE_TASK(task) \
m5_dump_stats(0, 0); task.function(); m5_dump_stats(0, 0);
int main( int argc, char *argv[] ) {
int values[6];
program_init();
EXECUTE_TASK_WITH_INIT(_test_ppm_task, 4, 1, 0, 1, 1, 0, 0)
EXECUTE_TASK(_servo_transmit)
EXECUTE_TASK_WITH_INIT(_send_data_to_autopilot_task, 4, 0, 1, 1, 1, 0, 0)
EXECUTE_TASK_WITH_INIT(_check_mega128_values_task, 4, 0, 1, 0, 1, 0, 0)
EXECUTE_TASK_WITH_INIT(_check_failsafe_task, 1, 0, 0, 0, 0, 0, 0)
EXECUTE_TASK_WITH_INIT(_stabilisation_task, 1, 1, 0, 0, 0, 0, 0)
EXECUTE_TASK(_reporting_task)
EXECUTE_TASK_WITH_INIT(_receive_gps_data_task, 6, 0, 3, 0, 0, 0, 6)
EXECUTE_TASK_WITH_INIT(_radio_control_task, 5, 1, 4, 1, 1, 0, 0)
EXECUTE_TASK_WITH_INIT(_navigation_task, 2, 0, 3, 0, 0, 0, 0)
EXECUTE_TASK_WITH_INIT(_link_fbw_send, 1, 1, 0, 0, 0, 0, 0)
EXECUTE_TASK_WITH_INIT(_climb_control_task, 5, 0, 1, 7, 6, 1, 0)
EXECUTE_TASK_WITH_INIT(_altitude_control_task, 1, 1, 0, 0, 0, 0, 0)
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment