/*allocate memory*/ static void phci_hcd_mem_alloc( u32 size, struct isp1761_mem_addr *memptr, u32 flag) { u32 blk_size = size; u16 i; u32 nextblk1=0,nextblk4=0; u32 start = 0,end = 0; struct isp1761_mem_addr *memaddr = 0; memset(memptr,0,sizeof *memptr); pehci_print("phci_hcd_mem_alloc(size = %d)\n",size); if(blk_size==0) { memptr->phy_addr = 0; memptr->virt_addr = 0; memptr->blk_size = 0; memptr->num_alloc = 0; memptr->blk_num = 0; return; } /*end of the 1k blocks*/ nextblk1 = BLK_256_ + BLK_1024_; /*end of the 4k blocks*/ nextblk4 = nextblk1 + BLK_4096_; if(blk_size<=BLK_SIZE_256){ blk_size = BLK_SIZE_256; start = 0; end = BLK_256_; } else if(blk_size<=BLK_SIZE_1024){ blk_size = BLK_SIZE_1024; start = BLK_256_; end = start + BLK_1024_; } else if(blk_size > BLK_SIZE_1024){ blk_size = BLK_SIZE_4096; start = BLK_256_ + BLK_1024_; end = start + BLK_4096_; } for(i = start;i<end;i++){ memaddr = &memalloc[i]; if(!memaddr->used){ memaddr->used = 1; memptr->blk_num = i; memptr->blk_size = blk_size; memptr->phy_addr = memaddr->phy_addr; memptr->virt_addr = memptr->phy_addr; return; } } /*look for in the next block if memory is free*/ /*start from the first place of the next block*/ start = end; /*for 1k and 256 size request only 4k can be returned*/ end = nextblk4; for(i = start;i<end;i++){ memaddr = &memalloc[i]; if(!memaddr->used){ memaddr->used = 1; memptr->blk_num = i; memptr->blk_size = blk_size; memptr->phy_addr = memaddr->phy_addr; memptr->virt_addr = memptr->phy_addr; return; } } }
static void phci_hcd_mem_alloc(u32 size, struct isp1763_mem_addr *memptr, u32 flag) { u32 blk_size = size; u16 i; u32 nextblk1 = 0, nextblk4 = 0; u32 start = 0, end = 0; struct isp1763_mem_addr *memaddr = 0; memset(memptr, 0, sizeof *memptr); pehci_print("phci_hcd_mem_alloc(size = %d)\n", size); if (blk_size == 0) { memptr->phy_addr = 0; memptr->virt_addr = 0; memptr->blk_size = 0; memptr->num_alloc = 0; memptr->blk_num = 0; return; } /* */ nextblk1 = BLK_256_ + BLK_1024_; /* */ nextblk4 = nextblk1 + BLK_4096_; if (blk_size <= BLK_SIZE_256) { blk_size = BLK_SIZE_256; start = 0; end = BLK_256_; } else if (blk_size <= BLK_SIZE_1024) { blk_size = BLK_SIZE_1024; start = BLK_256_; end = start + BLK_1024_; } else if (blk_size > BLK_SIZE_1024) { blk_size = BLK_SIZE_4096; start = BLK_256_ + BLK_1024_; end = start + BLK_4096_; } for (i = start; i < end; i++) { memaddr = &memalloc[i]; if (!memaddr->used) { memaddr->used = 1; memptr->blk_num = i; memptr->used = 1; memptr->blk_size = blk_size; memptr->phy_addr = memaddr->phy_addr; memptr->virt_addr = memptr->phy_addr; return; } } /* */ /* */ start = end; /* */ end = nextblk4; for (i = start; i < end; i++) { memaddr = &memalloc[i]; if (!memaddr->used) { memaddr->used = 1; memptr->used = 1; memptr->blk_num = i; memptr->blk_size = blk_size; memptr->phy_addr = memaddr->phy_addr; memptr->virt_addr = memptr->phy_addr; return; } } }