Numerous CD-ROM fixes (and disc changes now work correctly in Windows 98 SE);

Slight reworking in the mouse and network code (ported from VARCem) in preparation for a major change that will const a lot of things to further reduce RAM usage.
This commit is contained in:
OBattler
2018-03-18 20:48:10 +01:00
parent 0cb43db290
commit b6c393cc91
11 changed files with 196 additions and 191 deletions

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like) * Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage. * commands, for both ATAPI and SCSI usage.
* *
* Version: @(#)cdrom.c 1.0.39 2018/03/17 * Version: @(#)cdrom.c 1.0.40 2018/03/18
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
@@ -128,7 +128,7 @@ uint8_t cdrom_command_flags[0x100] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
IMPLEMENTED | CHECK_READY, IMPLEMENTED | CHECK_READY,
IMPLEMENTED | CHECK_READY, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS IMPLEMENTED | CHECK_READY | ALLOW_UA, /* Read TOC - can get through UNIT_ATTENTION, per VIDE-CDD.SYS
NOTE: The ATAPI reference says otherwise, but I think this is a question of NOTE: The ATAPI reference says otherwise, but I think this is a question of
interpreting things right - the UNIT ATTENTION condition we have here interpreting things right - the UNIT ATTENTION condition we have here
is a tradition from not ready to ready, by definition the drive is a tradition from not ready to ready, by definition the drive
@@ -232,7 +232,7 @@ static const mode_sense_pages_t cdrom_mode_sense_pages_default =
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
{ GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } { GPMODE_CAPABILITIES_PAGE, 0x12, 0, 0, 1, 0, 0, 0, 0x02, 0xC2, 1, 0, 0, 0, 0x02, 0xC2, 0, 0, 0, 0 }
} }; } };
static const mode_sense_pages_t cdrom_mode_sense_pages_default_scsi = static const mode_sense_pages_t cdrom_mode_sense_pages_default_scsi =
@@ -279,7 +279,7 @@ static const mode_sense_pages_t cdrom_mode_sense_pages_default_scsi =
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
{ GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } { GPMODE_CAPABILITIES_PAGE, 0x12, 0, 0, 1, 0, 0, 0, 0x02, 0xC2, 1, 0, 0, 0, 0x02, 0xC2, 0, 0, 0, 0 }
} }; } };
static const mode_sense_pages_t cdrom_mode_sense_pages_changeable = static const mode_sense_pages_t cdrom_mode_sense_pages_changeable =
@@ -326,12 +326,13 @@ static const mode_sense_pages_t cdrom_mode_sense_pages_changeable =
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 },
{ GPMODE_CAPABILITIES_PAGE, 0x14, 0x3B, 0, 0x71, 0x60, 0x29, 0, 0x02, 0xC2, 0, 2, 0, 0, 0x02, 0xC2, 0, 0, 0, 0, 0, 0 } { GPMODE_CAPABILITIES_PAGE, 0x12, 0, 0, 1, 0, 0, 0, 0x02, 0xC2, 1, 0, 0, 0, 0x02, 0xC2, 0, 0, 0, 0 }
} }; } };
static mode_sense_pages_t cdrom_mode_sense_pages_saved[CDROM_NUM]; static mode_sense_pages_t cdrom_mode_sense_pages_saved[CDROM_NUM];
#define ENABLE_CDROM_LOG 1
#ifdef ENABLE_CDROM_LOG #ifdef ENABLE_CDROM_LOG
int cdrom_do_log = ENABLE_CDROM_LOG; int cdrom_do_log = ENABLE_CDROM_LOG;
#endif #endif
@@ -475,6 +476,7 @@ void cdrom_init(int id, int cdb_len_setting)
cdrom_sense_key = cdrom_asc = cdrom_ascq = dev->unit_attention = 0; cdrom_sense_key = cdrom_asc = cdrom_ascq = dev->unit_attention = 0;
dev->cdb_len_setting = 0; dev->cdb_len_setting = 0;
dev->cdb_len = 12; dev->cdb_len = 12;
dev->cur_speed = cdrom_drives[id].speed;
} }
int cdrom_supports_pio(int id) int cdrom_supports_pio(int id)
@@ -697,11 +699,23 @@ uint32_t cdrom_mode_sense(uint8_t id, uint8_t *buf, uint32_t pos, uint8_t type,
msplen = cdrom_mode_sense_read(id, page_control, i, 1); msplen = cdrom_mode_sense_read(id, page_control, i, 1);
buf[pos++] = msplen; buf[pos++] = msplen;
cdrom_log("CD-ROM %i: MODE SENSE: Page [%02X] length %i\n", id, i, msplen); cdrom_log("CD-ROM %i: MODE SENSE: Page [%02X] length %i\n", id, i, msplen);
for (j = 0; j < msplen; j++) for (j = 0; j < msplen; j++) {
if ((i == GPMODE_CAPABILITIES_PAGE) && (j >= 6) && (j <= 7)) {
if (j & 1)
buf[pos++] = ((cdrom_drives[id].speed * 176) & 0xff);
else
buf[pos++] = ((cdrom_drives[id].speed * 176) >> 8);
} else if ((i == GPMODE_CAPABILITIES_PAGE) && (j >= 12) && (j <= 13)) {
if (j & 1)
buf[pos++] = ((dev->cur_speed * 176) & 0xff);
else
buf[pos++] = ((dev->cur_speed * 176) >> 8);
} else
buf[pos++] = cdrom_mode_sense_read(id, page_control, i, 2 + j); buf[pos++] = cdrom_mode_sense_read(id, page_control, i, 2 + j);
} }
} }
} }
}
return pos; return pos;
} }
@@ -852,6 +866,7 @@ static void cdrom_command_common(uint8_t id)
dev->callback = 0LL; dev->callback = 0LL;
} else { } else {
switch(dev->current_cdb[0]) { switch(dev->current_cdb[0]) {
case GPCMD_REZERO_UNIT:
case 0x0b: case 0x0b:
case 0x2b: case 0x2b:
/* Seek time is in us. */ /* Seek time is in us. */
@@ -877,7 +892,7 @@ static void cdrom_command_common(uint8_t id)
case 0xbe: case 0xbe:
/* bytes_per_second = 150.0 * 1024.0; */ /* bytes_per_second = 150.0 * 1024.0; */
bytes_per_second = (1000000.0 / 12000.0) * 2048.0; /* Account for seek time. */ bytes_per_second = (1000000.0 / 12000.0) * 2048.0; /* Account for seek time. */
bytes_per_second *= (double) cdrom_drives[id].speed; bytes_per_second *= (double) dev->cur_speed;
break; break;
default: default:
bytes_per_second = cdrom_bus_speed(id); bytes_per_second = cdrom_bus_speed(id);
@@ -1434,6 +1449,8 @@ void cdrom_insert(uint8_t id)
cdrom_t *dev = cdrom[id]; cdrom_t *dev = cdrom[id];
dev->unit_attention = 1; dev->unit_attention = 1;
cdrom_log("CD-ROM %i: Media insert\n", id);
} }
/*SCSI Sense Initialization*/ /*SCSI Sense Initialization*/
@@ -1500,7 +1517,7 @@ skip_ready_check:
/* Only increment the unit attention phase if the command can not pass through it. */ /* Only increment the unit attention phase if the command can not pass through it. */
if (!(cdrom_command_flags[cdb[0]] & ALLOW_UA)) { if (!(cdrom_command_flags[cdb[0]] & ALLOW_UA)) {
/* cdrom_log("CD-ROM %i: Unit attention now 2\n", id); */ /* cdrom_log("CD-ROM %i: Unit attention now 2\n", id); */
dev->unit_attention = 2; dev->unit_attention++;
cdrom_log("CD-ROM %i: UNIT ATTENTION: Command %02X not allowed to pass through\n", id, cdb[0]); cdrom_log("CD-ROM %i: UNIT ATTENTION: Command %02X not allowed to pass through\n", id, cdb[0]);
cdrom_unit_attention(id); cdrom_unit_attention(id);
return 0; return 0;
@@ -1574,6 +1591,9 @@ void cdrom_reset(uint8_t id)
{ {
cdrom_t *dev = cdrom[id]; cdrom_t *dev = cdrom[id];
if (!dev)
return;
cdrom_rezero(id); cdrom_rezero(id);
dev->status = 0; dev->status = 0;
dev->callback = 0LL; dev->callback = 0LL;
@@ -1771,6 +1791,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb)
if (cdrom_drives[id].handler->stop) if (cdrom_drives[id].handler->stop)
cdrom_drives[id].handler->stop(id); cdrom_drives[id].handler->stop(id);
dev->sector_pos = dev->sector_len = 0; dev->sector_pos = dev->sector_len = 0;
dev->seek_diff = dev->seek_pos;
cdrom_seek(id, 0); cdrom_seek(id, 0);
cdrom_set_phase(id, SCSI_PHASE_STATUS); cdrom_set_phase(id, SCSI_PHASE_STATUS);
break; break;
@@ -1788,6 +1809,11 @@ void cdrom_command(uint8_t id, uint8_t *cdb)
case GPCMD_SET_SPEED: case GPCMD_SET_SPEED:
case GPCMD_SET_SPEED_ALT: case GPCMD_SET_SPEED_ALT:
dev->cur_speed = (cdb[3] | (cdb[2] << 8)) / 176;
if (dev->cur_speed < 1)
dev->cur_speed = 1;
else if (dev->cur_speed > cdrom_drives[id].speed)
dev->cur_speed = cdrom_drives[id].speed;
cdrom_set_phase(id, SCSI_PHASE_STATUS); cdrom_set_phase(id, SCSI_PHASE_STATUS);
cdrom_command_complete(id); cdrom_command_complete(id);
break; break;

View File

@@ -9,7 +9,7 @@
* Implementation of the CD-ROM drive with SCSI(-like) * Implementation of the CD-ROM drive with SCSI(-like)
* commands, for both ATAPI and SCSI usage. * commands, for both ATAPI and SCSI usage.
* *
* Version: @(#)cdrom.h 1.0.8 2018/03/17 * Version: @(#)cdrom.h 1.0.9 2018/03/18
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* *
@@ -165,6 +165,8 @@ typedef struct {
int handler_inited; int handler_inited;
int disc_changed; int disc_changed;
int cur_speed;
} cdrom_t; } cdrom_t;
typedef struct { typedef struct {
@@ -249,6 +251,7 @@ extern void cdrom_set_signature(int id);
extern void cdrom_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length); extern void cdrom_request_sense_for_scsi(uint8_t id, uint8_t *buffer, uint8_t alloc_length);
extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks); extern void cdrom_update_cdb(uint8_t *cdb, int lba_pos, int number_of_blocks);
extern void cdrom_insert(uint8_t id); extern void cdrom_insert(uint8_t id);
extern void cdrom_new_image(uint8_t id);
extern int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun); extern int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun);
extern int cdrom_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len); extern int cdrom_read_capacity(uint8_t id, uint8_t *cdb, uint8_t *buffer, uint32_t *len);

View File

@@ -58,41 +58,41 @@ CDROM_Interface_Image::BinaryFile::BinaryFile(const char *filename, bool &error)
{ {
memset(fn, 0, sizeof(fn)); memset(fn, 0, sizeof(fn));
strcpy(fn, filename); strcpy(fn, filename);
file = fopen64(fn, "rb");
if (file == NULL)
error = true;
else
error = false; error = false;
} }
CDROM_Interface_Image::BinaryFile::~BinaryFile() CDROM_Interface_Image::BinaryFile::~BinaryFile()
{ {
fclose(file);
file = NULL;
memset(fn, 0, sizeof(fn)); memset(fn, 0, sizeof(fn));
} }
bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, uint64_t seek, uint64_t count) bool CDROM_Interface_Image::BinaryFile::read(Bit8u *buffer, uint64_t seek, uint64_t count)
{ {
file = fopen64(fn, "rb");
if (file == NULL) return 0;
fseeko64(file, seek, SEEK_SET); fseeko64(file, seek, SEEK_SET);
fread(buffer, 1, count, file); fread(buffer, 1, count, file);
fclose(file);
return 1; return 1;
} }
uint64_t CDROM_Interface_Image::BinaryFile::getLength() uint64_t CDROM_Interface_Image::BinaryFile::getLength()
{ {
uint64_t ret = 0;
file = fopen64(fn, "rb");
if (file == NULL) return 0;
fseeko64(file, 0, SEEK_END); fseeko64(file, 0, SEEK_END);
ret = ftello64(file); return ftello64(file);
fclose(file);
return ret;
} }
CDROM_Interface_Image::CDROM_Interface_Image() CDROM_Interface_Image::CDROM_Interface_Image()
{ {
printf("CDROM_Interface_Image constructor\n");
} }
CDROM_Interface_Image::~CDROM_Interface_Image() CDROM_Interface_Image::~CDROM_Interface_Image()
{ {
printf("CDROM_Interface_Image destructor\n");
ClearTracks(); ClearTracks();
} }
@@ -357,6 +357,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
ifstream in; ifstream in;
in.open(cuefile, ios::in); in.open(cuefile, ios::in);
if (in.fail()) return false; if (in.fail()) return false;
int last_attr;
while(!in.eof()) { while(!in.eof()) {
// get next line // get next line
@@ -427,6 +428,7 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
track.attr = DATA_TRACK; track.attr = DATA_TRACK;
track.mode2 = true; track.mode2 = true;
} else success = false; } else success = false;
last_attr = track.attr;
canAddTrack = true; canAddTrack = true;
} }
@@ -479,7 +481,8 @@ bool CDROM_Interface_Image::LoadCueSheet(char *cuefile)
track.number++; track.number++;
track.track_number = 0xAA; track.track_number = 0xAA;
// track.attr = 0;//sync with load iso // track.attr = 0;//sync with load iso
track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */ // track.attr = 0x16; /* Was 0x00 but I believe 0x16 is appropriate. */
track.attr = last_attr | 0x02;
track.start = 0; track.start = 0;
track.length = 0; track.length = 0;
track.file = NULL; track.file = NULL;

View File

@@ -68,6 +68,7 @@ void image_audio_callback(uint8_t id, int16_t *output, int len)
{ {
cdrom_t *dev = cdrom[id]; cdrom_t *dev = cdrom[id];
return;
if (!cdrom_drives[id].sound_on || (dev->cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso) if (!cdrom_drives[id].sound_on || (dev->cd_state != CD_PLAYING) || cdrom_image[id].image_is_iso)
{ {
cdrom_image_log("image_audio_callback(i): Not playing\n", id); cdrom_image_log("image_audio_callback(i): Not playing\n", id);
@@ -216,12 +217,6 @@ static int image_ready(uint8_t id)
return 1; return 1;
} }
if (dev->disc_changed)
{
dev->disc_changed = 0;
return 1;
}
return 1; return 1;
} }
@@ -268,12 +263,6 @@ static int image_medium_changed(uint8_t id)
return 1; return 1;
} }
if (dev->disc_changed)
{
dev->disc_changed = 0;
return 1;
}
return 0; return 0;
} }
@@ -848,7 +837,7 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack,
uint32_t temp; uint32_t temp;
int first_track; int first_track;
int last_track; int last_track, last_track_pos;
int number; int number;
unsigned char attr; unsigned char attr;
TMSF tmsf; TMSF tmsf;
@@ -881,6 +870,7 @@ static int image_readtoc(uint8_t id, unsigned char *b, unsigned char starttrack,
break; break;
cdimg[id]->GetAudioTrackInfo(c+1, number, tmsf, attr); cdimg[id]->GetAudioTrackInfo(c+1, number, tmsf, attr);
last_track_pos = 0;
b[len++] = 0; /* reserved */ b[len++] = 0; /* reserved */
b[len++] = attr; b[len++] = attr;
b[len++] = number; /* track number */ b[len++] = number; /* track number */
@@ -971,10 +961,8 @@ static int image_readtoc_raw(uint8_t id, unsigned char *b, int maxlen)
cdimg[id]->GetAudioTracks(first_track, last_track, tmsf); cdimg[id]->GetAudioTracks(first_track, last_track, tmsf);
if (maxlen >= 3) b[2] = first_track; b[2] = first_track;
if (maxlen >= 4) b[3] = last_track; b[3] = last_track;
if (maxlen <= 4) return len;
for (track = first_track; track <= last_track; track++) for (track = first_track; track <= last_track; track++)
{ {
@@ -1057,18 +1045,7 @@ int image_open(uint8_t id, wchar_t *fn)
{ {
cdrom_t *dev = cdrom[id]; cdrom_t *dev = cdrom[id];
if (wcscmp(fn, cdrom_image[id].image_path) != 0)
{
dev->disc_changed = 1;
}
/* Make sure image_changed stays when changing from an image to another image. */
if (!dev->handler_inited && (cdrom_drives[id].host_drive != 200)) dev->disc_changed = 0;
if (!dev->handler_inited || dev->disc_changed)
{
wcscpy(cdrom_image[id].image_path, fn); wcscpy(cdrom_image[id].image_path, fn);
}
if (! wcscasecmp(plat_get_extension(fn), L"ISO")) if (! wcscasecmp(plat_get_extension(fn), L"ISO"))
{ {
@@ -1080,6 +1057,7 @@ int image_open(uint8_t id, wchar_t *fn)
} }
cdimg[id] = new CDROM_Interface_Image(); cdimg[id] = new CDROM_Interface_Image();
memset(afn, 0, sizeof(afn));
wcstombs(afn, fn, sizeof(afn)); wcstombs(afn, fn, sizeof(afn));
if (!cdimg[id]->SetDevice(afn, false)) if (!cdimg[id]->SetDevice(afn, false))
{ {
@@ -1093,12 +1071,6 @@ int image_open(uint8_t id, wchar_t *fn)
dev->cdrom_capacity = image_get_last_block(id, 0, 0, 4096, 0) + 1; dev->cdrom_capacity = image_get_last_block(id, 0, 0, 4096, 0) + 1;
cdrom_drives[id].handler = &image_cdrom; cdrom_drives[id].handler = &image_cdrom;
if (!dev->handler_inited || dev->disc_changed)
{
if (!dev->handler_inited)
dev->handler_inited = 1;
}
return 0; return 0;
} }

View File

@@ -10,7 +10,7 @@
* data in the form of FM/MFM-encoded transitions) which also * data in the form of FM/MFM-encoded transitions) which also
* forms the core of the emulator's floppy disk emulation. * forms the core of the emulator's floppy disk emulation.
* *
* Version: @(#)fdd_86f.c 1.0.17 2018/03/14 * Version: @(#)fdd_86f.c 1.0.18 2018/03/17
* *
* Author: Miran Grca, <mgrca8@gmail.com> * Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016-2018 Miran Grca. * Copyright 2016-2018 Miran Grca.

View File

@@ -11,7 +11,7 @@
* TODO: Add the Genius bus- and serial mouse. * TODO: Add the Genius bus- and serial mouse.
* Remove the '3-button' flag from mouse types. * Remove the '3-button' flag from mouse types.
* *
* Version: @(#)mouse.c 1.0.21 2018/01/29 * Version: @(#)mouse.c 1.0.22 2018/03/18
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -75,6 +75,7 @@ static mouse_t mouse_devices[] = {
static device_t *mouse_curr; static device_t *mouse_curr;
static void *mouse_priv; static void *mouse_priv;
static int mouse_nbut; static int mouse_nbut;
static int (*mouse_dev_poll)();
/* Initialize the mouse module. */ /* Initialize the mouse module. */
@@ -89,6 +90,7 @@ mouse_init(void)
mouse_curr = NULL; mouse_curr = NULL;
mouse_priv = NULL; mouse_priv = NULL;
mouse_nbut = 0; mouse_nbut = 0;
mouse_dev_poll = NULL;
} }
@@ -100,6 +102,7 @@ mouse_close(void)
mouse_curr = NULL; mouse_curr = NULL;
mouse_priv = NULL; mouse_priv = NULL;
mouse_nbut = 0; mouse_nbut = 0;
mouse_dev_poll = NULL;
} }
@@ -145,8 +148,11 @@ mouse_process(void)
mouse_poll(); mouse_poll();
if (mouse_curr->available != NULL) { if ((mouse_dev_poll != NULL) || (mouse_curr->available != NULL)) {
if (mouse_curr->available != NULL)
mouse_curr->available(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv); mouse_curr->available(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv);
else
mouse_dev_poll(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv);
/* Reset mouse deltas. */ /* Reset mouse deltas. */
mouse_x = mouse_y = mouse_z = 0; mouse_x = mouse_y = mouse_z = 0;
@@ -161,7 +167,7 @@ mouse_set_poll(int (*func)(int,int,int,int,void *), void *arg)
{ {
if (mouse_type != MOUSE_TYPE_INTERNAL) return; if (mouse_type != MOUSE_TYPE_INTERNAL) return;
mouse_curr->available = func; mouse_dev_poll = func;
mouse_priv = arg; mouse_priv = arg;
} }

View File

@@ -8,11 +8,11 @@
* *
* Handle WinPcap library processing. * Handle WinPcap library processing.
* *
* Version: @(#)net_pcap.c 1.0.13 2017/11/04 * Version: @(#)net_pcap.c 1.0.14 2018/03/18
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
* Copyright 2017 Fred N. van Kempen. * Copyright 2017,2018 Fred N. van Kempen.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
@@ -274,7 +274,7 @@ net_pcap_close(void)
* tries to attach to the network module. * tries to attach to the network module.
*/ */
int int
net_pcap_reset(netcard_t *card) net_pcap_reset(netcard_t *card, uint8_t *mac)
{ {
char errbuf[PCAP_ERRBUF_SIZE]; char errbuf[PCAP_ERRBUF_SIZE];
char filter_exp[255]; char filter_exp[255];
@@ -293,14 +293,11 @@ net_pcap_reset(netcard_t *card)
/* Create a MAC address based packet filter. */ /* Create a MAC address based packet filter. */
pclog("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", pclog("PCAP: installing filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n",
card->mac[0], card->mac[1], card->mac[2], mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
card->mac[3], card->mac[4], card->mac[5]);
sprintf(filter_exp, sprintf(filter_exp,
"( ((ether dst ff:ff:ff:ff:ff:ff) or (ether dst %02x:%02x:%02x:%02x:%02x:%02x)) and not (ether src %02x:%02x:%02x:%02x:%02x:%02x) )", "( ((ether dst ff:ff:ff:ff:ff:ff) or (ether dst %02x:%02x:%02x:%02x:%02x:%02x)) and not (ether src %02x:%02x:%02x:%02x:%02x:%02x) )",
card->mac[0], card->mac[1], card->mac[2], mac[0], mac[1], mac[2], mac[3], mac[4], mac[5],
card->mac[3], card->mac[4], card->mac[5], mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
card->mac[0], card->mac[1], card->mac[2],
card->mac[3], card->mac[4], card->mac[5]);
if (f_pcap_compile((pcap_t *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) { if (f_pcap_compile((pcap_t *)pcap, &fp, filter_exp, 0, 0xffffffff) != -1) {
if (f_pcap_setfilter((pcap_t *)pcap, &fp) != 0) { if (f_pcap_setfilter((pcap_t *)pcap, &fp) != 0) {
pclog("PCAP: error installing filter (%s) !\n", filter_exp); pclog("PCAP: error installing filter (%s) !\n", filter_exp);
@@ -318,7 +315,7 @@ net_pcap_reset(netcard_t *card)
pclog("PCAP: starting thread..\n"); pclog("PCAP: starting thread..\n");
poll_state = thread_create_event(); poll_state = thread_create_event();
poll_tid = thread_create(poll_thread, card->mac); poll_tid = thread_create(poll_thread, mac);
thread_wait_event(poll_state, -1); thread_wait_event(poll_state, -1);
return(0); return(0);

View File

@@ -8,11 +8,11 @@
* *
* Handle SLiRP library processing. * Handle SLiRP library processing.
* *
* Version: @(#)net_slirp.c 1.0.13 2017/11/04 * Version: @(#)net_slirp.c 1.0.14 2018/03/18
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
* Copyright 2017 Fred N. van Kempen. * Copyright 2017,2018 Fred N. van Kempen.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
@@ -143,14 +143,14 @@ net_slirp_init(void)
/* Initialize SLiRP for use. */ /* Initialize SLiRP for use. */
int int
net_slirp_reset(netcard_t *card) net_slirp_reset(netcard_t *card, uint8_t *mac)
{ {
/* Save the callback info. */ /* Save the callback info. */
poll_card = card; poll_card = card;
pclog("SLiRP: creating thread..\n"); pclog("SLiRP: creating thread..\n");
poll_state = thread_create_event(); poll_state = thread_create_event();
poll_tid = thread_create(poll_thread, card->mac); poll_tid = thread_create(poll_thread, mac);
thread_wait_event(poll_state, -1); thread_wait_event(poll_state, -1);
return(0); return(0);

View File

@@ -12,7 +12,7 @@
* it should be malloc'ed and then linked to the NETCARD def. * it should be malloc'ed and then linked to the NETCARD def.
* Will be done later. * Will be done later.
* *
* Version: @(#)network.c 1.0.21 2018/02/18 * Version: @(#)network.c 1.0.22 2018/03/18
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -51,12 +51,13 @@ static netcard_t net_cards[] = {
int network_type; int network_type;
int network_ndev; int network_ndev;
int network_card; int network_card;
netdev_t network_devs[32];
char network_pcap[512]; char network_pcap[512];
netdev_t network_devs[32];
#ifdef ENABLE_NIC_LOG #ifdef ENABLE_NIC_LOG
int nic_do_log = ENABLE_NIC_LOG; int nic_do_log = ENABLE_NIC_LOG;
#endif #endif
static mutex_t *network_mutex; static mutex_t *network_mutex;
static uint8_t *network_mac;
static struct { static struct {
@@ -149,7 +150,7 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
/* Save the card's info. */ /* Save the card's info. */
net_cards[network_card].priv = dev; net_cards[network_card].priv = dev;
net_cards[network_card].rx = rx; net_cards[network_card].rx = rx;
net_cards[network_card].mac = mac; network_mac = mac;
/* Create the network events. */ /* Create the network events. */
poll_data.wake_poll_thread = thread_create_event(); poll_data.wake_poll_thread = thread_create_event();
@@ -158,11 +159,11 @@ network_attach(void *dev, uint8_t *mac, NETRXCB rx)
/* Activate the platform module. */ /* Activate the platform module. */
switch(network_type) { switch(network_type) {
case NET_TYPE_PCAP: case NET_TYPE_PCAP:
(void)net_pcap_reset(&net_cards[network_card]); (void)net_pcap_reset(&net_cards[network_card], network_mac);
break; break;
case NET_TYPE_SLIRP: case NET_TYPE_SLIRP:
(void)net_slirp_reset(&net_cards[network_card]); (void)net_slirp_reset(&net_cards[network_card], network_mac);
break; break;
} }
} }
@@ -194,6 +195,7 @@ network_close(void)
/* Close the network thread mutex. */ /* Close the network thread mutex. */
thread_close_mutex(network_mutex); thread_close_mutex(network_mutex);
network_mutex = NULL; network_mutex = NULL;
network_mac = NULL;
pclog("NETWORK: closed.\n"); pclog("NETWORK: closed.\n");
} }

View File

@@ -8,7 +8,7 @@
* *
* Definitions for the network module. * Definitions for the network module.
* *
* Version: @(#)network.h 1.0.12 2018/02/18 * Version: @(#)network.h 1.0.13 2018/03/18
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
*/ */
@@ -79,12 +79,12 @@ extern void network_tx(uint8_t *, int);
extern int net_pcap_prepare(netdev_t *); extern int net_pcap_prepare(netdev_t *);
extern int net_pcap_init(void); extern int net_pcap_init(void);
extern int net_pcap_reset(netcard_t *); extern int net_pcap_reset(netcard_t *, uint8_t *);
extern void net_pcap_close(void); extern void net_pcap_close(void);
extern void net_pcap_in(uint8_t *, int); extern void net_pcap_in(uint8_t *, int);
extern int net_slirp_init(void); extern int net_slirp_init(void);
extern int net_slirp_reset(netcard_t *); extern int net_slirp_reset(netcard_t *, uint8_t *);
extern void net_slirp_close(void); extern void net_slirp_close(void);
extern void net_slirp_in(uint8_t *, int); extern void net_slirp_in(uint8_t *, int);

View File

@@ -8,7 +8,7 @@
* *
* Implement the application's Status Bar. * Implement the application's Status Bar.
* *
* Version: @(#)win_stbar.c 1.0.16 2018/03/17 * Version: @(#)win_stbar.c 1.0.17 2018/03/18
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -1072,10 +1072,6 @@ StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
if (!file_dlg_w_st(hwnd, IDS_2075, cdrom_image[id].image_path, 0)) { if (!file_dlg_w_st(hwnd, IDS_2075, cdrom_image[id].image_path, 0)) {
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive; cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
wcscpy(temp_path, wopenfilestring); wcscpy(temp_path, wopenfilestring);
if ((wcscmp(cdrom_image[id].image_path, temp_path) == 0) && (cdrom_drives[id].host_drive == 200)) {
/* Switching from image to the same image. Do nothing. */
break;
}
if (!cdrom_image[id].prev_image_path) if (!cdrom_image[id].prev_image_path)
cdrom_image[id].prev_image_path = (wchar_t *) malloc(1024); cdrom_image[id].prev_image_path = (wchar_t *) malloc(1024);
wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path); wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path);