Skip to content

Commit

Permalink
Preliminary support for ethernet/multiple screens in cocoa client
Browse files Browse the repository at this point in the history
  • Loading branch information
pruten committed Sep 13, 2015
1 parent 1ab8a6a commit 0322e55
Show file tree
Hide file tree
Showing 14 changed files with 527 additions and 134 deletions.
4 changes: 2 additions & 2 deletions core/core_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
7 changes: 4 additions & 3 deletions core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}


Expand Down
5 changes: 2 additions & 3 deletions core/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions core/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -2756,7 +2757,7 @@ static void inst_fmath (const uint16_t ext)
#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)
{
Expand Down
4 changes: 2 additions & 2 deletions core/shoebill.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion debugger/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 17 additions & 4 deletions debugger/debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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 *);
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions gui/Shoebill/Shoebill-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013-2014 Peter Rutenbar</string>
<string>Copyright © 2013-2015 Peter Rutenbar</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.4</string>
<string>0.0.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.0.4</string>
<string>0.0.5</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
Expand Down
30 changes: 26 additions & 4 deletions gui/Shoebill/shoeAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#import "shoeAppDelegate.h"
#import "shoeApplication.h"
#import "shoePreferencesWindowController.h"

@implementation shoeAppDelegate

Expand All @@ -39,8 +40,8 @@ - (void)createFirstTimeUserDefaults
[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]];
Expand All @@ -50,20 +51,41 @@ - (void)createFirstTimeUserDefaults

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
uint32_t i;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

BOOL isInitialized = [defaults boolForKey:@"defaultsInitialized"];

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];
}


Expand Down
8 changes: 8 additions & 0 deletions gui/Shoebill/shoeApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}


Expand Down
Loading

0 comments on commit 0322e55

Please sign in to comment.