isapnp: Add method for disabling the PnP key for a single device

This commit is contained in:
RichardG867 2022-02-18 14:34:43 -03:00
parent 07cba51e7b
commit de6a5b4e79
3 changed files with 7 additions and 11 deletions

View file

@ -414,7 +414,7 @@ isapnp_write_addr(uint16_t addr, uint8_t val, void *priv)
if (!dev->key_pos) {
isapnp_log("ISAPnP: Key unlocked, putting cards to SLEEP\n");
while (card) {
if (card->enable && (card->state == PNP_STATE_WAIT_FOR_KEY))
if (card->enable && (card->enable != ISAPNP_CARD_NO_KEY) && (card->state == PNP_STATE_WAIT_FOR_KEY))
card->state = PNP_STATE_SLEEP;
card = card->next;
}
@ -974,14 +974,12 @@ isapnp_enable_card(void *priv, uint8_t enable)
/* Look for a matching card. */
isapnp_card_t *card = dev->first_card;
uint8_t will_enable;
while (card) {
if (card == priv) {
/* Enable or disable the card. */
will_enable = (enable >= ISAPNP_CARD_ENABLE);
if (will_enable ^ card->enable)
if (!!enable ^ !!card->enable)
card->state = (enable == ISAPNP_CARD_FORCE_CONFIG) ? PNP_STATE_CONFIG : PNP_STATE_WAIT_FOR_KEY;
card->enable = will_enable;
card->enable = enable;
/* Invalidate other references if we're disabling this card. */
if (!card->enable) {

View file

@ -28,7 +28,8 @@
enum {
ISAPNP_CARD_DISABLE = 0,
ISAPNP_CARD_ENABLE = 1,
ISAPNP_CARD_FORCE_CONFIG /* cheat code for UMC UM8669F */
ISAPNP_CARD_FORCE_CONFIG, /* cheat code for UMC UM8669F */
ISAPNP_CARD_NO_KEY /* cheat code for Crystal CS423x */
};

View file

@ -547,11 +547,8 @@ cs423x_pnp_enable(cs423x_t *dev, uint8_t update_rom, uint8_t update_hwconfig)
if (update_rom)
isapnp_update_card_rom(dev->pnp_card, &dev->ram_data[dev->pnp_offset], 384);
/* Hide PnP card if the PKD bit is set, or if PnP was disabled by command 0x55. */
if ((dev->ram_data[0x4002] & 0x20) || !dev->pnp_enable)
isapnp_enable_card(dev->pnp_card, ISAPNP_CARD_DISABLE);
else
isapnp_enable_card(dev->pnp_card, ISAPNP_CARD_ENABLE);
/* Disable PnP key if the PKD bit is set, or if it was disabled by command 0x55. */
isapnp_enable_card(dev->pnp_card, ((dev->ram_data[0x4002] & 0x20) || !dev->pnp_enable) ? ISAPNP_CARD_NO_KEY : ISAPNP_CARD_ENABLE);
}
/* Update some register bits based on the config data in RAM if requested. */