void csyscall() { /* A trivial system call */ /*printf("We made it back into the kernel :-)\n");*/ /*printf("eax=%x, ebx=%x, retaddr=%x, esp=%x\n", user.regs.eax, user.regs.ebx, user.iret.eip, user.iret.esp);*/ putchar(user.regs.eax); switchToUser(&user); }
void kernel() { struct BootData* bd = (struct BootData*)0x1000; unsigned* hdrs = bd->headers; unsigned* mmap = bd->mmap; unsigned i; setWindow(2, 22, 0, 45); // kernel on left hand side cls(); printf("Protected kernel has booted!\n"); printf("Headers:\n"); for (i=0; i<hdrs[0]; i++) { printf(" header[%d]: [%x-%x], entry %x\n", i, hdrs[3*i+1], hdrs[3*i+2], hdrs[3*i+3]); } printf("Memory map:\n"); for (i=0; i<mmap[0]; i++) { printf(" mmap[%d]: [%x-%x]\n", i, mmap[2*i+1], mmap[2*i+2]); } printf("Strings:\n"); printf(" cmdline: %s [%x]\n", bd->cmdline, bd->cmdline); printf(" imgline: %s [%x]\n", bd->imgline, bd->imgline); printf("user code is at 0x%x\n", hdrs[9]); initContext(&user, hdrs[9], 0); printf("user is at %x\n", (unsigned)(&user)); switchToUser(&user); printf("This message shouldn't appear!\n"); }
C_RESULT ardrone_general_navdata_process( const navdata_unpacked_t* const pnd ) { navdata_mode_t current_navdata_state = NAVDATA_BOOTSTRAP; /* Makes sure the navdata stream will be resumed if the drone is disconnected and reconnected. * Allows changing the drone battery during debugging sessions. */ if( ardrone_get_mask_from_state(pnd->ardrone_state, ARDRONE_NAVDATA_BOOTSTRAP) ) { current_navdata_state = NAVDATA_BOOTSTRAP; } else { current_navdata_state = (ardrone_get_mask_from_state(pnd->ardrone_state, ARDRONE_NAVDATA_DEMO_MASK)) ? NAVDATA_DEMO : NAVDATA_FULL ; } if (current_navdata_state == NAVDATA_BOOTSTRAP && configState == MULTICONFIG_IDLE && navdataState == NAVDATA_REQUEST_IDLE) { navdataState = NAVDATA_REQUEST_NEEDED; } /* Multiconfig settings */ int configIndex, userNeedInit, appNeedInit; userNeedInit = 0; appNeedInit = 0; switch (configState) { case MULTICONFIG_GOT_DRONE_VERSION: PRINTDBG ("Checking drone version ...\n"); // Check if drone version is >= 1.6 if (versionSupportsMulticonfiguration (ardrone_control_config.num_version_soft)) { PRINTDBG ("Drone supports multiconfig\n"); configState = MULTICONFIG_IN_PROGRESS_LIST; ARDRONE_TOOL_CUSTOM_CONFIGURATION_GET (configurationCallback); droneSupportsMulticonfig = 1; } else { PRINTDBG ("Drone does not support multiconfig\n"); // Drone does not support multiconfig ... don't call init functions because we don't want to mess up things in default config configState = MULTICONFIG_REQUEST_NAVDATA; } break; case MULTICONFIG_GOT_IDS_LIST: // At this point, we're sure that the AR.Drone supports multiconfiguration, so we'll wheck if our ids exists, and send them. PRINTDBG ("Got AR.Drone ID list. Switch->%d,%d,%d. ND->%d\n", sesSwitch, usrSwitch, appSwitch, navdataNeeded); if (1 == sesSwitch) { switchToSession(); // Go to session ... } if (1 == appSwitch) { if (0 != strcmp(ardrone_control_config_default.application_id, app_id)) // Check for application only if we're not asking for the default one { appNeedInit = 1; for (configIndex = 0; configIndex < available_configurations[CAT_APPLI].nb_configurations; configIndex++) // Check all existing app_ids { PRINTDBG ("Checking application %s (desc : %s)\n", available_configurations[CAT_APPLI].list[configIndex].id, available_configurations[CAT_APPLI].list[configIndex].description); if (0 == strcmp(available_configurations[CAT_APPLI].list[configIndex].id, app_id)) { PRINTDBG ("Found our application ... should not init\n"); appNeedInit = 0; break; } } switchToApplication(); } else { PRINTDBG ("We're requesting default application (%s), do nothing.\n", app_id); } } if (1 == usrSwitch) { if (0 != strcmp(ardrone_control_config_default.profile_id, usr_id)) // Check for user only if we're not asking for the default one { userNeedInit = 1; for (configIndex = 0; configIndex < available_configurations[CAT_USER].nb_configurations; configIndex++) // Check all existing user_ids { PRINTDBG ("Checking user %s (desc : %s)\n", available_configurations[CAT_USER].list[configIndex].id, available_configurations[CAT_USER].list[configIndex].description); if (0 == strcmp(available_configurations[CAT_USER].list[configIndex].id, usr_id)) { PRINTDBG ("Found our user ... should not init\n"); userNeedInit = 0; break; } } switchToUser(); } else { PRINTDBG ("We're requesting default user (%s), do nothing.\n", usr_id); } } if (1 == appNeedInit) { // Send application defined default values ardrone_tool_send_application_default(); PRINTDBG ("Creating app. profile on AR.Drone\n"); ARDRONE_TOOL_CONFIGURATION_ADDEVENT (application_desc, app_name, NULL); } if (1 == userNeedInit) { // Send user defined default values ardrone_tool_send_user_default(); PRINTDBG ("Creating usr. profile on AR.Drone\n"); ARDRONE_TOOL_CONFIGURATION_ADDEVENT (profile_desc, usr_name, NULL); } if (1 == sesSwitch) { if (0 != strcmp(ardrone_control_config_default.session_id, ses_id)) // Send session info only if session is not the default one { ARDRONE_TOOL_CONFIGURATION_ADDEVENT (session_desc, ses_name, NULL); // Send session specific default values ardrone_tool_send_session_default(); } else { PRINTDBG ("We're requesting default session (%s), do nothing.\n", ses_id); } } configState = MULTICONFIG_IN_PROGRESS_IDS; ARDRONE_TOOL_CONFIGURATION_GET (configurationCallback); case MULTICONFIG_GOT_CURRENT_IDS: if (0 != strcmp(ardrone_control_config.session_id, ses_id) || 0 != strcmp(ardrone_control_config.profile_id, usr_id) || 0 != strcmp(ardrone_control_config.application_id, app_id)) { configState = MULTICONFIG_GOT_DRONE_VERSION; // We failed at setting up the application ids ... restart (but assume that drone supports multiconfig as we already checked) } else if (1 == navdataNeeded) { configState = MULTICONFIG_REQUEST_NAVDATA; } else { configState = MULTICONFIG_IDLE; } break; case MULTICONFIG_NEEDED: PRINTDBG ("Need to check multiconfig ... request config file\n"); // Get config file for reset configState = MULTICONFIG_IN_PROGRESS_VERSION; ARDRONE_TOOL_CONFIGURATION_GET (configurationCallback); break; case MULTICONFIG_REQUEST_NAVDATA: PRINTDBG ("Send application navdata demo/options\n"); // Send application navdata demo/options to start navdatas from AR.Drone ARDRONE_TOOL_CONFIGURATION_ADDEVENT (navdata_demo, &ardrone_application_default_config.navdata_demo, NULL); if (TRUE == ardrone_application_default_config.navdata_demo) { // Send navdata options only for navdata demo mode ARDRONE_TOOL_CONFIGURATION_ADDEVENT (navdata_options, &ardrone_application_default_config.navdata_options, NULL); } configState = MULTICONFIG_IDLE; break; case MULTICONFIG_IDLE: case MULTICONFIG_IN_PROGRESS_LIST: case MULTICONFIG_IN_PROGRESS_VERSION: case MULTICONFIG_IN_PROGRESS_IDS: default: break; } /* Navdata request settings */ switch (navdataState) { case NAVDATA_REQUEST_NEEDED: PRINTDBG ("Resetting navdatas to %s\n", (0 == ardrone_application_default_config.navdata_demo) ? "full" : "demo"); navdataState = NAVDATA_REQUEST_IN_PROGRESS; switchToSession(); // Resend session id when reconnecting. ARDRONE_TOOL_CONFIGURATION_ADDEVENT(navdata_demo, &ardrone_application_default_config.navdata_demo, NULL); if (TRUE == ardrone_application_default_config.navdata_demo) { // Send navdata options only for navdata demo mode ARDRONE_TOOL_CONFIGURATION_ADDEVENT (navdata_options, &ardrone_application_default_config.navdata_options, navdataCallback); } break; case NAVDATA_REQUEST_IN_PROGRESS: case NAVDATA_REQUEST_IDLE: default: break; } return C_OK; }