i2o.h
来自「此工具是arm-linux-GCC交叉编译工具(cross-3.4.4)」· C头文件 代码 · 共 1,127 行 · 第 1/3 页
H
1,127 行
* SG list if the allocation was successful. * * Returns DMA address which must be checked for failures using * dma_mapping_error(). */static inline dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr, size_t size, enum dma_data_direction direction, u32 __iomem ** sg_ptr){ u32 sg_flags; u32 __iomem *mptr = *sg_ptr; dma_addr_t dma_addr; switch (direction) { case DMA_TO_DEVICE: sg_flags = 0xd4000000; break; case DMA_FROM_DEVICE: sg_flags = 0xd0000000; break; default: return 0; } dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction); if (!dma_mapping_error(dma_addr)) {#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 if ((sizeof(dma_addr_t) > 4) && c->pae_support) { writel(0x7C020002, mptr++); writel(PAGE_SIZE, mptr++); }#endif writel(sg_flags | size, mptr++); writel(i2o_dma_low(dma_addr), mptr++);#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 if ((sizeof(dma_addr_t) > 4) && c->pae_support) writel(i2o_dma_high(dma_addr), mptr++);#endif *sg_ptr = mptr; } return dma_addr;};/** * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message. * @c: I2O controller * @sg: SG list to be mapped * @sg_count: number of elements in the SG list * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE * @sg_ptr: pointer to the SG list inside the I2O message * * This function does all necessary DMA handling and also writes the I2O * SGL elements into the I2O message. For details on DMA handling see also * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG * list if the allocation was successful. * * Returns 0 on failure or 1 on success. */static inline int i2o_dma_map_sg(struct i2o_controller *c, struct scatterlist *sg, int sg_count, enum dma_data_direction direction, u32 __iomem ** sg_ptr){ u32 sg_flags; u32 __iomem *mptr = *sg_ptr; switch (direction) { case DMA_TO_DEVICE: sg_flags = 0x14000000; break; case DMA_FROM_DEVICE: sg_flags = 0x10000000; break; default: return 0; } sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction); if (!sg_count) return 0;#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 if ((sizeof(dma_addr_t) > 4) && c->pae_support) { writel(0x7C020002, mptr++); writel(PAGE_SIZE, mptr++); }#endif while (sg_count-- > 0) { if (!sg_count) sg_flags |= 0xC0000000; writel(sg_flags | sg_dma_len(sg), mptr++); writel(i2o_dma_low(sg_dma_address(sg)), mptr++);#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 if ((sizeof(dma_addr_t) > 4) && c->pae_support) writel(i2o_dma_high(sg_dma_address(sg)), mptr++);#endif sg++; } *sg_ptr = mptr; return 1;};/** * i2o_dma_alloc - Allocate DMA memory * @dev: struct device pointer to the PCI device of the I2O controller * @addr: i2o_dma struct which should get the DMA buffer * @len: length of the new DMA memory * @gfp_mask: GFP mask * * Allocate a coherent DMA memory and write the pointers into addr. * * Returns 0 on success or -ENOMEM on failure. */static inline int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len, unsigned int gfp_mask){ struct pci_dev *pdev = to_pci_dev(dev); int dma_64 = 0; if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_64BIT_MASK)) { dma_64 = 1; if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) return -ENOMEM; } addr->virt = dma_alloc_coherent(dev, len, &addr->phys, gfp_mask); if ((sizeof(dma_addr_t) > 4) && dma_64) if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)) printk(KERN_WARNING "i2o: unable to set 64-bit DMA"); if (!addr->virt) return -ENOMEM; memset(addr->virt, 0, len); addr->len = len; return 0;};/** * i2o_dma_free - Free DMA memory * @dev: struct device pointer to the PCI device of the I2O controller * @addr: i2o_dma struct which contains the DMA buffer * * Free a coherent DMA memory and set virtual address of addr to NULL. */static inline void i2o_dma_free(struct device *dev, struct i2o_dma *addr){ if (addr->virt) { if (addr->phys) dma_free_coherent(dev, addr->len, addr->virt, addr->phys); else kfree(addr->virt); addr->virt = NULL; }};/** * i2o_dma_realloc - Realloc DMA memory * @dev: struct device pointer to the PCI device of the I2O controller * @addr: pointer to a i2o_dma struct DMA buffer * @len: new length of memory * @gfp_mask: GFP mask * * If there was something allocated in the addr, free it first. If len > 0 * than try to allocate it and write the addresses back to the addr * structure. If len == 0 set the virtual address to NULL. * * Returns the 0 on success or negative error code on failure. */static inline int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, size_t len, unsigned int gfp_mask){ i2o_dma_free(dev, addr); if (len) return i2o_dma_alloc(dev, addr, len, gfp_mask); return 0;};/* I2O driver (OSM) functions */extern int i2o_driver_register(struct i2o_driver *);extern void i2o_driver_unregister(struct i2o_driver *);/** * i2o_driver_notify_controller_add - Send notification of added controller * to a single I2O driver * * Send notification of added controller to a single registered driver. */static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv, struct i2o_controller *c){ if (drv->notify_controller_add) drv->notify_controller_add(c);};/** * i2o_driver_notify_controller_remove - Send notification of removed * controller to a single I2O driver * * Send notification of removed controller to a single registered driver. */static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv, struct i2o_controller *c){ if (drv->notify_controller_remove) drv->notify_controller_remove(c);};/** * i2o_driver_notify_device_add - Send notification of added device to a * single I2O driver * * Send notification of added device to a single registered driver. */static inline void i2o_driver_notify_device_add(struct i2o_driver *drv, struct i2o_device *i2o_dev){ if (drv->notify_device_add) drv->notify_device_add(i2o_dev);};/** * i2o_driver_notify_device_remove - Send notification of removed device * to a single I2O driver * * Send notification of removed device to a single registered driver. */static inline void i2o_driver_notify_device_remove(struct i2o_driver *drv, struct i2o_device *i2o_dev){ if (drv->notify_device_remove) drv->notify_device_remove(i2o_dev);};extern void i2o_driver_notify_controller_add_all(struct i2o_controller *);extern void i2o_driver_notify_controller_remove_all(struct i2o_controller *);extern void i2o_driver_notify_device_add_all(struct i2o_device *);extern void i2o_driver_notify_device_remove_all(struct i2o_device *);/* I2O device functions */extern int i2o_device_claim(struct i2o_device *);extern int i2o_device_claim_release(struct i2o_device *);/* Exec OSM functions */extern int i2o_exec_lct_get(struct i2o_controller *);/* device / driver / kobject conversion functions */#define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver)#define to_i2o_device(dev) container_of(dev, struct i2o_device, device)#define to_i2o_controller(dev) container_of(dev, struct i2o_controller, device)#define kobj_to_i2o_device(kobj) to_i2o_device(container_of(kobj, struct device, kobj))/** * i2o_msg_get - obtain an I2O message from the IOP * @c: I2O controller * @msg: pointer to a I2O message pointer * * This function tries to get a message slot. If no message slot is * available do not wait until one is availabe (see also i2o_msg_get_wait). * * On a success the message is returned and the pointer to the message is * set in msg. The returned message is the physical page frame offset * address from the read port (see the i2o spec). If no message is * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. */static inline u32 i2o_msg_get(struct i2o_controller *c, struct i2o_message __iomem ** msg){ u32 m = readl(c->in_port); if (m != I2O_QUEUE_EMPTY) *msg = c->in_queue.virt + m; return m;};/** * i2o_msg_post - Post I2O message to I2O controller * @c: I2O controller to which the message should be send * @m: the message identifier * * Post the message to the I2O controller. */static inline void i2o_msg_post(struct i2o_controller *c, u32 m){ writel(m, c->in_port);};/** * i2o_msg_post_wait - Post and wait a message and wait until return * @c: controller * @m: message to post * @timeout: time in seconds to wait * * This API allows an OSM to post a message and then be told whether or * not the system received a successful reply. If the message times out * then the value '-ETIMEDOUT' is returned. * * Returns 0 on success or negative error code on failure. */static inline int i2o_msg_post_wait(struct i2o_controller *c, u32 m, unsigned long timeout){ return i2o_msg_post_wait_mem(c, m, timeout, NULL);};/** * i2o_flush_reply - Flush reply from I2O controller * @c: I2O controller * @m: the message identifier * * The I2O controller must be informed that the reply message is not needed * anymore. If you forget to flush the reply, the message frame can't be * used by the controller anymore and is therefore lost. */static inline void i2o_flush_reply(struct i2o_controller *c, u32 m){ writel(m, c->out_port);};/** * i2o_out_to_virt - Turn an I2O message to a virtual address * @c: controller * @m: message engine value * * Turn a receive message from an I2O controller bus address into * a Linux virtual address. The shared page frame is a linear block * so we simply have to shift the offset. This function does not * work for sender side messages as they are ioremap objects * provided by the I2O controller. */static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c, u32 m){ BUG_ON(m < c->out_queue.phys || m >= c->out_queue.phys + c->out_queue.len); return c->out_queue.virt + (m - c->out_queue.phys);};/** * i2o_msg_in_to_virt - Turn an I2O message to a virtual address * @c: controller * @m: message engine value * * Turn a send message from an I2O controller bus address into * a Linux virtual address. The shared page frame is a linear block * so we simply have to shift the offset. This function does not * work for receive side messages as they are kmalloc objects * in a different pool. */static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct i2o_controller *c, u32 m){ return c->in_queue.virt + m;};/* * Endian handling wrapped into the macro - keeps the core code * cleaner. */#define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem)extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int);extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?