Add Novell NetWare 2.x Card Key emulation
This commit is contained in:
@@ -22,7 +22,8 @@ add_library(dev OBJECT bugger.c cassette.c cartridge.c hasp.c hwm.c hwm_lm75.c h
|
||||
kbc_at.c kbc_at_dev.c
|
||||
keyboard_at.c
|
||||
mouse.c mouse_bus.c mouse_serial.c mouse_ps2.c nec_mate_unk.c phoenix_486_jumper.c
|
||||
serial_passthrough.c)
|
||||
serial_passthrough.c
|
||||
novell_cardkey.c)
|
||||
|
||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_link_libraries(86Box atomic)
|
||||
|
||||
115
src/device/novell_cardkey.c
Normal file
115
src/device/novell_cardkey.c
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the Novell NetWare 2.x Key Card, which
|
||||
* was used for anti-piracy protection.
|
||||
*
|
||||
*
|
||||
* Authors: Cacodemon345
|
||||
*
|
||||
* Copyright 2024 Cacodemon345.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/io.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/novell_cardkey.h>
|
||||
|
||||
typedef struct novell_cardkey_t
|
||||
{
|
||||
char serial_number_str[13];
|
||||
} novell_cardkey_t;
|
||||
|
||||
static uint8_t
|
||||
novell_cardkey_read(uint16_t port, void *priv)
|
||||
{
|
||||
novell_cardkey_t* cardkey = (novell_cardkey_t*)priv;
|
||||
uint8_t val = 0x00;
|
||||
switch (port) {
|
||||
case 0x23A:
|
||||
val = ((cardkey->serial_number_str[11] - '0') << 4) | ((cardkey->serial_number_str[9] - '0'));
|
||||
break;
|
||||
case 0x23B:
|
||||
val = ((cardkey->serial_number_str[10] - '0') << 4) | ((cardkey->serial_number_str[8] - '0'));
|
||||
break;
|
||||
|
||||
case 0x23C:
|
||||
val = ((cardkey->serial_number_str[4] - '0') << 4) | ((cardkey->serial_number_str[2] - '0'));
|
||||
break;
|
||||
case 0x23D:
|
||||
val = ((cardkey->serial_number_str[1] - '0') << 4) | ((cardkey->serial_number_str[6] - '0'));
|
||||
break;
|
||||
case 0x23E:
|
||||
val = ((cardkey->serial_number_str[0] - '0') << 4) | ((cardkey->serial_number_str[7] - '0'));
|
||||
break;
|
||||
case 0x23F:
|
||||
val = ((cardkey->serial_number_str[3] - '0') << 4) | ((cardkey->serial_number_str[5] - '0'));
|
||||
break;
|
||||
}
|
||||
return val ^ 0xFF;
|
||||
}
|
||||
|
||||
void* novell_cardkey_init(const device_t* info)
|
||||
{
|
||||
char sernumstr[13] = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 0 };
|
||||
int i = 0;
|
||||
novell_cardkey_t* cardkey = calloc(1, sizeof(novell_cardkey_t));
|
||||
|
||||
strncpy(sernumstr, device_get_config_string("serial_number"), sizeof(sernumstr) - 1);
|
||||
|
||||
for (i = 0; i < sizeof(sernumstr); i++) {
|
||||
if (sernumstr[i] > '8' || sernumstr[i] < '0')
|
||||
sernumstr[i] = '0';
|
||||
}
|
||||
sernumstr[12] = 0;
|
||||
strncpy(cardkey->serial_number_str, sernumstr, sizeof(sernumstr));
|
||||
io_sethandler(NOVELL_KEYCARD_ADDR, NOVELL_KEYCARD_ADDRLEN, novell_cardkey_read, NULL, NULL, NULL, NULL, NULL, cardkey);
|
||||
return cardkey;
|
||||
}
|
||||
|
||||
void novell_cardkey_close(void* priv)
|
||||
{
|
||||
free(priv);
|
||||
}
|
||||
|
||||
static const device_config_t keycard_config[] = {
|
||||
// clang-format off
|
||||
{
|
||||
.name = "serial_number",
|
||||
.description = "Serial Number",
|
||||
.type = CONFIG_STRING,
|
||||
.default_string = "",
|
||||
.default_int = 0,
|
||||
.file_filter = "",
|
||||
.spinner = { 0 },
|
||||
.selection = { 0 }
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t novell_keycard_device = {
|
||||
.name = "Novell Netware 2.x Key Card",
|
||||
.internal_name = "mssystems",
|
||||
.flags = DEVICE_ISA,
|
||||
.local = 0,
|
||||
.init = novell_cardkey_init,
|
||||
.close = novell_cardkey_close,
|
||||
.reset = NULL,
|
||||
{ .available = NULL },
|
||||
.speed_changed = NULL,
|
||||
.force_redraw = NULL,
|
||||
.config = keycard_config
|
||||
};
|
||||
Reference in New Issue
Block a user