Main Page | Directories | File List | Globals

dma.c File Reference

#include <agnix/agnix.h>
#include <agnix/adi/adi.h>
#include <agnix/spinlock.h>
#include <asm/types.h>
#include <agnix/ioport.h>
#include <agnix/memory.h>
#include <agnix/resources.h>
#include <agnix/console.h>

Include dependency graph for dma.c:

Go to the source code of this file.

Defines

#define MOD_NAME   "DMA: "

Functions

int dma_chip_init (struct chip_s *chip)
int dma_chip_release (struct chip_s *chip)
int dma_request_channel (struct chip_s *chip, u8 dma_nr)
int dma_put_channel (struct chip_s *chip, u8 dma_nr)
int dma_enable (struct chip_s *chip, u8 dma_nr)
int dma_disable (struct chip_s *chip, u8 dma_nr)
int dma_clear_ff (struct chip_s *chip, u8 dma_nr)
int dma_set_mode (struct chip_s *chip, u8 dma_nr, u8 mode)
int dma_set_addr (struct chip_s *chip, u8 dma_nr, u32 address)
int dma_set_count (struct chip_s *chip, u8 dma_nr, u16 count)
int dma_lock (struct chip_s *chip)
int dma_unlock (struct chip_s *chip)
int __init dma_init (void)

Variables

u32 dma_resource_bitmap [1]
resource_s dma_resource
int dma_resource_desc
u32 flags
chip_dma_ops_s dma_internal_ops
chip_ops_s dma_chip_ops
chip_s dma_chip


Define Documentation

#define MOD_NAME   "DMA: "
 

Definition at line 22 of file dma.c.


Function Documentation

int dma_chip_init struct chip_s *  chip  ) 
 

Definition at line 36 of file dma.c.

References dma_resource, dma_resource_desc, MOD_NAME, printk(), and register_resource().

00037 {
00038     if ((dma_resource_desc = register_resource(&dma_resource)) < 0)
00039     {
00040         printk(MOD_NAME "can not register dma resource\n");
00041         return -1;
00042     }    
00043     
00044     return 0;
00045 }

Here is the call graph for this function:

int dma_chip_release struct chip_s *  chip  ) 
 

Definition at line 47 of file dma.c.

00048 {
00049     return 0;
00050 }

int dma_clear_ff struct chip_s *  chip,
u8  dma_nr
 

Definition at line 90 of file dma.c.

00091 {
00092     if (dma_nr > 7)
00093         return -1;
00094 
00095     if (dma_nr < 4)
00096         outb(0x00, DMA1_REG_FF);
00097     else
00098     if (dma_nr < 8)
00099         outb(0x00, DMA2_REG_FF);
00100 
00101     return 0;
00102 }

int dma_disable struct chip_s *  chip,
u8  dma_nr
 

Definition at line 76 of file dma.c.

00077 {
00078     if (dma_nr > 7)
00079         return -1;
00080 
00081     if (dma_nr < 4)
00082         outb(dma_nr | 0x04, DMA1_REG_MASK);
00083     else
00084     if (dma_nr < 8)
00085         outb((dma_nr & 0x03) | 0x04, DMA2_REG_MASK);
00086 
00087     return 0;
00088 }

int dma_enable struct chip_s *  chip,
u8  dma_nr
 

Definition at line 62 of file dma.c.

00063 {
00064     if (dma_nr > 7)
00065         return -1;
00066 
00067     if (dma_nr < 4)
00068         outb(dma_nr, DMA1_REG_MASK);
00069     else
00070     if (dma_nr < 8)
00071         outb(dma_nr & 0x03, DMA2_REG_MASK);
00072 
00073     return 0;
00074 }

int __init dma_init void   ) 
 

Definition at line 239 of file dma.c.

References adi_register_chip(), and dma_chip.

Referenced by adi_chips_init().

00240 {
00241     adi_register_chip(&dma_chip);
00242 
00243     return 0;    
00244 }

Here is the call graph for this function:

int dma_lock struct chip_s *  chip  ) 
 

Definition at line 197 of file dma.c.

References flags.

00198 {
00199     spin_lock_irqsave(&chip->chip_lock, flags);
00200     
00201     return 0;
00202 }

int dma_put_channel struct chip_s *  chip,
u8  dma_nr
 

Definition at line 57 of file dma.c.

References dma_resource_desc, and put_free_resource().

Referenced by floppy_free_dma().

00058 {
00059     return put_free_resource(dma_resource_desc, (int)dma_nr);
00060 }

Here is the call graph for this function:

int dma_request_channel struct chip_s *  chip,
u8  dma_nr
 

Definition at line 52 of file dma.c.

References dma_resource_desc, and request_resource().

Referenced by floppy_set_dma().

00053 {
00054     return request_resource(dma_resource_desc, (int)dma_nr);
00055 }

Here is the call graph for this function:

int dma_set_addr struct chip_s *  chip,
u8  dma_nr,
u32  address
 

Definition at line 118 of file dma.c.

00119 {
00120     int shift = 0;
00121     u8 page = (u8)(address >> 16);
00122     u8 dma_page_addr;
00123     u8 dma_addr;
00124 
00125     switch(dma_nr) {
00126         case 0x00:
00127             dma_page_addr = DMA_PAGE_0;
00128             break;
00129 
00130         case 0x01:
00131             dma_page_addr = DMA_PAGE_1;
00132             break;
00133 
00134         case 0x02:
00135             dma_page_addr = DMA_PAGE_2;
00136             break;
00137 
00138         case 0x03:
00139             dma_page_addr = DMA_PAGE_3;
00140             break;
00141 
00142         case 0x05:
00143             dma_page_addr = DMA_PAGE_5;
00144             break;
00145 
00146         case 0x06:
00147             dma_page_addr = DMA_PAGE_6;
00148             break;
00149 
00150         case 0x07:
00151             dma_page_addr = DMA_PAGE_7;
00152             break;
00153             
00154         default:
00155             return -1;
00156     }
00157 
00158     if (dma_nr < 4) {
00159         dma_addr = ((dma_nr & 0x03) << 1);
00160     } else 
00161     if (dma_nr < 8) {
00162         page &= 0xfe;
00163         shift = 1;
00164         dma_addr = ((dma_nr & 0x03) << 2);
00165     } else
00166         return -1;
00167 
00168     outb(page, dma_page_addr);
00169     outb((address >> shift) & 0xff, dma_addr);
00170     outb((address >> (8 + shift)) & 0xff, dma_addr);    
00171 
00172     return 0;
00173 }

int dma_set_count struct chip_s *  chip,
u8  dma_nr,
u16  count
 

Definition at line 175 of file dma.c.

00176 {
00177     int shift = 0;
00178     u8 dma_count_addr;
00179     
00180     count--;
00181 
00182     if (dma_nr < 4) {
00183         dma_count_addr = ((dma_nr & 0x03) << 1) + 1;
00184     } else 
00185     if (dma_nr < 8) {
00186         shift = 1;
00187         dma_count_addr = ((dma_nr & 0x03) << 2) + 1;
00188     } else
00189         return -1;
00190 
00191     outb((count >> shift) & 0xff, dma_count_addr);
00192     outb((count >> (8 + shift)) & 0xff, dma_count_addr);    
00193     
00194     return 0;
00195 }

int dma_set_mode struct chip_s *  chip,
u8  dma_nr,
u8  mode
 

Definition at line 104 of file dma.c.

00105 {
00106     if (dma_nr > 7)
00107         return -1;
00108 
00109     if (dma_nr < 4)
00110         outb(dma_nr | mode, DMA1_REG_MODE);
00111     else
00112     if (dma_nr < 8)
00113         outb((dma_nr & 0x03) | mode, DMA2_REG_MODE);
00114 
00115     return 0;
00116 }

int dma_unlock struct chip_s *  chip  ) 
 

Definition at line 204 of file dma.c.

References flags.

00205 {
00206     spin_unlock_irqrestore(&chip->chip_lock, flags);
00207     
00208     return 0;
00209 }


Variable Documentation

struct chip_s dma_chip
 

Initial value:

 {
    .chip_name          = "dma",
    .chip_class         = CHIP_CLASS_DMA,
    .chip_vendor        = 0x8086,
    .chip_ops           = &dma_chip_ops,
    .chip_pm_ops        = NULL,
    .internal_ops       = &dma_internal_ops,
}

Definition at line 230 of file dma.c.

Referenced by dma_init(), floppy_free_dma(), floppy_set_dma(), and floppy_setup_DMA().

struct chip_ops_s dma_chip_ops
 

Initial value:

 {
    .init               = dma_chip_init,
    .release            = dma_chip_release
}

Definition at line 225 of file dma.c.

struct chip_dma_ops_s dma_internal_ops
 

Initial value:

 
{
    .dma_lock            = dma_lock,
    .dma_unlock          = dma_unlock,
    .dma_request_channel = dma_request_channel,
    .dma_put_channel     = dma_put_channel,
    .dma_enable          = dma_enable,
    .dma_disable         = dma_disable,
    .dma_clear_ff        = dma_clear_ff,
    .dma_set_addr        = dma_set_addr,
    .dma_set_mode        = dma_set_mode,
    .dma_set_count       = dma_set_count
}

Definition at line 211 of file dma.c.

struct resource_s dma_resource
 

Initial value:

 {
    .resource_name      = "DMA",
    .resource_bitmap    = dma_resource_bitmap,
    .resource_len       = 1,
    .resource_max       = DMA_MAX_CHANNEL
}

Definition at line 26 of file dma.c.

Referenced by dma_chip_init().

u32 dma_resource_bitmap[1]
 

Definition at line 24 of file dma.c.

int dma_resource_desc
 

Definition at line 33 of file dma.c.

Referenced by dma_chip_init(), dma_put_channel(), and dma_request_channel().

u32 flags
 

Definition at line 34 of file dma.c.

Referenced by adi_netdev_find_by_name(), adi_netdev_list_add(), adi_netdev_print_interfaces(), adi_print_resources(), adi_register_pci_driver(), adi_register_resource(), apm_function_call_full(), apm_function_call_simple(), arp_get_local_mac(), arp_get_neigh(), arp_recv(), arp_request_add(), arp_request_del(), arp_request_wake_up(), arp_resolve(), arp_timer_expire(), arp_timer_refresh(), btree_insert(), btree_search(), buddy_alloc_free(), buddy_alloc_print_units(), buddy_get_free_pages(), buddy_put_free_pages(), dma_lock(), dma_unlock(), do_task_exit(), fastirq_run_irq(), faults_init(), free_irq(), get_free_resource(), hash_entry_add(), hash_entry_del(), hash_entry_find(), idle_state_enter(), install_irq(), irqs_init(), net_layer_2_add_pack(), net_layer_2_recv_pack(), pcibus_add_bus(), pcibus_add_device(), pcibus_find_device_by_fn(), pcibus_find_device_by_id(), pcibus_irq_all_set(), pcibus_print_all(), put_free_resource(), queue_dequeue(), queue_empty(), queue_enqueue(), queue_free(), request_resource(), rtl_8029_send_frame(), sched_activate_task(), sched_add_task(), sched_deactivate_task(), schedule_task(), scheduler_print_tasks(), send_signal_to_task(), signal_dequeue(), timer_gettimeofday(), timer_settimeofday(), wait_list_add(), wait_list_del(), and wait_list_wake_up().

Dokumentacje wygenerowano programem Doxygen 1.4.2 dla projektu Agnix