Life Observatory

Январь 28, 2007

Рубрика: Uncategorized — kirjanov @ 3:49 пп

Январь 16, 2007

Driver development model with Intel e1000 Gigabit Ethernet driver

Рубрика: Uncategorized — kirjanov @ 9:23 дп

e1000_probe function not so small :) The first step inside function is switch on bus mastering on ethernet card. So we are invoke sequence on functions: pci_enable_device(), pci_set_dma_mask(), pci_request_region and finally pci_set_master(). When pci_set_dma_mask was called, 2 addressing modes are checked: 32 and 64 bit(DMA_64BIT_MASK and DMA_32BIT_MASK). If system has no support for dma error has occured.

if ((err = pci_enable_device(pdev)))
		return err;

	if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) {
		pci_using_dac = 1;
	} else {
		if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK))) {
			E1000_ERR("No usable DMA configuration, aborting\n");
			return err;
		}
		pci_using_dac = 0;
	}

	if ((err = pci_request_regions(pdev, e1000_driver_name)))
		return err;

	pci_set_master(pdev);

After all dma manipulations, next step is allocate net_device structure.

netdev = alloc_etherdev(sizeof(struct e1000_adapter)); if (!netdev) {

err = -ENOMEM;

goto err_alloc_etherdev;

}

alloc_etherdev was used because this function invokes ethernet specific routines internally. One parameter for function is size of private driver data, in our case - e1000 structure.

Январь 14, 2007

Ubuntu - ATI Friendship

Рубрика: Uncategorized — kirjanov @ 9:20 дп

New ATI video drivers installed succesfully. New driver pack includes ATI Control Panel.

Display Driver

      Driver Version :      8.33.06

OpenGL

      Vendor:                  ATI Technologies Inc.

      Version:                  2.0.6286 (8.33.6)

      Renderer:

           RADEON x700 PRO Generic

Январь 13, 2007

Driver development model with Intel e1000 Gigabit Ethernet driver

Рубрика: Unix0id — kirjanov @ 10:35 дп

New driver development model is veru useful! If we are develope usb driver, or pci driver for network card, we are use pci_device_id table for pci devices and usb_device_id table correspondingly. Also, for pci we are declare pci_driver struct with valid pointers to probe and remove functions.

static struct pci_device_id e1000_pci_tbl[] = { INTEL_E1000_ETHERNET_DEVICE(0x1000),   /* macro for PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id) */

INTEL_E1000_ETHERNET_DEVICE(0x1001),

..........

};

static struct pci_driver e1000_driver = {

.name     = e1000_driver_name,

.id_table = e1000_pci_tbl,

.probe    = e1000_probe,

.remove   = __devexit_p(e1000_remove),

/* Power Managment Hooks */

#ifdef CONFIG_PM

.suspend  = e1000_suspend,

.resume   = e1000_resume

#endif

};

static int __devinit

e1000_probe(struct pci_dev *pdev,

            const struct pci_device_id *ent)

{
        struct net_device *netdev;
	struct e1000_adapter *adapter;
	unsigned long mmio_start, mmio_len;

	static int cards_found = 0;
	static int e1000_ksp3_port_a = 0; /* global ksp3 port a indication */
	int i, err, pci_using_dac;
	uint16_t eeprom_data;
	uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
	if ((err = pci_enable_device(pdev)))
		return err;

      ........

}

static void __devexit

e1000_remove(struct pci_dev *pdev)

{

      ........

}

Our probe method invoked via pci_module_init function in module init routine

static int __init
e1000_init_module(void)
{
	int ret;
	printk(KERN_INFO "%s - version %sn",
	       e1000_driver_string, e1000_driver_version);

	printk(KERN_INFO "%sn", e1000_copyright);

	ret = pci_module_init(&e1000_driver);

	return ret;
}

Also we need enable our device with pci_enable_device() function. This is common steps for writing device driver.

To be continue…

Ноябрь 2, 2006

Map class for images splitting(PHP)

Рубрика: PHP — kirjanov @ 5:47 пп

Here PHP class for splitting images. create_image function creates navigation links via html table tag. Next step - add rendering code for displaying objects on map via GD library.

maplib

Октябрь 11, 2006

Lightweight processes(tasks)

Рубрика: Unix0id — kirjanov @ 5:46 пп

The main advantage of linux kernel are lightweight processes(tasks in kernel). To create new task, kernel invokes clone() system call, whoes invokes copy_process() function inside. New process have unique descriptor, task_struct, and thread_info struct. thread_info used, because new memory allocating mechanism(slab allocator) now implemented in 2.6 kernel. init process have his own task_struct - init_task. Kernel forks init in __init fork_init().

Октябрь 8, 2006

domainname/hostname implementation

Рубрика: Unix0id — kirjanov @ 9:51 дп

sys_setdomainname() and sys_gethostname() are implemented in file kernel/sys.c. Mutex locking used on rw_semaphore while manipulating system_utsname.

asmlinkage long sys_gethostname(char __user *name, int len)

{

if (copy_to_user(name, system_utsname.nodename, len))

errno = -EFAULT;

}

asmlinkage long sys_setdomainname(char __user *name, int len)

{

if (!copy_from_user(tmp, name, len)) {

memcpy(system_utsname.domainname, tmp, len);
system_utsname.domainname[len] = 0;

errno = 0;

}

}

Октябрь 3, 2006

New books in collection

Рубрика: generic life — kirjanov @ 5:45 дп

Linux Kernel Development by Robert Love  and Understanding Unix/Linux Programming by Bruce Molay. The first books with The Linux Networking Architecture is a good start palce for linux kernel hacking=).

Октябрь 1, 2006

Version diffs

Рубрика: Unix0id, generic life — kirjanov @ 9:44 дп

usb_class_driver struct changed while migrating from 2.6.12 to 2.6.15 kernel version. mode struct entry removed.

Сентябрь 27, 2006

Good Lyrics

Рубрика: generic life — kirjanov @ 4:47 пп

I’ve lost my way.

In a dark wood of error.

In a crisis, inside deep terror.

With fear in my mind, i spot a light!

The’re coming, after me, can’t

reach the light

three beast blocked the path

that lead the way to my life.

The beast from the UK.

The beast from the US.

The un beast was then unleashed,

to solve the problems in the

world, but they don’t!

Despise their false prophecies,

they have no right.

I despise what they’re doing to.

Sepultura, “Dark wood of error”

Предыдущие записи »

Заведите блог на WordPress.com.