Help on Modifying a Driver on Native Linux
Richard Akintola <[email protected]> Tue, 1 Apr 2025 23:36:26 +0100
| Newsgroups | dev.linux.lists.outreachy |
|---|---|
| Message-ID | <[email protected]> |
I learnt that e1000 didn't work because the driver is included in VM
images and not on Linux native, and a variant of e1000 on Linux native
is the e1000e driver.
Below are some of the drivers that one could modify on Linux native
in order have the "I can modify Linux kernel\n" effect.
Using the e1000e driver
1. vim drivers/net/ethernet/intel/e1000e/netdev.c
2. Find the probe function
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *netdev;
struct e1000_adapter *adapter;
struct e1000_hw *hw;
const struct e1000_info *ei = e1000_info_tbl[ent->driver_data];
resource_size_t mmio_start, mmio_len;
resource_size_t flash_start, flash_len;
static int cards_found;
u16 aspm_disable_flag = 0;
u16 eeprom_data = 0;
u16 eeprom_apme_mask = E1000_EEPROM_APME;
int bars, i, err;
s32 ret_val = 0;
printk(KERN_DEBUG "I can modify the Linux kernel\n");
3. Save the file and recompile the kernel, you should see the text
printed when you run the "dmesg | less" command after rebooting.
Or you could use the bluetooth driver
1. vim drivers/bluetooth/btusb.c
2. Find the probe function
static int btusb_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_endpoint_descriptor *ep_desc;
struct gpio_desc *reset_gpio;
struct btusb_data *data;
struct hci_dev *hdev;
unsigned ifnum_base;
int i, err, priv_size;
printk(KERN_DEBUG "I can modify the Linux Kernel\n");
3. Save the file and recompile the kernel, you should see the text
printed when you run the "dmesg | less" command after rebooting.
I hope this helps.