static void real_main2 (int argc, char **argv) { #if defined (NATMEM_OFFSET) && defined( _WIN32 ) && !defined( NO_WIN32_EXCEPTION_HANDLER ) extern int EvalException ( LPEXCEPTION_POINTERS blah, int n_except ); __try #endif { if (! graphics_setup ()) { exit (1); } if (restart_config[0]) { #ifdef FILESYS free_mountinfo (currprefs.mountinfo); currprefs.mountinfo = alloc_mountinfo (); #endif default_prefs (&currprefs, 0); fix_options (); } #ifdef NATMEM_OFFSET init_shm (); #endif #ifdef FILESYS rtarea_init (); hardfile_install (); #endif if (restart_config[0]) parse_cmdline_and_init_file (argc, argv); else currprefs = changed_prefs; uae_inithrtimer (); sleep_test (); machdep_init (); if (! setup_sound ()) { write_log ("Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } inputdevice_init (); changed_prefs = currprefs; no_gui = ! currprefs.start_gui; if (restart_program == 2) no_gui = 1; else if (restart_program == 3) no_gui = 0; if (! no_gui) { int err = gui_init (); struct uaedev_mount_info *mi = currprefs.mountinfo; currprefs = changed_prefs; currprefs.mountinfo = mi; if (err == -1) { write_log ("Failed to initialize the GUI\n"); if (restart_program == 3) { restart_program = 0; return; } } else if (err == -2) { restart_program = 0; return; } } restart_program = 0; #ifdef JIT if (!(( currprefs.cpu_level >= 2 ) && ( currprefs.address_space_24 == 0 ) && ( currprefs.cachesize ))) canbang = 0; #endif #ifdef _WIN32 logging_init(); /* Yes, we call this twice - the first case handles when the user has loaded a config using the cmd-line. This case handles loads through the GUI. */ #endif fix_options (); changed_prefs = currprefs; #ifdef SAVESTATE savestate_init (); #endif #ifdef SCSIEMU scsidev_install (); #endif #ifdef AUTOCONFIG /* Install resident module to get 8MB chipmem, if requested */ rtarea_setup (); #endif keybuf_init (); /* Must come after init_joystick */ #ifdef AUTOCONFIG expansion_init (); #endif memory_init (); memory_reset (); #ifdef FILESYS filesys_install (); #endif #ifdef AUTOCONFIG bsdlib_install (); emulib_install (); uaeexe_install (); native2amiga_install (); #endif if (custom_init ()) { /* Must come after memory_init */ #ifdef SERIAL_PORT serial_init (); #endif DISK_init (); reset_frame_rate_hack (); init_m68k(); /* must come after reset_frame_rate_hack (); */ gui_update (); if (graphics_init ()) { #ifdef DEBUGGER setup_brkhandler (); if (currprefs.start_debugger && debuggable ()) activate_debugger (); #endif #ifdef WIN32 #ifdef FILESYS filesys_init (); /* New function, to do 'add_filesys_unit()' calls at start-up */ #endif #endif if (sound_available && currprefs.produce_sound > 1 && ! init_audio ()) { write_log ("Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } start_program (); } } } #if defined (NATMEM_OFFSET) && defined( _WIN32 ) && !defined( NO_WIN32_EXCEPTION_HANDLER ) __except( EvalException( GetExceptionInformation(), GetExceptionCode() ) ) { // EvalException does the good stuff... } #endif }
/* * Initialization of emulator proper */ static int do_init_machine (void) { #ifdef JIT if (!(( currprefs.cpu_level >= 2 ) && ( currprefs.address_space_24 == 0 ) && ( currprefs.cachesize ))) canbang = 0; #endif #ifdef _WIN32 logging_init(); /* Yes, we call this twice - the first case handles when the user has loaded a config using the cmd-line. This case handles loads through the GUI. */ #endif #ifdef SAVESTATE savestate_init (); #endif #ifdef SCSIEMU scsidev_install (); #endif #ifdef AUTOCONFIG /* Install resident module to get 8MB chipmem, if requested */ rtarea_setup (); #endif keybuf_init (); /* Must come after init_joystick */ #ifdef AUTOCONFIG expansion_init (); #endif memory_init (); memory_reset (); #ifdef FILESYS filesys_install (); #endif #ifdef AUTOCONFIG bsdlib_install (); emulib_install (); uaeexe_install (); native2amiga_install (); #endif if (custom_init ()) { /* Must come after memory_init */ #ifdef SERIAL_PORT serial_init (); #endif DISK_init (); reset_frame_rate_hack (); init_m68k(); /* must come after reset_frame_rate_hack (); */ gui_update (); if (graphics_init ()) { #ifdef DEBUGGER setup_brkhandler (); if (currprefs.start_debugger && debuggable ()) activate_debugger (); #endif #ifdef WIN32 #ifdef FILESYS filesys_init (); /* New function, to do 'add_filesys_unit()' calls at start-up */ #endif #endif if (sound_available && currprefs.produce_sound > 1 && ! audio_init ()) { write_log ("Sound driver unavailable: Sound output disabled\n"); currprefs.produce_sound = 0; } return 1; } } return 0; }
/* Check if MAGIC is valid and print the Multiboot information structure pointed by ADDR. */ void entry (unsigned long magic, unsigned long addr) { uint32_t fileptr;// start of file system multiboot_info_t *mbi; /* Initialize the screen. */ terminal_open(); /* Am I booted by a Multiboot-compliant boot loader? */ if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { printf ("Invalid magic number: 0x%#x\n", (unsigned) magic); return; } /* Set MBI to the address of the Multiboot information structure. */ mbi = (multiboot_info_t *) addr; /* Print out the flags. */ printf ("flags = 0x%#x\n", (unsigned) mbi->flags); /* Are mem_* valid? */ if (CHECK_FLAG (mbi->flags, 0)) printf ("mem_lower = %uKB, mem_upper = %uKB\n", (unsigned) mbi->mem_lower, (unsigned) mbi->mem_upper); /* Is boot_device valid? */ if (CHECK_FLAG (mbi->flags, 1)) printf ("boot_device = 0x%#x\n", (unsigned) mbi->boot_device); /* Is the command line passed? */ if (CHECK_FLAG (mbi->flags, 2)) printf ("cmdline = %s\n", (char *) mbi->cmdline); if (CHECK_FLAG (mbi->flags, 3)) { int mod_count = 0; int i; module_t* mod = (module_t*)mbi->mods_addr; fileptr = mod->mod_start; while(mod_count < mbi->mods_count) { printf("Module %d loaded at address: 0x%#x\n", mod_count, (unsigned int)mod->mod_start); printf("Module %d ends at address: 0x%#x\n", mod_count, (unsigned int)mod->mod_end); printf("First few bytes of module:\n"); for(i = 0; i<16; i++) { printf("0x%x ", *((char*)(mod->mod_start+i))); } printf("\n"); mod_count++; } } /* Bits 4 and 5 are mutually exclusive! */ if (CHECK_FLAG (mbi->flags, 4) && CHECK_FLAG (mbi->flags, 5)) { printf ("Both bits 4 and 5 are set.\n"); return; } /* Is the section header table of ELF valid? */ if (CHECK_FLAG (mbi->flags, 5)) { elf_section_header_table_t *elf_sec = &(mbi->elf_sec); printf ("elf_sec: num = %u, size = 0x%#x," " addr = 0x%#x, shndx = 0x%#x\n", (unsigned) elf_sec->num, (unsigned) elf_sec->size, (unsigned) elf_sec->addr, (unsigned) elf_sec->shndx); } /* Are mmap_* valid? */ if (CHECK_FLAG (mbi->flags, 6)) { memory_map_t *mmap; printf ("mmap_addr = 0x%#x, mmap_length = 0x%x\n", (unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length); for (mmap = (memory_map_t *) mbi->mmap_addr; (unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length; mmap = (memory_map_t *) ((unsigned long) mmap + mmap->size + sizeof (mmap->size))) printf (" size = 0x%x, base_addr = 0x%#x%#x\n" " type = 0x%x, length = 0x%#x%#x\n", (unsigned) mmap->size, (unsigned) mmap->base_addr_high, (unsigned) mmap->base_addr_low, (unsigned) mmap->type, (unsigned) mmap->length_high, (unsigned) mmap->length_low); } /* Construct an LDT entry in the GDT */ { seg_desc_t the_ldt_desc; the_ldt_desc.granularity = 0; the_ldt_desc.opsize = 1; the_ldt_desc.reserved = 0; the_ldt_desc.avail = 0; the_ldt_desc.present = 1; the_ldt_desc.dpl = 0x0; the_ldt_desc.sys = 0; the_ldt_desc.type = 0x2; SET_LDT_PARAMS(the_ldt_desc, &ldt, ldt_size); ldt_desc_ptr = the_ldt_desc; lldt(KERNEL_LDT); } /* Construct a TSS entry in the GDT */ { seg_desc_t the_tss_desc; the_tss_desc.granularity = 0; the_tss_desc.opsize = 0; the_tss_desc.reserved = 0; the_tss_desc.avail = 0; the_tss_desc.seg_lim_19_16 = TSS_SIZE & 0x000F0000; the_tss_desc.present = 1; the_tss_desc.dpl = 0x0; the_tss_desc.sys = 0; the_tss_desc.type = 0x9; the_tss_desc.seg_lim_15_00 = TSS_SIZE & 0x0000FFFF; SET_TSS_PARAMS(the_tss_desc, &tss, tss_size); tss_desc_ptr = the_tss_desc; tss.ldt_segment_selector = KERNEL_LDT; tss.ss0 = KERNEL_DS; tss.esp0 = 0x800000; ltr(KERNEL_TSS); } /* Mask all IRQs again*/ int j; for(j=0;j<16;j++) { disable_irq(j); } /* Init the PIC */ i8259_init(); /* Init IDT vector 0-20*/ { int i; for(i=0;i<20;i++) { if(i!=15) { //Define an idt_desc_t structure idt_desc_t idt_desc; //populate w/ correct values idt_desc.seg_selector=0x0010; idt_desc.present=1; idt_desc.size=1; idt_desc.dpl=0x0; idt_desc.reserved1=1; idt_desc.reserved2=1; idt_desc.reserved3=1; SET_IDT_ENTRY(idt_desc, ehandlers[i]); //Set new entry in table idt[i]=idt_desc; } } } /* Init IRQ Interrupts*/ //Timer Chip { //Define an idt_desc_t structure idt_desc_t idt_desc; //populate w/ correct values idt_desc.seg_selector=0x0010; idt_desc.present=1; idt_desc.size=1; idt_desc.dpl=0x0; idt_desc.reserved1=1; idt_desc.reserved2=1; SET_IDT_ENTRY(idt_desc, irqhandlers[0]); //Set new entry in table idt[32]=idt_desc; //Disable IRQ masking //enable_irq(0); } //Keyboard { //Define an idt_desc_t structure idt_desc_t idt_desc; //populate w/ correct values idt_desc.seg_selector=0x0010; idt_desc.present=1; idt_desc.size=1; idt_desc.dpl=0x0; idt_desc.reserved1=1; idt_desc.reserved2=1; SET_IDT_ENTRY(idt_desc, irqhandlers[1]); //Set new entry in table idt[33]=idt_desc; //Disable IRQ masking //enable_irq(1); } //Real Time Clock { //Define an idt_desc_t structure idt_desc_t idt_desc; //populate w/ correct values idt_desc.seg_selector=0x0010; idt_desc.present=1; idt_desc.size=1; idt_desc.dpl=0x0; idt_desc.reserved1=1; idt_desc.reserved2=1; SET_IDT_ENTRY(idt_desc, irqhandlers[2]); //Set new entry in table idt[40]=idt_desc; //Disable IRQ masking //enable_irq(8); } /* Init System Call 0x80 */ //Define an idt_desc_t structure idt_desc_t idt_desc; //populate w/ correct values idt_desc.seg_selector=0x0010; idt_desc.present=1; idt_desc.size=1; idt_desc.dpl=0x0; idt_desc.reserved1=1; idt_desc.reserved2=1; SET_IDT_ENTRY(idt_desc, systemcall); //Set new entry in table idt[128]=idt_desc; //Load new IDT lidt(idt_desc_ptr); /* Initialize devices, memory, filesystem, enable device interrupts on the * PIC, any other initialization stuff... */ paging_init(); //Enable IRQ interrupts. enable_irq(8); enable_irq(2); enable_irq(1); /* Enable interrupts */ /* Do not enable the following until after you have set up your * IDT correctly otherwise QEMU will triple fault and simple close * without showing you any output */ printf("Enabling Interrupts\n"); sti(); /* This will be replaced by a system call after CP3 */ rtc_open(); filesys_init(fileptr); // start of filesystem while(1) { printf("Reading-> "); uint8_t buf[1024]; int cnt = terminal_read(buf, 1024); buf[cnt] = '\0'; puts ((int8_t*)"Typed: "); puts ((int8_t*)buf); putc('\n'); } /* Execute the first program (`shell') ... */ /* Spin (nicely, so we don't chew up cycles) */ asm volatile(".1: hlt; jmp .1;"); }
/* Check if MAGIC is valid and print the Multiboot information structure pointed by ADDR. */ void entry(unsigned long magic, unsigned long addr) { multiboot_info_t *mbi; uint32_t filesys_start_addr; /* Clear the screen. */ vga_text_clear(); /* Am I booted by a Multiboot-compliant boot loader? */ if(magic != MULTIBOOT_BOOTLOADER_MAGIC) { printf("Invalid magic number: 0x%#x\n", (unsigned)magic); return; } /* Set MBI to the address of the Multiboot information structure. */ mbi = (multiboot_info_t *)addr; /* Print out the flags. */ printf("flags = 0x%#x\n", (unsigned)mbi->flags); /* Are mem_* valid? */ if(CHECK_FLAG(mbi->flags, 0)) printf("mem_lower = %uKB, mem_upper = %uKB\n", (unsigned)mbi->mem_lower, (unsigned)mbi->mem_upper); /* Is boot_device valid? */ if(CHECK_FLAG(mbi->flags, 1)) printf("boot_device = 0x%#x\n", (unsigned)mbi->boot_device); /* Is the command line passed? */ if(CHECK_FLAG(mbi->flags, 2)) printf("cmdline = %s\n", (char *)mbi->cmdline); if(CHECK_FLAG(mbi->flags, 3)) { int mod_count = 0; int i; module_t* mod = (module_t*)mbi->mods_addr; filesys_start_addr = (uint32_t)mod->mod_start; while(mod_count < mbi->mods_count) { printf("Module %d loaded at address: 0x%#x\n", mod_count, (unsigned int)mod->mod_start); printf("Module %d ends at address: 0x%#x\n", mod_count, (unsigned int)mod->mod_end); printf("First few bytes of module:\n"); for(i = 0; i < 16; i++) { printf("0x%x ", *((char*)(mod->mod_start+i))); } printf("\n"); mod_count++; } } /* Bits 4 and 5 are mutually exclusive! */ if(CHECK_FLAG(mbi->flags, 4) && CHECK_FLAG(mbi->flags, 5)) { printf("Both bits 4 and 5 are set.\n"); return; } /* Is the section header table of ELF valid? */ if(CHECK_FLAG(mbi->flags, 5)) { elf_section_header_table_t *elf_sec = &(mbi->elf_sec); printf("elf_sec: num = %u, size = 0x%#x," " addr = 0x%#x, shndx = 0x%#x\n", (unsigned)elf_sec->num, (unsigned)elf_sec->size, (unsigned)elf_sec->addr, (unsigned)elf_sec->shndx); } /* Are mmap_* valid? */ if(CHECK_FLAG(mbi->flags, 6)) { memory_map_t *mmap; printf("mmap_addr = 0x%#x, mmap_length = 0x%x\n", (unsigned)mbi->mmap_addr, (unsigned)mbi->mmap_length); for(mmap = (memory_map_t *)mbi->mmap_addr; (unsigned long)mmap < mbi->mmap_addr + mbi->mmap_length; mmap = (memory_map_t *)((unsigned long)mmap + mmap->size + sizeof(mmap->size))) printf(" size = 0x%x, base_addr = 0x%#x%#x\n" " type = 0x%x, length = 0x%#x%#x\n", (unsigned)mmap->size, (unsigned)mmap->base_addr_high, (unsigned)mmap->base_addr_low, (unsigned)mmap->type, (unsigned)mmap->length_high, (unsigned)mmap->length_low); } /* Construct an LDT entry in the GDT */ { seg_desc_t the_ldt_desc; the_ldt_desc.granularity = 0; the_ldt_desc.opsize = 1; the_ldt_desc.reserved = 0; the_ldt_desc.avail = 0; the_ldt_desc.present = 1; the_ldt_desc.dpl = 0x0; the_ldt_desc.sys = 0; the_ldt_desc.type = 0x2; SET_LDT_PARAMS(the_ldt_desc, &ldt, ldt_size); ldt_desc_ptr = the_ldt_desc; lldt(KERNEL_LDT); } /* Construct a TSS entry in the GDT */ { seg_desc_t the_tss_desc; the_tss_desc.granularity = 0; the_tss_desc.opsize = 0; the_tss_desc.reserved = 0; the_tss_desc.avail = 0; the_tss_desc.seg_lim_19_16 = TSS_SIZE & 0x000F0000; the_tss_desc.present = 1; the_tss_desc.dpl = 0x0; the_tss_desc.sys = 0; the_tss_desc.type = 0x9; the_tss_desc.seg_lim_15_00 = TSS_SIZE & 0x0000FFFF; SET_TSS_PARAMS(the_tss_desc, &tss, tss_size); tss_desc_ptr = the_tss_desc; tss.ldt_segment_selector = KERNEL_LDT; tss.ss0 = KERNEL_DS; tss.esp0 = 0x800000; ltr(KERNEL_TSS); } /* If kernel got to here, that means everything should be fine with the boot. * Now we should initialize IDT, PIC, Syscall, paging, devices, filesystem, * and any other initialization stuff... terminal_init() should be called at * the very end of the initializations (after sti). */ /* But first, let's clear the screen */ vga_text_clear(); /* Init the IDT */ idt_init(); /* Init the PIC */ i8259_init(); /* Init Syscall */ syscall_init(); /* Init Paging */ paging_init(); /* Init file system */ filesys_init(filesys_start_addr); /* Init the Keyboard */ keyboard_init(); /* Init the RTC */ rtc_init(); /* Enable interrupts */ sti(); /* booting screen in mode X */ start_up = 3; set_mode_x(); load_bmp((uint8_t*)"boot", LOAD_FLAG_BOOT); while(start_up == 3); set_text_mode(); /* Init the good looking terminal */ terminal_init(); /* wait for a key press to clear the start up screen */ while(start_up == 2); vga_text_clear(); welcome_and_credit(); while(start_up == 1); /* Init the status bar for that terminal */ terminal_stat_bar_init(); terminal_clear(); /* Init the PIT */ pit_init(); /* Execute the first program "shell" */ pid_now = 1; pid_running[0] = 1; root_shell_flag = 1; execute((uint8_t*)"shell"); /* Spin (nicely, so we don't chew up cycles) */ asm volatile(".1: hlt; jmp .1;"); }
int main(int argc, char *argv){ eeprom_recover(); filesys_init(); /* general file manipulation calls */ file_t * foo = file_open("output.csv", 'a'); file_write(foo, "hello world",11); file_write(foo, "heres some more stuff", 21); file_close(foo); foo = file_open("vim", 'w'); char buf[2048] = "Vim has some intelligence about what to do if the swap file is corrupt in some way. If Vim has doubt about what it found, it will give an error message and insert lines with ??? in the text. If you see an error message while recovering, search in the file for ??? to see what is wrong. You may want to cut and paste to get the text you need. The most common remark is ???LINES MISSING. This means that Vim cannot read the text from the original file. This can happen if the system crashed and parts of the original file were not written to disk. Be sure that the recovery was successful before overwriting the original file or deleting the swap file. It is good practice to write the recovered file elsewhere and run diff to find out if the changes you want are in the recovered file. Or use |:DiffOrig|. Once you are sure the recovery is ok delete the swap file. Otherwise, you will continue to get warning messages that the .swp file already exists. {Vi: recovers in another way and sends mail if there is something to recover}\0"; file_write(foo, buf, strlen(buf)); file_close(foo); printf("--------------------------------------\n"); foo = file_open("output.csv", 'w'); file_write(foo, "***************************************|", 40); file_close(foo); foo = file_open("another.test", 'w'); file_close(foo); foo = file_open("vim", 'a'); char wiki[1024] = "Using universal hashing (in a randomized algorithm or data structure) refers to selecting a hash function at random from a family of hash functions with a certain mathematical property (see definition below). This guarantees a low number of collisions in expectation, even if the data is chosen by an adversary. Many universal families are known (for hashing integers, vectors, strings), and their evaluation is often very efficient. Universal hashing has numerous uses in computer science, for example in implementations of hash tables, randomized algorithms, and cryptography."; file_write(foo, wiki, strlen(wiki)); file_close(foo); foo = file_open("lines.txt", 'a'); file_writeline(foo, "this is the first line", 22); file_write(foo, "some more stuff", 15); file_close(foo); foo = file_open("lines.txt", 'r'); char in[256]; file_readline(foo, in, 256); printf("|%s|", in); file_rewind(foo); memset(in, 0, 256); file_read(foo, in, 10); printf("|%s|", in); file_close(foo); eeprom_print(); //char buf[256] = "**********************************************************************************************************************************************************************************************************************************************************ABC|"; //file_write(foo, buf, strlen(buf)); /* foo = file_open("test.foo",'a'); file_print(foo); file_write(foo, "$$$",3); */ //eeprom_print(); /* foo = file_open("test.foo", 'r'); file_print(foo); char read[128]; int b = file_read(foo, read, 11); printf("%d %s\n", b, read); file_print(foo); eeprom_print(); memset(read, 0, 128); b = file_read(foo, read, 29); printf("%d %s\n", b, read); file_close(foo); */ /* write test: foo = file_open("test.foo", 'w'); file_print(foo); file_write(foo, buf, 256); file_print(foo); eeprom_print(); */ /*=== PAGE tests === page_t *page_1 = page_create(DATA_P); page_t *page_2 = page_create(DATA_P); page_t *page_3 = page_create(DATA_P); page_t *page_4 = page_create(DATA_P); char text[256]; memset(text, 0, 256); int16_t a; sprintf(text, "%s %d", "hello world", 1); a = page_write(page_1, 2, text, 100); printf("bytes written: %d\n", a); sprintf(text, "%s %d", "hello world", 2); a = page_write(page_2, 2, text, 100); printf("bytes written: %d\n", a); sprintf(text, "%s %d", "hello world", 3); a = page_write(page_3, 2, text, 100); printf("bytes written: %d\n", a); int i; for(i = 0; i < 256; ++i) text[i] = i % 0x80; a = page_write(page_4, 2, text, 256); printf("bytes written: %d\n", a); //eeprom_print(); memset(text, 0, 256); page_read(page_4, 5, text, 5); page_erase(page_4, 64, 32); page_write(page_4, 64, "this is erased data", 19); //will fail due to open pages pagesys_qwipe(); //eeprom_print(); printf("\n"); page_close(page_1); page_close(page_2); page_close(page_3); page_close(page_4); pagesys_qwipe(); //eeprom_print(); memset(text, 0, 256); page_1 = page_create(DATA_P); sprintf(text, "%s %d", "goodbye", 5); page_write(page_1, 2, text, 9); //eeprom_print(); page_close(page_1); //full wipe pagesys_wipe(); eeprom_print(); //printf("%s\n", text); */ /* === EEPROM tests === uint8_t x = 0xFF; printf("0x%X\n", x); int i = 0; for(; i < 8; ++i){ x &= (0xFF ^ (1 << i)) ; printf("0x%X\n", x); x = 0xFF; } */ /* char buf[256] = "hello world"; eeprom_write_page(0x0, buf, sizeof(buf)); sprintf(buf, "%s", "this is a test sentence. here are some numbers 100 20123 1i12 DFASDFADSf"); eeprom_write_page(0x100, buf, sizeof(buf)); //full aligned page write int i; for(i = 0; i < 256; ++i) buf[i] = i % 0x80; eeprom_write_page(0x300, buf, sizeof(buf)); //eeprom_erase_page(0x3f1); eeprom_write(0x290, buf, sizeof(buf)); eeprom_print(); eeprom_backup(); */ /* eeprom_read_page(0x0, buf, sizeof(buf)); memview(buf, sizeof(buf)); eeprom_read_page(0x290, buf, sizeof(buf)); memview(buf, sizeof(buf)); eeprom_read_page(0x300, buf, sizeof(buf)); memview(buf, sizeof(buf)); //eeprom_erase(0x300, 129); eeprom_wipe(); eeprom_write(0x000, "A", 1); eeprom_write(0x100, "B", 1); eeprom_write(0x200, "C", 1); eeprom_write(0x300, "D", 1); eeprom_print(); //eeprom_wipe(); */ }
void _cdecl main (SHORT argc, char *argv[]) { // bool ok = FALSE; // char test[5]; // test for trap 05 errors ULONG ulTimes; // need for Trap Ctrl-Break Signal #ifdef TESTING if(!dout) { DosBeep(500,300); } if(!memout) { DosBeep(1000,300); } #endif #ifdef ERR_HAND rc = set_int24(); if(rc != 0) { err_exit("Error initializing error handler", 3); } MYEXCEPTIONREGISTRATIONRECORD myExceptionRegRecord; myExceptionRegRecord.prev_structure = NULL; myExceptionRegRecord.ExceptionHandler = MyExceptionHandler; DosSetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord); DosSetSignalExceptionFocus(SIG_SETFOCUS, &ulTimes); if(setjmp(myExceptionRegRecord.env)) goto OnException; #endif DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl); filesys_init(); get_current_directory(cwd); // init cur dir Mem::vmem_setup(); strcpy(exe_dir, *argv); // assume loaded via X:\subdir\KED.EXE DBG_FILE(dout << "EXE_DIR = " << exe_dir <<endl); DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl); assure_windows_ready(); if(!thread_init()) { err_exit("Error creating initial threads", 5); } process_env_string ("EDITOR"); /* do parameters from environment string */ strcpy (progname,*argv); argc--; /* don't count program name */ argv++; while (argc--) { /* process each parameter */ process_arg (*argv); argv++; } if (!*settings.help_path) { /* help is usually in same dir as program */ delta_filename (settings.help_path, progname, "*.HLP"); } //#ifdef TESTING //if(!debug_on) { // dout.close(); // memout.close(); //} //#endif assure_1_view(); DBG_INI(dout<<"edit.cpp line "<<__LINE__<<" shell_command.s = °"<<settings.shell_command.s<<"°"<<endl); DBG_INI(dout<<"file "<<__FILE__<<" line "<<__LINE__<<" settings.numlock_on = "<<settings.numlock_on<<endl); // ok = load_keys(); // Version 2.08 // if(!ok) // err_exit("Failed to load Keyboard driver", 10); edit_loop(); // test[5000] = 'A'; // test trap array bounds goto Ked_Exit; OnException: #ifdef ERR_HAND DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord); // Screen.term_mess = "application trapped"; err_exit(" application trapped", 20); #endif Ked_Exit: #ifdef ERR_HAND if(ORG_NUMLOCK) { DBG_NUML(dout<<" exit - setting NUMLOCK on"<<endl); numlock_set(TRUE); } else { DBG_NUML(dout<<" exit - setting NUMLOCK off"<<endl); numlock_set(FALSE); } DosUnsetExceptionHandler((PEXCEPTIONREGISTRATIONRECORD) &myExceptionRegRecord); #endif DBG_MEM(memout<< " main after except setup "<< checkmem2 << endl); DBG_BUGS(dout<<'\n'<<" Normal Closedown in LOGFILE "<<endl); }