int ldr_main(struct multiboot_info* boot_info, uint32 krnldr_size_bytes) { SetColor(MakeColor(DARK_BLUE, WHITE)); ClearScreen(); if (krnldr_size_bytes > 40 KB) PANIC("Kernel Loader is too large"); init_kallocations(KRN_LDR_BASE + krnldr_size_bytes, KRN_LDR_LIMIT); Print("Initializing descriptor tables."); INT_OFF; init_isr(); init_descriptor_tables(); init_pic(); INT_ON; init_pit_timer(50, timer_callback); struct kernel_info* k_info = kalloc(sizeof(struct kernel_info)); //setup AHCI HBA_MEM_t* abar = PCIFindAHCI(); // initialize basic virtual memory vmmngr_initialize(); uint32 ahci_base = kalloc_get_ptr() + 1024 - (uint32)kalloc_get_ptr() % 1024; init_ahci(abar, ahci_base); uint32 start, _length, position = 0; fsysSimpleFind("MeOs.exe", 1, &_length, &start); if (start == (uint32)-1 && _length == 0) PANIC("Kernel module could not be found!"); while (position <= _length) { fsysSimpleRead(start + position / 512, 4096, KERNEL_BASE + position); position += 4096; } // after all the loading is done... enable paging vmmngr_paging_enable(true); k_info->kernel_size = _length; k_info->isr_handlers = interrupt_handlers; k_info->gdt_base = gdt_entries; k_info->idt_base = idt_entries; printfln("Executing kernel\0"); execute_kernel(boot_info, k_info); ClearScreen(); _asm cli _asm hlt }
int main(void){ init_io(); init_isr(); sei();// Global Interrupts aktivieren uint8_t i =0; while(1){ for(i=0;i<27;i++) { led_values[i]++; } sleep_ms(3); } return 0; }
int k0_main(multiboot_header_t *header) { k0_cls(); module_header_t *mod_header = (module_header_t *)header->mods_addr; //msg[4] = '\0'; //k0_print(msg); //k0_print_char('\n'); k0_print("Kernel level 0 loaded.\nInitializing GDT... "); init_gdt(); k0_print("OK\nInitializing IDT... "); init_idt(); k0_print("OK\nInitializing ISR... "); init_isr(); k0_print("OK\nInitializing IRQ... "); init_irq(); k0_print("OK\n"); k1_main(mod_header); return 0; }
void test_isr() { int i, j; c1 = c2 = c3 = 0; //init init_isr(); for(i=0;i<100;i++) { //trigger isr1 trigger_int(0); for(j=0;j<10000;j++); //get isr1 cnt printf("(%u)c1=%u\n", i, c1); read_IFR(); } }
int main() { char pkt_arr[] = {0, 0, 0}; // {damage, health, stun} unsigned char i = 0; // Initialize PIC init_pic(); //init_uart(); // Initialize teammates' code init_ir(); init_accel(); init_leds(); init_isr(); init_conn(); /* RC4 = 1; __delay_ms(250); RC4 = 0; __delay_ms(250); RC4 = 1; __delay_ms(250); RC4 = 0; __delay_ms(250); RC4 = 1; __delay_ms(250); RC4 = 0; */ // main loop while(1) { #if _ALPHA_BLADE display_health(); if(damage_received) { display_blade_lights(_LIGHT_MODE_DAMAGE_RECEIVED); damage_received = 0; } if( determine_sword_was_swung() && ( ( health > 0) || determine_omega_mode_active() ) ) { if(!determine_omega_mode_active()) { display_blade_lights(_LIGHT_MODE_INDIVIDUAL_SWING); determine_packets_to_send(&pkt_arr); for(i = 3; i > 0; --i) { if(pkt_arr[i-1] > 0) { GIE = 0; output_ir(i-1, pkt_arr[i-1]); GIE = 1; } } } else { display_blade_lights(_LIGHT_MODE_OMEGA_SWING); } } GIE = 0; while( ( stun_counter > 0 ) && !determine_omega_mode_active() ) { GIE = 1; //****************Turn full blue //Green to 0% PSMC2DCH = 0xFF;//PSMC2 Duty Cycle High-byte PSMC2DCL = 0xFF;//PSMC2 Duty Cycle Low-byte PSMC2LD = 1; //PSMC 2 Load //Blue to 0% PSMC3DCH = 0x00;//PSMC3 Duty Cycle High-byte PSMC3DCL = 0x00;//PSMC3 Duty Cycle Low-byte PSMC3LD = 1; //PSMC 3 Load //Red to 100% PSMC4DCH = 0xFF;//PSMC4 Duty Cycle High-byte PSMC4DCL = 0x00;//PSMC4 Duty Cycle Low-byte PSMC4LD = 1; //PSMC 4 Load //Set Load Bit to load duty cycle values PSMC2LD = 1; //PSMC 2 Load PSMC3LD = 1; //PSMC 3 Load PSMC4LD = 1; //PSMC 4 Load __delay_ms(50); //****************Turn off //Green to 0% PSMC2DCH = 0x00;//PSMC2 Duty Cycle High-byte PSMC2DCL = 0x00;//PSMC2 Duty Cycle Low-byte PSMC2LD = 1; //PSMC 2 Load //Blue to 0% PSMC3DCH = 0x00;//PSMC3 Duty Cycle High-byte PSMC3DCL = 0x00;//PSMC3 Duty Cycle Low-byte PSMC3LD = 1; //PSMC 3 Load //Red to 0% PSMC4DCH = 0x00;//PSMC4 Duty Cycle High-byte PSMC4DCL = 0x00;//PSMC4 Duty Cycle Low-byte PSMC4LD = 1; //PSMC 4 Load //Set Load Bit to load duty cycle values PSMC2LD = 1; //PSMC 2 Load PSMC3LD = 1; //PSMC 3 Load PSMC4LD = 1; //PSMC 4 Load __delay_ms(50); GIE = 0; --stun_counter; } GIE = 1; #elif _BETA_BLADE display_health(); if( determine_sword_was_swung() ) { if(!determine_omega_mode_active()) { play_sound(_SOUND_TYPE_INDIVIDUAL); display_blade_lights(_LIGHT_MODE_INDIVIDUAL_SWING); determine_packets_to_send(&pkt_arr); for(i = 3; i > 0; --i) { if(pkt_arr[i-1] > 0) { GIE = 0; output_ir(i-1, pkt_arr[i-1]); GIE = 1; } } } else { play_sound(_SOUND_TYPE_OMEGA); display_blade_lights(_LIGHT_MODE_OMEGA_SWING); } } #elif _DELTA_BLADE display_health(); if(damage_received) { display_blade_lights(_LIGHT_MODE_DAMAGE_RECEIVED); damage_received = 0; } if( determine_sword_was_swung() && ( ( health > 0) || determine_omega_mode_active() ) ) { if(!determine_omega_mode_active()) { display_blade_lights(_LIGHT_MODE_INDIVIDUAL_SWING); } else { display_blade_lights(_LIGHT_MODE_OMEGA_SWING); } determine_packets_to_send(&pkt_arr); for(i = 3; i > 0; --i) { if(pkt_arr[i-1] > 0) { GIE = 0; output_ir(i-1, pkt_arr[i-1]); GIE = 1; } } } GIE = 0; while( ( stun_counter > 0 ) && !determine_omega_mode_active() ) { GIE = 1; //****************Turn full blue //Green to 0% PSMC2DCH = 0xFF;//PSMC2 Duty Cycle High-byte PSMC2DCL = 0xFF;//PSMC2 Duty Cycle Low-byte PSMC2LD = 1; //PSMC 2 Load //Blue to 0% PSMC3DCH = 0x00;//PSMC3 Duty Cycle High-byte PSMC3DCL = 0x00;//PSMC3 Duty Cycle Low-byte PSMC3LD = 1; //PSMC 3 Load //Red to 100% PSMC4DCH = 0xFF;//PSMC4 Duty Cycle High-byte PSMC4DCL = 0x00;//PSMC4 Duty Cycle Low-byte PSMC4LD = 1; //PSMC 4 Load //Set Load Bit to load duty cycle values PSMC2LD = 1; //PSMC 2 Load PSMC3LD = 1; //PSMC 3 Load PSMC4LD = 1; //PSMC 4 Load __delay_ms(50); //****************Turn off //Green to 0% PSMC2DCH = 0x00;//PSMC2 Duty Cycle High-byte PSMC2DCL = 0x00;//PSMC2 Duty Cycle Low-byte PSMC2LD = 1; //PSMC 2 Load //Blue to 0% PSMC3DCH = 0x00;//PSMC3 Duty Cycle High-byte PSMC3DCL = 0x00;//PSMC3 Duty Cycle Low-byte PSMC3LD = 1; //PSMC 3 Load //Red to 0% PSMC4DCH = 0x00;//PSMC4 Duty Cycle High-byte PSMC4DCL = 0x00;//PSMC4 Duty Cycle Low-byte PSMC4LD = 1; //PSMC 4 Load //Set Load Bit to load duty cycle values PSMC2LD = 1; //PSMC 2 Load PSMC3LD = 1; //PSMC 3 Load PSMC4LD = 1; //PSMC 4 Load __delay_ms(50); GIE = 0; --stun_counter; } GIE = 1; #elif _GAMMA_BLADE display_health(); if(damage_received) { display_blade_lights(_LIGHT_MODE_DAMAGE_RECEIVED); damage_received = 0; } if( determine_sword_was_swung() && ( ( health > 0) || determine_omega_mode_active() ) ) { if(!determine_omega_mode_active()) { display_blade_lights(_LIGHT_MODE_INDIVIDUAL_SWING); determine_packets_to_send(&pkt_arr); for(i = 3; i > 0; --i) { if(pkt_arr[i-1] > 0) { GIE = 0; output_ir(i-1, pkt_arr[i-1]); GIE = 1; } } } else { display_blade_lights(_LIGHT_MODE_OMEGA_SWING); } } GIE = 0; while( ( stun_counter > 0 ) && !determine_omega_mode_active() ) { GIE = 1; //****************Turn full blue //Green to 0% PSMC2DCH = 0xFF;//PSMC2 Duty Cycle High-byte PSMC2DCL = 0xFF;//PSMC2 Duty Cycle Low-byte PSMC2LD = 1; //PSMC 2 Load //Blue to 0% PSMC3DCH = 0x00;//PSMC3 Duty Cycle High-byte PSMC3DCL = 0x00;//PSMC3 Duty Cycle Low-byte PSMC3LD = 1; //PSMC 3 Load //Red to 100% PSMC4DCH = 0xFF;//PSMC4 Duty Cycle High-byte PSMC4DCL = 0x00;//PSMC4 Duty Cycle Low-byte PSMC4LD = 1; //PSMC 4 Load //Set Load Bit to load duty cycle values PSMC2LD = 1; //PSMC 2 Load PSMC3LD = 1; //PSMC 3 Load PSMC4LD = 1; //PSMC 4 Load __delay_ms(50); //****************Turn off //Green to 0% PSMC2DCH = 0x00;//PSMC2 Duty Cycle High-byte PSMC2DCL = 0x00;//PSMC2 Duty Cycle Low-byte PSMC2LD = 1; //PSMC 2 Load //Blue to 0% PSMC3DCH = 0x00;//PSMC3 Duty Cycle High-byte PSMC3DCL = 0x00;//PSMC3 Duty Cycle Low-byte PSMC3LD = 1; //PSMC 3 Load //Red to 0% PSMC4DCH = 0x00;//PSMC4 Duty Cycle High-byte PSMC4DCL = 0x00;//PSMC4 Duty Cycle Low-byte PSMC4LD = 1; //PSMC 4 Load //Set Load Bit to load duty cycle values PSMC2LD = 1; //PSMC 2 Load PSMC3LD = 1; //PSMC 3 Load PSMC4LD = 1; //PSMC 4 Load __delay_ms(50); GIE = 0; --stun_counter; } GIE = 1; #endif } }