<commit_before>#include <fudge/module.h>
#include <base/base.h>
#include <arch/x86/io/io.h>
#include "pci.h"

static unsigned int calculate_address(unsigned int num, unsigned int slot, unsigned int function)
{

    return 0x80000000 | (num << 16) | (slot << 11) | (function << 8);

}

unsigned int pci_bus_ind(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function, unsigned short offset)
{

    io_outd(bus->control, calculate_address(num, slot, function) | (offset & 0xFC));

    return io_ind(bus->data);

}

unsigned short pci_bus_inw(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function, unsigned short offset)
{

    io_outd(bus->control, calculate_address(num, slot, function) | (offset & 0xFC));

    return io_ind(bus->data) >> ((offset & 2) * 8);

}

unsigned char pci_bus_inb(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function, unsigned short offset)
{

    io_outd(bus->control, calculate_address(num, slot, function) | (offset & 0xFC));

    return io_ind(bus->data) >> ((offset & 3) * 8);

}

static void add_device(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function)
{

    struct pci_device *device = &bus->devices.item[bus->devices.count];
    unsigned int irq = pci_device_inb(device, PCI_CONFIG_LINE);

    pci_init_device(device, bus, irq, num, slot, function);

    bus->devices.count++;

}

static void detect(struct pci_bus *bus, unsigned int num)
{

    unsigned int slot;

    for (slot = 0; slot < 32; slot++)
    {

        unsigned int header;

        if (pci_bus_inw(bus, num, slot, 0, 0x00) == 0xFFFF)
            continue;<commit_msg>fixed a bug in pci irq<commit_after>#include <fudge/module.h>
#include <base/base.h>
#include <arch/x86/io/io.h>
#include "pci.h"

static unsigned int calculate_address(unsigned int num, unsigned int slot, unsigned int function)
{

    return 0x80000000 | (num << 16) | (slot << 11) | (function << 8);

}

unsigned int pci_bus_ind(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function, unsigned short offset)
{

    io_outd(bus->control, calculate_address(num, slot, function) | (offset & 0xFC));

    return io_ind(bus->data);

}

unsigned short pci_bus_inw(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function, unsigned short offset)
{

    io_outd(bus->control, calculate_address(num, slot, function) | (offset & 0xFC));

    return io_ind(bus->data) >> ((offset & 2) * 8);

}

unsigned char pci_bus_inb(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function, unsigned short offset)
{

    io_outd(bus->control, calculate_address(num, slot, function) | (offset & 0xFC));

    return io_ind(bus->data) >> ((offset & 3) * 8);

}

static void add_device(struct pci_bus *bus, unsigned int num, unsigned int slot, unsigned int function)
{

    struct pci_device *device = &bus->devices.item[bus->devices.count];
    unsigned int irq = pci_bus_inb(bus, num, slot, function, PCI_CONFIG_LINE);

    pci_init_device(device, bus, irq, num, slot, function);

    bus->devices.count++;

}

static void detect(struct pci_bus *bus, unsigned int num)
{

    unsigned int slot;

    for (slot = 0; slot < 32; slot++)
    {

        unsigned int header;

        if (pci_bus_inw(bus, num, slot, 0, 0x00) == 0xFFFF)
            continue;
{'fraction_non_alphanumeric': 0.12648104265402843, 'fraction_numerical': 0.018364928909952605, 'mean_word_length': 4.032786885245901, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6582094', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1114, 'n_words': 341}