diff --git a/core/core_api.c b/core/core_api.c index deb538d..abaf860 100644 --- a/core/core_api.c +++ b/core/core_api.c @@ -583,7 +583,7 @@ uint32_t shoebill_install_tfb_card(shoebill_config_t *config, uint8_t slotnum) return 1; } -uint32_t shoebill_install_ethernet_card(shoebill_config_t *config, uint8_t slotnum, uint8_t ethernet_addr[6]) +uint32_t shoebill_install_ethernet_card(shoebill_config_t *config, uint8_t slotnum, uint8_t ethernet_addr[6], int tap_fd) { shoebill_card_ethernet_t *ctx; @@ -601,7 +601,7 @@ uint32_t shoebill_install_ethernet_card(shoebill_config_t *config, uint8_t slotn shoe.slots[slotnum].write_func = nubus_ethernet_write_func; shoe.slots[slotnum].destroy_func = nubus_ethernet_destroy_func; shoe.slots[slotnum].interrupts_enabled = 1; - nubus_ethernet_init(ctx, slotnum, ethernet_addr); + nubus_ethernet_init(ctx, slotnum, ethernet_addr, tap_fd); return 1; } diff --git a/core/cpu.c b/core/cpu.c index ef17dd7..b6f2621 100644 --- a/core/cpu.c +++ b/core/cpu.c @@ -1162,7 +1162,7 @@ static void inst_cmpm (void) { const uint8_t sz = 1 << s; const uint32_t source_addr = shoe.a[y]; - // Usual rules apply for byte-size if x or y is a7 ( + // Usual rules apply for byte-size if x or y is a7 const uint32_t post_source_addr = source_addr + sz + (y == 7 && sz == 1); const uint32_t dest_addr = (x == y) ? post_source_addr : shoe.a[x]; // The increments are cumulative if x==y @@ -2954,7 +2954,7 @@ static void inst_bchg_reg (void) { } static void inst_bclr_reg (void) { - ~decompose(shoe.op, 0000 rrr 111 MMMMMM); + ~decompose(shoe.op, 0000 rrr 110 MMMMMM); const uint8_t is_data_reg = (M>>3) == 0; const uint8_t sz = is_data_reg ? 4 : 1; @@ -3283,7 +3283,8 @@ static void inst_trap (void) { return ; fail: - assert(!"trap - push_a7 raised shoe.abort\n"); // FIXME + return ; + // assert(!"trap - push_a7 raised shoe.abort\n"); // FIXME } diff --git a/core/ethernet.c b/core/ethernet.c index ec6855e..7d1619f 100644 --- a/core/ethernet.c +++ b/core/ethernet.c @@ -459,7 +459,7 @@ void *_ethernet_sender_thread(void *arg) return NULL; } -void nubus_ethernet_init(void *_ctx, uint8_t slotnum, uint8_t ethernet_addr[6]) +void nubus_ethernet_init(void *_ctx, uint8_t slotnum, uint8_t ethernet_addr[6], int tap_fd) { shoebill_card_ethernet_t *ctx = (shoebill_card_ethernet_t*)_ctx; memset(ctx, 0, sizeof(shoebill_card_ethernet_t)); @@ -489,8 +489,7 @@ void nubus_ethernet_init(void *_ctx, uint8_t slotnum, uint8_t ethernet_addr[6]) ctx->isr |= isr_rst; // I presume ISR's RST powers up high too /* Platform-specific tap code */ - ctx->tap_fd = open("/dev/tap0", O_RDWR); - assert(ctx->tap_fd >= 0); + ctx->tap_fd = tap_fd; } void nubus_ethernet_destroy_func(uint8_t slotnum) diff --git a/core/fpu.c b/core/fpu.c index b036265..d83af67 100644 --- a/core/fpu.c +++ b/core/fpu.c @@ -240,7 +240,8 @@ static _Bool _bsun_test() static void _throw_illegal_instruction() { - assert(!"throw_illegal_instruction!"); + // assert(!"throw_illegal_instruction!"); + throw_illegal_instruction(); } #pragma mark Float format translators (to/from big-endian motorola format) @@ -2756,7 +2757,7 @@ computation_done: #pragma mark Second-hop non-fmath instructions /* - * reg->mem fmove (fmath handles all other fmoves + * reg->mem fmove (fmath handles all other fmoves) */ static void inst_fmove (const uint16_t ext) { diff --git a/core/shoebill.h b/core/shoebill.h index eb000a5..2b466f0 100644 --- a/core/shoebill.h +++ b/core/shoebill.h @@ -138,7 +138,7 @@ uint32_t shoebill_install_video_card(shoebill_config_t *config, uint8_t slotnum, uint32_t shoebill_install_tfb_card(shoebill_config_t *config, uint8_t slotnum); /* Call this after shoebill_initialize() to add an ethernet card */ -uint32_t shoebill_install_ethernet_card(shoebill_config_t *config, uint8_t slotnum, uint8_t ethernet_addr[6]); +uint32_t shoebill_install_ethernet_card(shoebill_config_t *config, uint8_t slotnum, uint8_t ethernet_addr[6], int tap_fd); /* Get a video frame from a particular video card */ shoebill_video_frame_info_t shoebill_get_video_frame(uint8_t slotnum, _Bool just_params); @@ -1081,7 +1081,7 @@ shoebill_video_frame_info_t nubus_video_get_frame(shoebill_card_video_t *ctx, _Bool just_params); // Apple EtherTalk -void nubus_ethernet_init(void *_ctx, uint8_t slotnum, uint8_t ethernet_addr[6]); +void nubus_ethernet_init(void *_ctx, uint8_t slotnum, uint8_t ethernet_addr[6], int tap_fd); uint32_t nubus_ethernet_read_func(uint32_t, uint32_t, uint8_t); void nubus_ethernet_write_func(uint32_t, uint32_t, uint32_t, uint8_t); void nubus_ethernet_destroy_func(uint8_t); diff --git a/debugger/Makefile b/debugger/Makefile index 367a99b..3662d89 100644 --- a/debugger/Makefile +++ b/debugger/Makefile @@ -1,6 +1,6 @@ CC = clang -CFLAGS = -O0 -ggdb -flto -Wno-deprecated-declarations +CFLAGS = -O3 -ggdb -flto -Wno-deprecated-declarations LFLAGS = -L ../intermediates -lshoebill_core -framework GLUT -framework OpenGL -ledit all: debugger diff --git a/debugger/debugger.c b/debugger/debugger.c index 5c1ac99..42d8b58 100644 --- a/debugger/debugger.c +++ b/debugger/debugger.c @@ -42,6 +42,7 @@ struct dbg_state_t { uint64_t breakpoint_counter; dbg_breakpoint_t *breakpoints; _Bool trace; + uint32_t slow_factor; char *ring; uint32_t ring_i, ring_len; @@ -394,6 +395,8 @@ void verb_continue_handler (const char *line) { dbg_state.running = 1; while (dbg_state.running) { + if (dbg_state.slow_factor) + usleep(dbg_state.slow_factor); stepper(); } print_pc(); @@ -412,6 +415,13 @@ void verb_reset_handler (const char *line) shoe.pool = NULL; } +void verb_slow_handler (const char *line) +{ + const uint64_t usecs = strtoul(line, NULL, 0); + printf("Slow factor %u -> %u\n", dbg_state.slow_factor, (uint32_t)usecs); + dbg_state.slow_factor = usecs; +} + struct verb_handler_table_t { const char *name; void (*func)(const char *); @@ -430,6 +440,7 @@ struct verb_handler_table_t { {"trace", verb_trace_toggle_handler}, {"x", verb_examine_handler}, {"reset", verb_reset_handler}, + {"slow", verb_slow_handler}, }; void execute_verb (const char *line) @@ -839,19 +850,21 @@ int main (int argc, char **argv) */ config.debug_mode = 1; - config.aux_verbose = 1; - config.ram_size = 32 * 1024 * 1024; + config.aux_verbose = 0; + config.ram_size = 16 * 1024 * 1024; config.aux_kernel_path = "/unix"; - config.rom_path = "../priv/macii.rom"; + config.rom_path = "../../../shoebill_priv/macii.rom"; - config.scsi_devices[0].path = "../priv/root3.img"; + config.scsi_devices[0].path = "../../../shoebill_priv/root3.img"; //config.scsi_devices[1].path = "../priv/marathon.img"; /*dbg_state.ring_len = 256 * 1024 * 1024; dbg_state.ring = malloc(dbg_state.ring_len); dbg_state.ring_i = 0;*/ + shoebill_validate_or_zap_pram(config.pram, 1); + if (!shoebill_initialize(&config)) { printf("%s\n", config.error_msg); return 0; diff --git a/gui/Shoebill/Shoebill-Info.plist b/gui/Shoebill/Shoebill-Info.plist index 7d161eb..3b6c97e 100644 --- a/gui/Shoebill/Shoebill-Info.plist +++ b/gui/Shoebill/Shoebill-Info.plist @@ -3,7 +3,7 @@ NSHumanReadableCopyright - Copyright © 2013-2014 Peter Rutenbar + Copyright © 2013-2015 Peter Rutenbar CFBundleDevelopmentRegion en CFBundleExecutable @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.0.4 + 0.0.5 CFBundleSignature ???? CFBundleVersion - 0.0.4 + 0.0.5 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSMainNibFile diff --git a/gui/Shoebill/shoeAppDelegate.m b/gui/Shoebill/shoeAppDelegate.m index 602a1f2..3da42e9 100644 --- a/gui/Shoebill/shoeAppDelegate.m +++ b/gui/Shoebill/shoeAppDelegate.m @@ -25,6 +25,7 @@ #import "shoeAppDelegate.h" #import "shoeApplication.h" +#import "shoePreferencesWindowController.h" @implementation shoeAppDelegate @@ -39,8 +40,8 @@ [defaults setInteger:NSOnState forKey:@"verboseState"]; [defaults setInteger:16 forKey:@"memorySize"]; - [defaults setInteger:640 forKey:@"screenWidth"]; - [defaults setInteger:480 forKey:@"screenHeight"]; + // [defaults setInteger:640 forKey:@"screenWidth"]; + // [defaults setInteger:480 forKey:@"screenHeight"]; for (i=0; i<7; i++) [defaults setObject:@"" forKey:[NSString stringWithFormat:@"scsiPath%u", i]]; @@ -50,6 +51,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + uint32_t i; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; BOOL isInitialized = [defaults boolForKey:@"defaultsInitialized"]; @@ -57,13 +59,33 @@ if (!isInitialized) [self createFirstTimeUserDefaults]; - // Going from 0.0.1 to 0.0.2 leaves rootKernelPath uninitialized + // < 0.0.2 leaves rootKernelPath uninitialized if ([defaults objectForKey:@"rootKernelPath"] == nil) [defaults setObject:@"/unix" forKey:@"rootKernelPath"]; - // 0.0.1-2 leave pramData uninitialized + // < 0.0.3 leaves pramData uninitialized if ([defaults objectForKey:@"pramData"] == nil) [((shoeApplication*)NSApp) zapPram:defaults ptr:nil]; + + // < 0.0.5 leaves ethernet settings uninitialized + if ([defaults objectForKey:@"tapPathE"] == nil) { + uint8_t mac[6]; + generateMACAddr(mac); + [defaults setObject:[NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]] + forKey:@"macAddressE"]; + [defaults setObject:@"/dev/tap0" forKey:@"tapPathE"]; + [defaults setInteger:0 forKey:@"ethernetEnabledE"]; + + for (i=0; i<4; i++) { + [defaults setInteger:640 forKey:[NSString stringWithFormat:@"screenWidth%u", i]]; + [defaults setInteger:480 forKey:[NSString stringWithFormat:@"screenHeight%u", i]]; + [defaults setInteger:1 forKey:[NSString stringWithFormat:@"screenEnabled%u", i]]; + } + [defaults setInteger:1 forKey:@"screenEnabled0"]; + } + + [defaults synchronize]; } diff --git a/gui/Shoebill/shoeApplication.h b/gui/Shoebill/shoeApplication.h index 528f42e..5129cb8 100644 --- a/gui/Shoebill/shoeApplication.h +++ b/gui/Shoebill/shoeApplication.h @@ -46,6 +46,14 @@ struct shoe_app_pram_data_t BOOL doCaptureMouse, doCaptureKeys; BOOL isRunning; shoebill_config_t config; + + char *tapPath; + uint8_t mac[6]; + int tap_fd; + BOOL ethEnabled, tap_fd_valid; + struct { + uint16_t height, width, enabled; + } screens[4]; } diff --git a/gui/Shoebill/shoeApplication.m b/gui/Shoebill/shoeApplication.m index 34d0ba6..ba38cde 100644 --- a/gui/Shoebill/shoeApplication.m +++ b/gui/Shoebill/shoeApplication.m @@ -26,6 +26,7 @@ #import "shoeApplication.h" #import "shoeScreenWindow.h" #import "shoeScreenWindowController.h" +#import "shoePreferencesWindowController.h" #include @implementation shoeApplication @@ -215,7 +216,7 @@ } -- (BOOL) fetchUserDefaults:(uint16_t*)height width:(uint16_t*)width +- (BOOL) fetchUserDefaults { uint32_t i; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; @@ -239,14 +240,22 @@ if ((memsize < 1) || (memsize > 1024)) memsize = 8; - NSInteger screenHeightValue = [defaults integerForKey:@"screenHeight"]; - NSInteger screenWidthValue = [defaults integerForKey:@"screenWidth"]; + for (i=0; i<4; i++) { + NSInteger height = [defaults integerForKey:[NSString stringWithFormat:@"screenHeight%u", i]]; + NSInteger width = [defaults integerForKey:[NSString stringWithFormat:@"screenWidth%u", i]]; + NSInteger enabled = [defaults integerForKey:[NSString stringWithFormat:@"screenEnabled%u", i]]; + - if ((screenHeightValue < 342) || (screenHeightValue > 0xffff)) - screenHeightValue = 480; - - if ((screenWidthValue < 512) || (screenWidthValue > 0xffff)) - screenWidthValue = 640; + if ((height < 342) || (height > 0xffff)) + height = 480; + + if ((width < 512) || (width > 0xffff)) + width = 640; + + screens[i].width = (uint16_t)width; + screens[i].height = (uint16_t)height; + screens[i].enabled = (uint16_t)enabled; + } for (i=0; i<7; i++) { @@ -277,8 +286,23 @@ if (memcmp(config.pram+0xc, "NuMc", 4) != 0) [self zapPram:defaults ptr:config.pram]; - *width = screenWidthValue; - *height = screenHeightValue; + NSString *defaultTapPath = [defaults objectForKey:@"tapPathE"]; + NSString *defaultMacAddr = [defaults objectForKey:@"macAddressE"]; + ethEnabled = [defaults integerForKey:@"ethernetEnabledE"]; + if (ethEnabled) { + if (tap_fd_valid && strcmp(tapPath, [defaultTapPath UTF8String]) != 0) { + close(tap_fd); + tap_fd_valid = 0; + } + if (tapPath) + free(tapPath); + tapPath = strdup([defaultTapPath UTF8String]); + if (!(parseMACAddr([defaultMacAddr UTF8String], mac))) { + [self complain:@"Bad MAC addr"]; + ethEnabled = 0; + return NO; + } + } return YES; } @@ -346,12 +370,12 @@ void pram_callback (void *param, const uint8_t addr, const uint8_t byte) if (isRunning) return; - uint16_t width, height; uint32_t i; bzero(&config, sizeof(shoebill_config_t)); - [self fetchUserDefaults:&height width:&width]; + if (![self fetchUserDefaults]) + return ; self->pram = calloc(1, sizeof(struct shoe_app_pram_data_t)); memcpy(self->pram, config.pram, 256); @@ -371,12 +395,33 @@ void pram_callback (void *param, const uint8_t addr, const uint8_t byte) return ; } - [self createScreenWindow:9 height:height width:width]; + for (i=0; i<4; i++) { + if (screens[i].enabled) + [self createScreenWindow:(9+i) height:screens[i].height width:screens[i].width]; + } - // If you feel the cravin' for TAP-based ethernet, uncomment these lines - // - // uint8_t ethernet_addr[6] = {0x00, 0x24, 0x7e, 0x14, 0xd7, 0xff}; - // shoebill_install_ethernet_card(&config, 13, ethernet_addr); + if (ethEnabled) { + if (!tap_fd_valid) { + tap_fd = open(tapPath, O_RDWR | O_NOFOLLOW); + if (tap_fd == -1) { + NSAlert *theAlert = [NSAlert + alertWithMessageText:nil + defaultButton:nil + alternateButton:nil + otherButton:nil + informativeTextWithFormat:@"Couldn't open tap device (errno = %d)", errno + ]; + [theAlert runModal]; + return ; + } + tap_fd_valid = 1; + } + if (!shoebill_install_ethernet_card(&config, 13, mac, tap_fd)) { + [self complain:[NSString stringWithFormat:@"%s", config.error_msg]]; + return ; + } + + } shoebill_start(); diff --git a/gui/Shoebill/shoePreferencesWindowController.h b/gui/Shoebill/shoePreferencesWindowController.h index 639b56a..299fa72 100644 --- a/gui/Shoebill/shoePreferencesWindowController.h +++ b/gui/Shoebill/shoePreferencesWindowController.h @@ -27,10 +27,17 @@ @interface shoePreferencesWindowController : NSWindowController { - IBOutlet __weak NSButton *apply, *cancel, *applyAndRun, *verbose; + IBOutlet __weak NSButton *apply, *cancel, *applyAndRun, *verbose, *ethernetEnabled; IBOutlet __weak NSTextField *kernelPath, *romPath, *memorySize; IBOutlet __weak NSTextField *scsiPath0, *scsiPath1, *scsiPath2, *scsiPath3, *scsiPath4, *scsiPath5, *scsiPath6; - IBOutlet __weak NSTextField *screenHeight, *screenWidth; + IBOutlet __weak NSTextField *macAddress, *tapPath; + + IBOutlet __weak NSTextField *screenHeight1, *screenWidth1; + IBOutlet __weak NSTextField *screenHeight2, *screenWidth2; + IBOutlet __weak NSTextField *screenHeight3, *screenWidth3; + IBOutlet __weak NSTextField *screenHeight4, *screenWidth4; + + IBOutlet __weak NSButton *enableScreen1, *enableScreen2, *enableScreen3, *enableScreen4; } @@ -40,3 +47,6 @@ - (IBAction)browsePressed:(id)sender; @end + +void generateMACAddr (uint8_t *mac); +_Bool parseMACAddr (const char *str, uint8_t *mac); \ No newline at end of file diff --git a/gui/Shoebill/shoePreferencesWindowController.m b/gui/Shoebill/shoePreferencesWindowController.m index 65c31de..d7dc244 100644 --- a/gui/Shoebill/shoePreferencesWindowController.m +++ b/gui/Shoebill/shoePreferencesWindowController.m @@ -25,6 +25,7 @@ #import "shoePreferencesWindowController.h" #import "shoeApplication.h" +#include @implementation shoePreferencesWindowController @@ -35,6 +36,14 @@ - (void)windowDidLoad { + uint32_t i; + NSTextField *screenWidths[4] = { + screenWidth1, screenWidth2, screenWidth3, screenWidth4}; + NSTextField *screenHeights[4] = { + screenHeight1, screenHeight2, screenHeight3, screenHeight4}; + NSButton *screenEnableds[4] = { + enableScreen1, enableScreen2, enableScreen3, enableScreen4}; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *rootKernelPathStr = [defaults objectForKey:@"rootKernelPath"]; @@ -71,21 +80,28 @@ if (scsiPath5Str) [scsiPath5 setStringValue:scsiPath5Str]; if (scsiPath6Str) [scsiPath6 setStringValue:scsiPath6Str]; - NSInteger screenHeightValue = [defaults integerForKey:@"screenHeight"]; - NSInteger screenWidthValue = [defaults integerForKey:@"screenWidth"]; - - if ((screenHeightValue < 342) || (screenHeightValue > 0xffff)) { - screenHeightValue = 480; - [defaults setInteger:screenHeightValue forKey:@"screenHeight"]; + for (i=0; i<4; i++) { + NSInteger height = [defaults integerForKey:[NSString stringWithFormat:@"screenHeight%u", i]]; + NSInteger width = [defaults integerForKey:[NSString stringWithFormat:@"screenWidth%u", i]]; + NSInteger enabled = [defaults integerForKey:[NSString stringWithFormat:@"screenEnabled%u", i]]; + + if ((height < 342) || (height > 0xffff)) + height = 480; + if ((width < 342) || (width > 0xffff)) + width = 640; + + [screenHeights[i] setStringValue:[NSString stringWithFormat:@"%u", (uint32_t)height]]; + [screenWidths[i] setStringValue:[NSString stringWithFormat:@"%u", (uint32_t)width]]; + [screenEnableds[i] setState:enabled]; } + + NSString *tapPathStr = [defaults objectForKey:@"tapPathE"]; + NSString *macAddressStr = [defaults objectForKey:@"macAddressE"]; + NSInteger ethernetEnabledState = [defaults integerForKey:@"ethernetEnabledE"]; - if ((screenWidthValue < 512) || (screenWidthValue > 0xffff)) { - screenWidthValue = 640; - [defaults setInteger:screenWidthValue forKey:@"screenWidth"]; - } - - [screenWidth setStringValue:[NSString stringWithFormat:@"%u", (uint32_t)screenWidthValue]]; - [screenHeight setStringValue:[NSString stringWithFormat:@"%u", (uint32_t)screenHeightValue]]; + [tapPath setStringValue:tapPathStr]; + [macAddress setStringValue:macAddressStr]; + [ethernetEnabled setIntegerValue:ethernetEnabledState]; [defaults synchronize]; } @@ -134,8 +150,27 @@ [field setStringValue: [url path]]; } +- (void) complain:(NSString*)str +{ + NSAlert *theAlert = [NSAlert + alertWithMessageText:nil + defaultButton:nil + alternateButton:nil + otherButton:nil + informativeTextWithFormat:@"%@", str + ]; + [theAlert runModal]; +} + - (IBAction)applyPressed:(id)sender { + uint32_t i; + NSTextField *screenWidths[4] = { + screenWidth1, screenWidth2, screenWidth3, screenWidth4}; + NSTextField *screenHeights[4] = { + screenHeight1, screenHeight2, screenHeight3, screenHeight4}; + NSButton *screenEnableds[4] = { + enableScreen1, enableScreen2, enableScreen3, enableScreen4}; NSString *rootKernelPathStr = [kernelPath stringValue]; NSString *romPathStr = [romPath stringValue]; @@ -150,11 +185,21 @@ NSString *scsiPath5Str = [scsiPath5 stringValue]; NSString *scsiPath6Str = [scsiPath6 stringValue]; - NSInteger screenHeightValue = [screenHeight integerValue]; - NSInteger screenWidthValue = [screenWidth integerValue]; + NSString *macAddressStr = [macAddress stringValue]; + NSString *tapPathStr = [tapPath stringValue]; + NSInteger ethernetEnabledState = [ethernetEnabled state]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + uint8_t mac[6]; + if (!parseMACAddr ([macAddressStr UTF8String], mac)) { + [self complain:@"Bad MAC address"]; + } + else { + [macAddress setStringValue:[NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]]]; + } + [defaults setObject:rootKernelPathStr forKey:@"rootKernelPath"]; [defaults setObject:romPathStr forKey:@"romPath"]; [defaults setInteger:verboseState forKey:@"verboseState"]; @@ -168,8 +213,24 @@ [defaults setObject:scsiPath5Str forKey:@"scsiPath5"]; [defaults setObject:scsiPath6Str forKey:@"scsiPath6"]; - [defaults setInteger:screenHeightValue forKey:@"screenHeight"]; - [defaults setInteger:screenWidthValue forKey:@"screenWidth"]; + for (i=0; i<4; i++) { + NSInteger height = [screenHeights[i] integerValue]; + NSInteger width = [screenWidths[i] integerValue]; + NSInteger enabled = [screenEnableds[i] state]; + + if ((height < 342) || (height > 0xffff)) + height = 480; + if ((width < 342) || (width > 0xffff)) + width = 640; + + [defaults setInteger:height forKey:[NSString stringWithFormat:@"screenHeight%u", i]]; + [defaults setInteger:width forKey:[NSString stringWithFormat:@"screenWidth%u", i]]; + [defaults setInteger:enabled forKey:[NSString stringWithFormat:@"screenEnabled%u", i]]; + } + + [defaults setObject:macAddressStr forKey:@"macAddressE"]; + [defaults setObject:tapPathStr forKey:@"tapPathE"]; + [defaults setInteger:ethernetEnabledState forKey:@"ethernetEnabledE"]; [defaults synchronize]; } @@ -192,5 +253,63 @@ [shoeApp zapPram:[NSUserDefaults standardUserDefaults] ptr:nil]; } +void generateMACAddr (uint8_t *mac) +{ + srandom((unsigned)(random() ^ time(NULL))); + + /* Generate a MAC address in the range of the original EtherTalk card */ + + mac[0] = 0x02; + mac[1] = 0x60; + mac[2] = 0x8c; + mac[3] = random() & 0x07; + mac[4] = random() & 0xff; + mac[5] = random() & 0xff; +} + +_Bool parseMACAddr (const char *str, uint8_t *mac) +{ + uint32_t i, nibbles = 0; + uint8_t allowed[256]; + + memset(allowed, 30, 256); + for (i=0; i<256; i++) + if (isspace(i)) + allowed[i] = 20; + allowed[':'] = 20; + allowed['-'] = 20; + for (i=0; i<10; i++) + allowed['0' + i] = i; + for (i=0; i<6; i++) { + allowed['a' + i] = 10 + i; + allowed['A' + i] = 10 + i; + } + + for (i=0; str[i]; i++) { + const uint8_t v = allowed[str[i]]; + + if (v == 30) + return 0; + else if (v == 20) + continue; + + if (nibbles >= 12) + return 0; + mac[nibbles/2] <<= 4; + mac[nibbles/2] |= v; + nibbles++; + } + return (nibbles == 12); +} + +-(IBAction)newMacAddrPressed:(id)sender +{ + uint8_t mac[6]; + + generateMACAddr(mac); + + [macAddress setStringValue:[NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]]]; +} @end diff --git a/gui/Shoebill/shoePreferencesWindowController.xib b/gui/Shoebill/shoePreferencesWindowController.xib index f4fbc7d..56b02da 100644 --- a/gui/Shoebill/shoePreferencesWindowController.xib +++ b/gui/Shoebill/shoePreferencesWindowController.xib @@ -1,17 +1,29 @@ - + - - + + + + + + + + - - + + + + + + + + @@ -19,34 +31,33 @@ + - + - + - - + - @@ -55,7 +66,6 @@ - @@ -75,7 +84,6 @@ - @@ -84,61 +92,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + The path to the kernel on the root image. If you don't know what this is, just use "/unix" (Note: the root image needs to be at SCSI ID 0) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -157,7 +335,6 @@ - @@ -166,7 +343,6 @@ - @@ -186,7 +361,6 @@ - @@ -195,7 +369,6 @@ - @@ -215,7 +387,6 @@ - @@ -224,7 +395,6 @@ - @@ -244,7 +413,6 @@ - @@ -253,7 +421,6 @@ - @@ -273,7 +439,6 @@ - @@ -282,7 +447,6 @@ - @@ -302,7 +465,6 @@ - @@ -311,7 +473,6 @@ - @@ -331,7 +491,6 @@ - @@ -340,7 +499,6 @@ - @@ -361,35 +518,56 @@ - - + + - - - - + + + - - - - The path to the kernel on the root image. If you don't know what this is, just use "/unix" (Note: the root image needs to be at SCSI ID 0) - + + + - +