当前位置: 首页>>代码示例>>C++>>正文


C++ page_offset函数代码示例

本文整理汇总了C++中page_offset函数的典型用法代码示例。如果您正苦于以下问题:C++ page_offset函数的具体用法?C++ page_offset怎么用?C++ page_offset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了page_offset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: receive

unsigned char receive(volatile unsigned char *buffer, unsigned char size)
{
	if (buffer == 0)
	{
		state = START;
		return 3;
	}
	else
	{
		switch (state)
		{
		case START:
			if (size == 3)
			{
				addr = (uint16_t)buffer[1] << 8 | (uint16_t)buffer[2];
				switch (buffer[0])
				{
				case 0x00:
					state = READ;
					break;
				case 0x01:
					state = WRITE;
					return SPM_PAGESIZE - page_offset(addr);
				case 0x02:
					state = BOOT;
					break;
				default:
					break;
				}
				return 0;
			}
			break;
		case WRITE:
			if(page_address != page_start(addr))
			{
				write_page();
				read_page(page_start(addr));
			}
			for (i = 0; i < size; i++)
			{
				page_buffer[page_offset(addr)] = buffer[i];
				addr++;
				page_dirty = 1;
			}
			return SPM_PAGESIZE - page_offset(addr);
		default:
			break;
		}
	}
	return 0;
}
开发者ID:ilduganov,项目名称:quadrotor,代码行数:51,代码来源:boot.c

示例2: mem_delmap

static void mem_delmap(int asid, md_addr_t addr, size_t length)
{
    ZTRACE_PRINT(INVALID_CORE, "mem_delmap: %d, %" PRIxPTR", length: %zd\n", asid, addr, length);

    assert(asid >= 0 && asid < num_address_spaces);

    /* Check alignment */
    if (page_offset(addr)) {
        fprintf(stderr, "mem_delmap: Address %" PRIxPTR" not aligned\n", addr);
        abort();
    }

    /* Remove every page in the range from page table */
    md_addr_t last_addr = page_round_up(addr + length);
    for (md_addr_t curr_addr = addr; (curr_addr <= last_addr) && curr_addr; curr_addr += PAGE_SIZE) {
        if (!mem_is_mapped(asid, curr_addr))
            continue; /* Attempting to remove something missing is ok */

        md_addr_t curr_vpn = curr_addr >> PAGE_SHIFT;
        page_tables[asid].erase(curr_vpn);

        page_count[asid]--;
        phys_page_count--;
    }
}
开发者ID:s-kanev,项目名称:XIOSim,代码行数:25,代码来源:memory.cpp

示例3: items

/* part of tail2extent. replace tail items with extent one. Content of tail
   items (@count bytes) being cut are copied already into
   pages. extent_writepage method is called to create extents corresponding to
   those pages */
static int replace(struct inode *inode, struct page **pages, unsigned nr_pages, int count)
{
	int result;
	unsigned i;
	STORE_COUNTERS;

	if (nr_pages == 0)
		return 0;

	assert("vs-596", pages[0]);

	/* cut copied items */
	result = cut_formatting_items(inode, page_offset(pages[0]), count);
	if (result)
		return result;

	CHECK_COUNTERS;

	/* put into tree replacement for just removed items: extent item, namely */
	for (i = 0; i < nr_pages; i++) {
		result = add_to_page_cache_lru(pages[i], inode->i_mapping,
					       pages[i]->index,
					       mapping_gfp_mask(inode->
								i_mapping));
		if (result)
			break;
		unlock_page(pages[i]);
		result = find_or_create_extent(pages[i]);
		if (result)
			break;
		SetPageUptodate(pages[i]);
	}
	return result;
}
开发者ID:mgross029,项目名称:android_kernel,代码行数:38,代码来源:tail_conversion.c

示例4: mlog_log_string

/********************************************************//**
Logs a write of a string to a file page buffered in the buffer pool.
Writes the corresponding log record to the mini-transaction log. */
UNIV_INTERN
void
mlog_log_string(
/*============*/
	byte*	ptr,	/*!< in: pointer written to */
	ulint	len,	/*!< in: string length */
	mtr_t*	mtr)	/*!< in: mini-transaction handle */
{
	byte*	log_ptr;

	ut_ad(ptr && mtr);
	ut_ad(len <= UNIV_PAGE_SIZE);

	log_ptr = mlog_open(mtr, 30);

	/* If no logging is requested, we may return now */
	if (log_ptr == NULL) {

		return;
	}

	log_ptr = mlog_write_initial_log_record_fast(ptr, MLOG_WRITE_STRING,
						     log_ptr, mtr);
	mach_write_to_2(log_ptr, page_offset(ptr));
	log_ptr += 2;

	mach_write_to_2(log_ptr, len);
	log_ptr += 2;

	mlog_close(mtr, log_ptr);

	mlog_catenate_string(mtr, ptr, len);
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:36,代码来源:mtr0log.c

示例5:

uint8_t cs4031_device::dma_read_byte(offs_t offset)
{
	if (m_dma_channel == -1)
		return 0xff;

	return m_space->read_byte(page_offset() + offset);
}
开发者ID:SailorSat,项目名称:cabmame,代码行数:7,代码来源:cs4031.cpp

示例6: romfs_readpage

static int
romfs_readpage(struct file *file, struct page * page)
{
	struct inode *inode = page->mapping->host;
	loff_t offset, avail, readlen;
	void *buf;
	int result = -EIO;

	page_cache_get(page);
	lock_kernel();
	buf = kmap(page);
	if (!buf)
		goto err_out;

	/* 32 bit warning -- but not for us :) */
	offset = page_offset(page);
	if (offset < i_size_read(inode)) {
		avail = inode->i_size-offset;
		readlen = min_t(unsigned long, avail, PAGE_SIZE);
		if (romfs_copyfrom(inode, buf, ROMFS_I(inode)->i_dataoffset+offset, readlen) == readlen) {
			if (readlen < PAGE_SIZE) {
				memset(buf + readlen,0,PAGE_SIZE-readlen);
			}
			SetPageUptodate(page);
			result = 0;
		}
	}
开发者ID:Tigrouzen,项目名称:k1099,代码行数:27,代码来源:inode.c

示例7: mem_newmap

/* We allocate physical pages to virtual pages on a
 * first-come-first-serve basis. Seems like linux frowns upon
 * page coloring, so should be reasonably accurate. */
static md_paddr_t next_ppn_to_allocate = 0x00000100; /* arbitrary starting point; */
static void mem_newmap(int asid, md_addr_t addr, size_t length)
{
    ZTRACE_PRINT(INVALID_CORE, "mem_newmap: %d, %" PRIxPTR", length: %zd\n", asid, addr, length);

    assert(asid >= 0 && asid < num_address_spaces);
    assert(addr != 0); // Mapping 0-th page might cause hell to break loose, don't do it.

    /* Check alignment */
    if (page_offset(addr)) {
        fprintf(stderr, "mem_newmap: Address %" PRIxPTR" not aligned\n", addr);
        abort();
    }

    /* Add every page in the range to page table */
    md_addr_t last_addr = page_round_up(addr + length);
    for (md_addr_t curr_addr = addr; (curr_addr <= last_addr) && curr_addr; curr_addr += PAGE_SIZE) {
        if (mem_is_mapped(asid, curr_addr))
            continue; /* Attempting to double-map is ok */

        md_addr_t curr_vpn = curr_addr >> PAGE_SHIFT;
        page_tables[asid][curr_vpn] = next_ppn_to_allocate;

        next_ppn_to_allocate++;

        page_count[asid]++;
        phys_page_count++;
    }
}
开发者ID:s-kanev,项目名称:XIOSim,代码行数:32,代码来源:memory.cpp

示例8: v9fs_vfs_readpage

static int v9fs_vfs_readpage(struct file *filp, struct page *page)
{
	int retval;
	loff_t offset;
	char *buffer;
	struct p9_fid *fid;

	P9_DPRINTK(P9_DEBUG_VFS, "\n");
	fid = filp->private_data;
	buffer = kmap(page);
	offset = page_offset(page);

	retval = p9_client_readn(fid, buffer, offset, PAGE_CACHE_SIZE);
	if (retval < 0)
		goto done;

	memset(buffer + retval, 0, PAGE_CACHE_SIZE - retval);
	flush_dcache_page(page);
	SetPageUptodate(page);
	retval = 0;

done:
	kunmap(page);
	unlock_page(page);
	return retval;
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:26,代码来源:vfs_addr.c

示例9: nfs_vm_page_mkwrite

static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
{
	struct page *page = vmf->page;
	struct file *filp = vma->vm_file;
	struct dentry *dentry = filp->f_path.dentry;
	unsigned pagelen;
	int ret = -EINVAL;
	struct address_space *mapping;

	dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n",
		dentry->d_parent->d_name.name, dentry->d_name.name,
		filp->f_mapping->host->i_ino,
		(long long)page_offset(page));

	lock_page(page);
	mapping = page->mapping;
	if (mapping != dentry->d_inode->i_mapping)
		goto out_unlock;

	ret = 0;
	pagelen = nfs_page_length(page);
	if (pagelen == 0)
		goto out_unlock;

	ret = nfs_flush_incompatible(filp, page);
	if (ret != 0)
		goto out_unlock;

	ret = nfs_updatepage(filp, page, 0, pagelen);
out_unlock:
	if (!ret)
		return VM_FAULT_LOCKED;
	unlock_page(page);
	return VM_FAULT_SIGBUS;
}
开发者ID:deepikateriar,项目名称:Onlive-Source-Backup,代码行数:35,代码来源:file.c

示例10: mlog_write_dulint

/********************************************************//**
Writes 8 bytes to a file page buffered in the buffer pool.
Writes the corresponding log record to the mini-transaction log. */
UNIV_INTERN
void
mlog_write_dulint(
/*==============*/
	byte*	ptr,	/*!< in: pointer where to write */
	dulint	val,	/*!< in: value to write */
	mtr_t*	mtr)	/*!< in: mini-transaction handle */
{
	byte*	log_ptr;

	ut_ad(ptr && mtr);

	mach_write_to_8(ptr, val);

	log_ptr = mlog_open(mtr, 11 + 2 + 9);

	/* If no logging is requested, we may return now */
	if (log_ptr == NULL) {

		return;
	}

	log_ptr = mlog_write_initial_log_record_fast(ptr, MLOG_8BYTES,
						     log_ptr, mtr);

	mach_write_to_2(log_ptr, page_offset(ptr));
	log_ptr += 2;

	log_ptr += mach_dulint_write_compressed(log_ptr, val);

	mlog_close(mtr, log_ptr);
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:35,代码来源:mtr0log.c

示例11: f2fs_vm_page_mkwrite

static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
						struct vm_fault *vmf)
{
	struct page *page = vmf->page;
	struct inode *inode = file_inode(vma->vm_file);
	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
	struct dnode_of_data dn;
	int err;

	f2fs_balance_fs(sbi);

	vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);

	f2fs_bug_on(sbi, f2fs_has_inline_data(inode));

	/* block allocation */
	f2fs_lock_op(sbi);
	set_new_dnode(&dn, inode, NULL, NULL, 0);
	err = f2fs_reserve_block(&dn, page->index);
	if (err) {
		f2fs_unlock_op(sbi);
		goto out;
	}
	f2fs_put_dnode(&dn);
	f2fs_unlock_op(sbi);

	file_update_time(vma->vm_file);
	lock_page(page);
	if (unlikely(page->mapping != inode->i_mapping ||
			page_offset(page) > i_size_read(inode) ||
			!PageUptodate(page))) {
		unlock_page(page);
		err = -EFAULT;
		goto out;
	}

	/*
	 * check to see if the page is mapped already (no holes)
	 */
	if (PageMappedToDisk(page))
		goto mapped;

	/* page is wholly or partially inside EOF */
	if (((page->index + 1) << PAGE_CACHE_SHIFT) > i_size_read(inode)) {
		unsigned offset;
		offset = i_size_read(inode) & ~PAGE_CACHE_MASK;
		zero_user_segment(page, offset, PAGE_CACHE_SIZE);
	}
	set_page_dirty(page);
	SetPageUptodate(page);

	trace_f2fs_vm_page_mkwrite(page, DATA);
mapped:
	/* fill the page */
	f2fs_wait_on_page_writeback(page, DATA);
	/* if gced page is attached, don't write to cold segment */
	clear_cold_data(page);
out:
	return block_page_mkwrite_return(err);
}
开发者ID:handelxh,项目名称:ONEPLUS2RAZOR,代码行数:60,代码来源:file.c

示例12: me2fsSetLink

/*
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
	Function	:me2fsSetLink
	Input		:struct inode *dir
				 < vfs inode >
				 struct ext2_dir_entry *dent
				 < directory entry to set link >
				 struct page *page
				 < directory page cache >
				 struct inode *inode
				 < vfs inode to be linked >
				 int update_times
				 < flag to update times >
	Output		:void
	Return		:void

	Description	:set link
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*/
void me2fsSetLink( struct inode *dir,
				   struct ext2_dir_entry *dent,
				   struct page *page,
				   struct inode *inode,
				   int update_times )
{
	loff_t		pos;
	unsigned	len;
	int			err;

	pos = page_offset( page ) + ( ( char* )dent - ( char* )page_address( page ) );
	len = le16_to_cpu( dent->rec_len );

	lock_page( page );
	err = prepareWriteBlock( page, pos, len );
	dent->inode = cpu_to_le32( inode->i_ino );
	setDirEntryType( dent, inode );
	err = commitBlockWrite( page, pos, len );
	me2fsPutDirPageCache( page );

	if( update_times )
	{
		dir->i_mtime = CURRENT_TIME_SEC;
		dir->i_ctime = dir->i_mtime;
	}

	ME2FS_I( dir )->i_flags &= ~EXT2_BTREE_FL;

	mark_inode_dirty( dir );


}
开发者ID:KnightSch,项目名称:Learning-Ext2-Filesystem,代码行数:51,代码来源:me2fs_dir.c

示例13: ftfs_bstore_scan_one_page

int ftfs_bstore_scan_one_page(DB *data_db, struct ftfs_meta_key *meta_key,
                              DB_TXN *txn, struct page *page)
{
	int ret;
	uint64_t block_num;
	size_t block_offset;
	loff_t offset;
	size_t len;
	struct ftfs_data_key *data_key;
	void *buf, *value_buf;
	DBT key_dbt, value_dbt;
	DBC *cursor;

	offset = page_offset(page);
	block_num = block_get_num_by_position(offset);
	data_key = kmalloc(DATA_KEY_MAX_LEN, GFP_KERNEL);
	if (!data_key)
		return -ENOMEM;
	value_buf = kmalloc(FTFS_BSTORE_BLOCKSIZE, GFP_KERNEL);
	if (!value_buf) {
		ret = -ENOMEM;
		goto out1;
	}
	copy_data_key_from_meta_key(data_key, meta_key, block_num);
	dbt_init(&key_dbt, data_key, DATA_KEY_MAX_LEN);
	dbt_init(&value_dbt, value_buf, FTFS_BSTORE_BLOCKSIZE);
	len = PAGE_CACHE_SIZE;
	buf = kmap(page);
	ret = data_db->cursor(data_db, txn, &cursor, DB_CURSOR_FLAGS);
	if (ret)
		goto out2;
	ret = cursor->c_get(cursor, &key_dbt, &value_dbt, DB_SET_RANGE);
	while (len > 0 && ret) {
		ssize_t read_size;
		block_num = block_get_num_by_position(offset);
		block_offset = block_get_offset_by_position(offset);
		read_size = min(len, (FTFS_BSTORE_BLOCKSIZE - block_offset));

		if (data_key->circle_id == meta_key->circle_id &&
		    !strcmp(data_key->path, meta_key->path) &&
		    data_key->block_num == block_num) {
			memcpy(buf, value_buf, read_size);
			ret = cursor->c_get(cursor, &key_dbt, &value_dbt, DB_NEXT);
		} else
			memset(buf, 0, read_size);

		buf += read_size;
		offset += read_size;
		len -= read_size;
	}

	cursor->c_close(cursor);
out2:
	kunmap(page);
out1:
	kfree(value_buf);
	data_key_free(data_key);
	return ret;
}
开发者ID:tonytcl,项目名称:betrfs,代码行数:59,代码来源:ftfs_bstore.c

示例14: virt_to_phys

static inline u32_t virt_to_phys (u32_t virt_addr, u32_t *pg_dir)
{
    u32_t *pg_table = (u32_t *) pg_dir [pg_dir_index (virt_addr)];
    u32_t page = pg_table [ pg_table_index ( virt_addr) ];

    return (page + page_offset ( virt_addr));

}
开发者ID:apurvam,项目名称:Nodes,代码行数:8,代码来源:init.c

示例15: me2fsDeleteDirEntry

/*
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
	Function	:me2fsDeleteDirEntry
	Input		:struct ext2_dir_entry *dir
				 < directory entry to delete >
				 struct page *page
				 < page cache the directory belongs to >
	Output		:void
	Return		:void

	Description	:delete a directory entry
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
*/
int me2fsDeleteDirEntry( struct ext2_dir_entry *dir, struct page *page )
{
	struct inode			*inode;
	char					*start;
	unsigned				from;
	unsigned				to;
	loff_t					pos;
	struct ext2_dir_entry	*pde;
	struct ext2_dir_entry	*dent;
	int						err;

	inode	= page->mapping->host;
	start	= page_address( page );
	from	= ( ( char* )dir - start ) & ~( inode->i_sb->s_blocksize - 1 );
	to		= ( ( char* )dir - start ) + le16_to_cpu( dir->rec_len );

	pde		= NULL;
	dent	= ( struct ext2_dir_entry* )( start + from );

	while( ( char* )dent < ( char* )dir )
	{
		if( dent->rec_len == 0 )
		{
			ME2FS_ERROR( "<ME2FS>%s:zero-length directory entry\n",
						 __func__ );
			err = -EIO;
			goto out;
		}

		pde = dent;
		dent = ( struct ext2_dir_entry* )( ( char* )dent
										   + le16_to_cpu( dent->rec_len ) );
	}

	if( pde )
	{
		from = ( char* )pde - start;
	}

	pos = page_offset( page ) + from;
	lock_page( page );
	err = prepareWriteBlock( page, pos, to - from );
	if( pde )
	{
		pde->rec_len = le16_to_cpu( to - from );
	}
	dir->inode					= 0;
	err							= commitBlockWrite( page, pos, to - from );
	inode->i_mtime				= CURRENT_TIME_SEC;
	inode->i_ctime				= inode->i_mtime;
	ME2FS_I( inode )->i_flags	&= ~EXT2_BTREE_FL;

	mark_inode_dirty( inode );

out:
	me2fsPutDirPageCache( page );
	return( err );
}
开发者ID:KnightSch,项目名称:Learning-Ext2-Filesystem,代码行数:71,代码来源:me2fs_dir.c


注:本文中的page_offset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。