void ancs_run() { if (ancs_send_buffered_command()) { ancs_updated = false; } else if (!ancs_updated) { ancs_updated = true; //ancs_notification_list_apply(&ancs_notifications_use_hook); free_ram(); } }
/********************** ************************/ int main(int argc,char *argv[]) { int n_pages = 0; //int n_frames = 0; ram_info_t ram_info;// ram_info.n_frames = 0;// ram_info.algorithm = NULL;// int n_cache = 0; int n_tlb = 0; char *access_file = NULL; FILE *access_fd = NULL; addr_t virtual_addr = 0; addr_t physical_addr; pid_t pid = 0; char mode; /* * Parse arguments */ if( 0 != parse_args(argc, argv, &access_file, &n_pages, &ram_info.n_frames, &n_cache, &n_tlb, &ram_info.algorithm) ) {// return -1; } /* * Setup data structures */ srand(time(NULL)); current_ref = (char *)malloc(sizeof(char) * MAX_LINE); clear_stats(); stats.cache_size = n_cache; stats.tlb_size = n_tlb; stats.num_pages = n_pages; stats.num_frames = ram_info.n_frames;// printf("Allocating resources...\n"); allocate_cache(n_cache); allocate_tlb(n_tlb); allocate_page_table(n_pages); allocate_page_directory(n_pages); //allocate_ram(n_frames); allocate_ram(ram_info); /* * Open the file that we are going to read */ if( NULL == (access_fd = fopen(access_file, "r") ) ) { fprintf(stderr, "Error: Unable to open the access file <%s>\n", access_file); return -1; } /* * Read page requests from the file */ gettimeofday(&stats.start, NULL); while(0 == feof(access_fd) ) { /* Read one line */ current_ref[0] = '\0'; if( NULL == fgets(current_ref, MAX_LINE, access_fd) ) { break; } /* Strip off the newline */ if( '\n' == current_ref[strlen(current_ref)-1] ) { current_ref[strlen(current_ref)-1] = '\0'; } extract_args(current_ref, &pid, &mode, &virtual_addr); /* * Memory management operations to access the page */ if(VERBOSE){ printf("-----------------------------------------------------------\n"); printf("%s: Process %*d \t Access [Page %4d, Offset %#05x] (%#010x)\n", current_ref, MAX_PID_LEN, pid, GET_PAGE(virtual_addr), GET_OFFSET(virtual_addr), virtual_addr); } access_page(pid, mode, virtual_addr, &physical_addr); if(VERBOSE){ printf("%s: Process %*d \t Access [Page %4d, Offset %#05x] (%#010x) --> (%#010x) [Frame %4d, Offset %#05x]\n", current_ref, MAX_PID_LEN, pid, GET_PAGE(virtual_addr), GET_OFFSET(virtual_addr), virtual_addr, physical_addr, GET_FRAME(physical_addr), GET_OFFSET(physical_addr)); } } gettimeofday(&stats.end, NULL); display_stats(); /* * Cleanup */ fclose(access_fd); if( NULL != current_ref ) { free(current_ref); current_ref = NULL; } free_ram(); free_page_dir(); free_tlb(); free_cache(); return 0; }
void ancs_get_notification_data(uint32_t uid) { if (command_send_enable || ((millis() - last_command_send) > 1000)) { Serial.print(F("[ANCS NS] ancs_get_notification_data(")); Serial.print(uid, DEC); Serial.println(F(")")); debug2_print(F("[ANCS NS] Buffering commands to get details for notification #")); debug2_println(uid, DEC); uint8_t* buffer; #ifdef ANCS_USE_APP buffer = (uint8_t*)malloc(6); // pack(buffer, "BIB", ANCS_COMMAND_GET_NOTIF_ATTRIBUTES, uid, ANCS_NOTIFICATION_ATTRIBUTE_APP_IDENTIFIER); fifo_push(buffer_commands, buffer, 6); free(buffer); #endif // buffer = (uint8_t*)malloc(8); pack(buffer, "BIBH", ANCS_COMMAND_GET_NOTIF_ATTRIBUTES, uid, ANCS_NOTIFICATION_ATTRIBUTE_TITLE, ANCS_NOTIFICATION_ATTRIBUTE_DATA_SIZE); fifo_push(buffer_commands, buffer, 8); free(buffer); // buffer = (uint8_t*)malloc(6); pack(buffer, "BIB", ANCS_COMMAND_GET_NOTIF_ATTRIBUTES, uid, ANCS_NOTIFICATION_ATTRIBUTE_DATE); fifo_push(buffer_commands, buffer, 6); free(buffer); buffer = (uint8_t*)malloc(6); pack(buffer, "BIB", ANCS_COMMAND_GET_NOTIF_ATTRIBUTES, uid, ANCS_NOTIFICATION_ATTRIBUTE_MESSAGE_SIZE); fifo_push(buffer_commands, buffer, 6); free(buffer); // #ifdef ANCS_USE_SUBTITLE buffer = (uint8_t*)malloc(8); pack(buffer, "BIBB", ANCS_COMMAND_GET_NOTIF_ATTRIBUTES, uid, ANCS_NOTIFICATION_ATTRIBUTE_SUBTITLE, ANCS_NOTIFICATION_ATTRIBUTE_DATA_SIZE); fifo_push(buffer_commands, buffer, 8); free(buffer); #endif // buffer = (uint8_t*)malloc(8); pack(buffer, "BIBH", ANCS_COMMAND_GET_NOTIF_ATTRIBUTES, uid, ANCS_NOTIFICATION_ATTRIBUTE_MESSAGE, MESSAGE_SIZE); fifo_push(buffer_commands, buffer, 8); free(buffer); free_ram(); debug_println(F("[ANCS NS] ancs_get_notification_data(): end")); debug_print(F("[ANCS NS] Command Send Enable: ")); debug_println(command_send_enable); } else { Serial.print(F("[ANCS NS] ancs_get_notification_data(")); Serial.print(uid, DEC); Serial.print(F(") - Need Command Send - ")); Serial.println(millis() - last_command_send); debug_print(command_send_enable); } }