本文整理汇总了C++中env_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ env_destroy函数的具体用法?C++ env_destroy怎么用?C++ env_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了env_destroy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
// if (tf->tf_trapno == 14)
// page_fault_handler(tf);
cprintf("TRAP NO : %d\n", tf->tf_trapno);
int r;
switch (tf->tf_trapno) {
case T_PGFLT :
page_fault_handler(tf);
break;
case T_BRKPT :
monitor(tf);
break;
case T_DEBUG :
monitor(tf);
break;
case T_SYSCALL :
r = syscall(tf->tf_regs.reg_eax, tf->tf_regs.reg_edx, tf->tf_regs.reg_ecx, tf->tf_regs.reg_ebx, tf->tf_regs.reg_edi, tf->tf_regs.reg_esi);
tf->tf_regs.reg_eax = r;
break;
default :
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
}
开发者ID:plutoshe,项目名称:JOS_OperatingSystemlab,代码行数:34,代码来源:trap.c
示例2: sys_env_swap
static int
sys_env_swap(envid_t envid)
{
struct Env* e;
if (envid2env(envid, &e, 1) < 0) {
return -E_BAD_ENV;
}
if (e->env_status != ENV_NOT_RUNNABLE) {
return -E_BAD_ENV;
}
struct Env temp = *curenv;
curenv->env_tf = e->env_tf;
curenv->env_pgdir = e->env_pgdir;
lcr3(PADDR(curenv->env_pgdir));
// Need to do this to free old pgdir
e->env_pgdir = temp.env_pgdir;
e->env_tf = temp.env_tf;
env_destroy(e);
return 0;
}
开发者ID:bosswissam,项目名称:djos,代码行数:25,代码来源:syscall.c
示例3: main
void main(void)
{
UCHAR cmd[0x8000];
BOOL exitflag;
log_init();
hello();
log(greeting);
log("DosLogWrite address: %x\n", DosLogWrite);
exitflag=FALSE;
// Ok. Here we just in endless loop. Except for EXIT command.
// create the global env. array
env_create();
while (!exitflag)
{
showpath();
read_cmd (cmd);
exitflag = parse_cmd (cmd);
}
// destroy the global env. array
env_destroy();
exit(0);
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:30,代码来源:minicmd.c
示例4: env_create
env_h env_create( const env_h init_env )
{
unsigned u ;
env_s *ep ;
unsigned max_vars ;
if ( init_env == ENV_NULL )
max_vars = INITIAL_VARS ;
else
max_vars = init_env->n_vars + 5 ;
ep = alloc_env( max_vars ) ;
if ( ep == NULL )
{
env_errno = ENV_ENOMEM ;
return( ENV_NULL ) ;
}
if ( init_env == ENV_NULL )
return( ep ) ;
for ( u = 0, ep->n_vars = 0 ; u < init_env->n_vars ; u++, ep->n_vars++ )
{
ep->vars[ ep->n_vars ] = new_string( init_env->vars[ u ] ) ;
if ( ep->vars[ ep->n_vars ] == NULL )
{
env_destroy( ep ) ;
env_errno = ENV_ENOMEM ;
return( ENV_NULL ) ;
}
}
return( ep ) ;
}
开发者ID:HappyDg,项目名称:Network-OS,代码行数:33,代码来源:m_env.c
示例5: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
uint32_t fault_va;
if(tf->tf_trapno >= 0 && tf->tf_trapno < 255)
{
switch(tf->tf_trapno)
{
case T_PGFLT://page fault
page_fault_handler(tf);
return;
case T_BRKPT:
monitor(tf);
return;
case T_SYSCALL:
//fault_va = rcr2();
//cprintf("[%08x] user fault va %08x ip %08x\n",curenv->env_id, fault_va, tf->tf_eip);
//cprintf("T_SYSCALL\n");
// print_trapframe(tf);
tf->tf_regs.reg_eax = syscall(tf->tf_regs.reg_eax, tf->tf_regs.reg_edx, tf->tf_regs.reg_ecx,tf->tf_regs.reg_ebx, tf->tf_regs.reg_edi, tf->tf_regs.reg_esi);
return;
}
}
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Handle clock interrupts. Don't forget to acknowledge the
// interrupt using lapic_eoi() before calling the scheduler!
// LAB 4: Your code here.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_TIMER) {
lapic_eoi();
sched_yield();
return;
}
// Handle keyboard and serial interrupts.
// LAB 5: Your code here.
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:chenkexin,项目名称:jos,代码行数:60,代码来源:trap.c
示例6: fill_entries
static int fill_entries(int ac, char **av, char **entries)
{
int i;
int j;
int flag;
i = 0;
j = 0;
flag = 0;
while (++i < ac)
{
if (!ft_strchr(av[i], '='))
{
if (flag)
break ;
else
continue ;
}
flag = 1;
if (!(entries[j++] = ft_strdup(av[i])))
{
env_destroy(&entries);
return (-1);
}
}
return (0);
}
开发者ID:sbenning42,项目名称:42,代码行数:27,代码来源:getentries.c
示例7: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
// Handle clock and serial interrupts.
// LAB 4: Your code here.
switch(tf->tf_trapno){
case T_SYSCALL:
tf->tf_regs.reg_eax = syscall(tf->tf_regs.reg_eax,
tf->tf_regs.reg_edx,
tf->tf_regs.reg_ecx,
tf->tf_regs.reg_ebx,
tf->tf_regs.reg_edi,
tf->tf_regs.reg_esi);
return ;
case T_PGFLT:
page_fault_handler(tf);
return ;
case T_BRKPT:
monitor(tf);
return ;
case IRQ_OFFSET + IRQ_TIMER:
sched_yield();
return ;
}
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:Hzwcode,项目名称:MIT-JOS,代码行数:35,代码来源:trap.c
示例8: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
switch(tf->tf_trapno)
{
case T_PGFLT: page_fault_handler(tf);
return;
case T_BRKPT: monitor(tf);
return;
case T_SYSCALL:
tf->tf_regs.reg_rax = syscall(tf->tf_regs.reg_rax,tf->tf_regs.reg_rdx,tf->tf_regs.reg_rcx,tf->tf_regs.reg_rbx, tf->tf_regs.reg_rdi, tf->tf_regs.reg_rsi);
return;
}
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:GeneralYun,项目名称:MIT-JOS-64bit-CSE506,代码行数:25,代码来源:trap.c
示例9: env_make
env_h env_make( char **env_strings )
{
env_s *ep ;
char **pp ;
for ( pp = env_strings ; *pp ; pp++ ) ;
ep = alloc_env( (unsigned) (pp-env_strings) ) ;
if ( ep == NULL )
{
env_errno = ENV_ENOMEM ;
return( ENV_NULL ) ;
}
for ( pp = env_strings ; *pp ; pp++ )
{
char *p = new_string( *pp ) ;
if ( p == NULL )
{
env_destroy( ep ) ;
env_errno = ENV_ENOMEM ;
return( ENV_NULL ) ;
}
ep->vars[ ep->n_vars++ ] = p ;
}
return( ep ) ;
}
开发者ID:HappyDg,项目名称:Network-OS,代码行数:28,代码来源:m_env.c
示例10: nvm_set_parameter
int nvm_set_parameter(const char *key, const char *value)
{
int env_valid = 0;
int isEnv1Bad = -1;
int isEnv2Bad = -1;
int opt_sts = CMM_SUCCESS;
env_t *env_ptr = NULL;
isEnv1Bad = check_block("/dev/mtd2", 0);
isEnv2Bad = check_block("/dev/mtd2", CFG_ENV_SIZE);
if( -1 == isEnv1Bad )
{
printf(" ERROR: check env block 1 failed\n");
return CMM_FAILED;
}
if( -1 == isEnv2Bad )
{
printf(" ERROR: check env block 2 failed\n");
return CMM_FAILED;
}
/* either env1 or env2 is bad block, we do not permit set operation */
if( ( isEnv1Bad != 0 ) || ( isEnv2Bad != 0 ) )
{
printf(" ERROR: env is broken\n");
return CMM_FAILED;
}
/* Get NVM */
env_ptr = env_init(&env_valid);
if( NULL == env_ptr )
{
printf(" ERROR: read env failed\n");
return CMM_FAILED;
}
/* modify ethaddr */
__do_env_set_parameter(env_ptr, key, value);
/* update env crc */
__env_crc_update(env_ptr);
/* save env to flash */
if( CMM_SUCCESS != __save_env(env_ptr, env_valid) )
{
printf(" ERROR: save env failed\n\n");
opt_sts = CMM_FAILED;
}
else
{
opt_sts = CMM_SUCCESS;
}
/* free env_ptr malloced by function env_init() */
env_destroy(env_ptr);
return opt_sts;
}
开发者ID:Undrizzle,项目名称:apps,代码行数:59,代码来源:nvm-utils.c
示例11: setup_environ
status_e setup_environ( struct service_config *scp, struct service_config *def )
{
struct environment *ep = SC_ENV( scp ) ;
if ( ! SC_SPECIFIED( scp, A_PASSENV ) )
{
if ( ! SC_SPECIFIED( def, A_PASSENV ) )
{
if ( ! SC_SPECIFIED( scp, A_ENV ) )
{
ep->env_type = STD_ENV ;
ep->env_handle = std_env ;
return( OK ) ;
}
else
return(
make_env_with_strings( ep, std_env, SC_ENV_VAR_DEFS(scp) ) ) ;
}
else /* SC_SPECIFIED( def, A_PASSENV ) */
{
struct environment *dep = SC_ENV( def ) ;
if ( dep->env_type == NO_ENV &&
make_env_from_vars( dep, std_env,
SC_PASS_ENV_VARS(def) ) == FAILED )
return( FAILED ) ;
if ( ! SC_SPECIFIED( scp, A_ENV ) )
{
ep->env_type = DEF_ENV ;
ep->env_handle = dep->env_handle ;
return( OK ) ;
}
else
return( make_env_with_strings( ep,
dep->env_handle, SC_ENV_VAR_DEFS(scp) ) ) ;
}
}
else /* SC_SPECIFIED( scp, A_PASSENV ) */
{
if ( make_env_from_vars( ep, std_env, SC_PASS_ENV_VARS(scp) ) == FAILED )
return( FAILED ) ;
if ( ! SC_SPECIFIED( scp, A_ENV ) )
return( OK ) ;
else
{
if ( update_env_with_strings(
ep->env_handle, SC_ENV_VAR_DEFS(scp) ) == FAILED )
{
env_destroy( ep->env_handle ) ;
return( FAILED ) ;
}
return( OK ) ;
}
}
}
开发者ID:HappyDg,项目名称:Network-OS,代码行数:57,代码来源:env.c
示例12: user_mem_assert
//
// Checks that environment 'env' is allowed to access the range
// of memory [va, va+len) with permissions 'perm | PTE_U | PTE_P'.
// If it can, then the function simply returns.
// If it cannot, 'env' is destroyed and, if env is the current
// environment, this function will not return.
//
void
user_mem_assert(struct Env *env, const void *va, size_t len, int perm)
{
if (user_mem_check(env, va, len, perm | PTE_U) < 0) {
cprintf("[%08x] user_mem_check assertion failure for "
"va %08x\n", env->env_id, user_mem_check_addr);
env_destroy(env); // may not return
}
}
开发者ID:taylorr7732,项目名称:os_dev_tcr,代码行数:16,代码来源:pmap.c
示例13: page_fault_handler
void
page_fault_handler(struct Trapframe *tf)
{
uint32_t fault_va;
// Read processor's CR2 register to find the faulting address
fault_va = rcr2();
cprintf("fault_va: %x\n", fault_va);
// Handle kernel-mode page faults.
// LAB 3: Your code here.
if ((tf->tf_cs&3) == 0) {
panic("Kernel page fault!");
}
// We've already handled kernel-mode exceptions, so if we get here,
// the page fault happened in user mode.
// Call the environment's page fault upcall, if one exists. Set up a
// page fault stack frame on the user exception stack (below
// UXSTACKTOP), then branch to curenv->env_pgfault_upcall.
if (curenv->env_pgfault_upcall) {
//
// The page fault upcall might cause another page fault, in which case
// we branch to the page fault upcall recursively, pushing another
// page fault stack frame on top of the user exception stack.
//
// The trap handler needs one word of scratch space at the top of the
// trap-time stack in order to return. In the non-recursive case, we
// don't have to worry about this because the top of the regular user
// stack is free. In the recursive case, this means we have to leave
// an extra word between the current top of the exception stack and
// the new stack frame because the exception stack _is_ the trap-time
// stack.
//
// If there's no page fault upcall, the environment didn't allocate a
// page for its exception stack or can't write to it, or the exception
// stack overflows, then destroy the environment that caused the fault.
// Note that the grade script assumes you will first check for the page
// fault upcall and print the "user fault va" message below if there is
// none. The remaining three checks can be combined into a single test.
//
// Hints:
// user_mem_assert() and env_run() are useful here.
// To change what the user environment runs, modify 'curenv->env_tf'
// (the 'tf' variable points at 'curenv->env_tf').
// LAB 4: Your code here.
}
// Destroy the environment that caused the fault.
cprintf("[%08x] user fault va %08x ip %08x\n",
curenv->env_id, fault_va, tf->tf_eip);
print_trapframe(tf);
env_destroy(curenv);
}
开发者ID:1060351485,项目名称:jos,代码行数:57,代码来源:trap.c
示例14: nvm_dump
void nvm_dump(void)
{
int env_valid = 0;
int isEnv1Bad = -1;
int isEnv2Bad = -1;
struct mtd_info_user info;
env_t *env_ptr = NULL;
if( CMM_SUCCESS != get_mtd_info("/dev/mtd2", &info) )
{
printf(" ERROR: can not get mtd info\n");
return;
}
isEnv1Bad = check_block("/dev/mtd2", 0);
isEnv2Bad = check_block("/dev/mtd2", CFG_ENV_SIZE);
if( -1 == isEnv1Bad )
{
printf(" ERROR: check env block 1 failed\n");
return;
}
if( -1 == isEnv2Bad )
{
printf(" ERROR: check env block 2 failed\n");
return;
}
if( ( isEnv1Bad != 0 ) || ( isEnv2Bad != 0 ) )
{
printf(" ERROR: env is broken\n");
return;
}
env_ptr = env_init(&env_valid);
if( NULL == env_ptr )
{
printf(" ERROR: read env failed\n");
return;
}
printf("nvm device name: mtd2\n");
printf("device type: %d\n", info.type);
printf("nvm total size: %d KiB\n", info.size/1024);
printf("block size: %d KiB\n", info.erasesize/1024);
printf("page size: %d KiB\n", info.writesize/1024);
printf("oob size: %d bytes\n", info.oobsize);
printf("bad blocks: 0\n");
printf("env config size: %d KiB\n", CFG_ENV_SIZE/1024);
printf("env valid: %d\n", env_valid);
__debug_printf_env(env_ptr);
env_destroy(env_ptr);
}
开发者ID:Undrizzle,项目名称:apps,代码行数:57,代码来源:nvm-utils.c
示例15: trap_dispatch
static void
trap_dispatch(struct Trapframe *tf)
{
// Handle processor exceptions.
// LAB 3: Your code here.
// Handle spurious interrupts
// The hardware sometimes raises these because of noise on the
// IRQ line or other reasons. We don't care.
if (tf->tf_trapno == IRQ_OFFSET + IRQ_SPURIOUS) {
cprintf("Spurious interrupt on irq 7\n");
print_trapframe(tf);
return;
}
// Handle clock interrupts. Don't forget to acknowledge the
// interrupt using lapic_eoi() before calling the scheduler!
// LAB 4: Your code here.
if (tf ->tf_trapno == IRQ_OFFSET + IRQ_TIMER) {
lapic_eoi();
sched_yield();
return;
}
// Unexpected trap: The user process or the kernel has a bug.
// if (tf->tf_trapno == 14)
// page_fault_handler(tf);
// cprintf("TRAP NO : %d\n", tf->tf_trapno);
int r;
switch (tf->tf_trapno) {
case T_PGFLT :
page_fault_handler(tf);
break;
case T_BRKPT :
monitor(tf);
break;
case T_DEBUG :
monitor(tf);
break;
case T_SYSCALL :
r = syscall(tf->tf_regs.reg_eax, tf->tf_regs.reg_edx, tf->tf_regs.reg_ecx, tf->tf_regs.reg_ebx, tf->tf_regs.reg_edi, tf->tf_regs.reg_esi);
tf->tf_regs.reg_eax = r;
break;
default :
// Unexpected trap: The user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
}
开发者ID:plutoshe,项目名称:JOS_OperatingSystemlab,代码行数:55,代码来源:trap.c
示例16: sys_env_destroy
// Destroy a given environment (possibly the currently running environment).
//
// Returns 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
static int
sys_env_destroy(envid_t envid)
{
int r;
struct Env *e;
if ((r = envid2env(envid, &e, 1)) < 0)
return r;
env_destroy(e);
return 0;
}
开发者ID:Insecurity-plan15,项目名称:JOS-Microkernel,代码行数:16,代码来源:syscall.c
示例17: malloc
BDNProgram *bd_alpha_convert(BDNProgram *prog)
{
BDNProgram *nprog = malloc(sizeof(BDNProgram));
bd_nprogram_init(nprog);
Vector *vec;
BDNExprDef *def;
int i;
Env *env = env_new();
// set primitive labels to env
PrimSig *sig;
for(i = 0; i < primsigs->length; i++){
sig = vector_get(primsigs, i);
env_set(env, sig->name, sig->lbl);
}
// set toplevel names to env
vec = prog->defs;
for(i = 0; i < vec->length; i++){
def = vector_get(vec, i);
env_set(env, def->ident->name, bd_generate_toplevel_lbl(def->ident->name));
}
// convert defs
vec = prog->defs;
for(i = 0; i < vec->length; i++){
def = vector_get(vec, i);
vector_add(nprog->defs,
bd_nexpr_def(
bd_expr_ident(find_alt_name(env, def->ident->name), bd_type_clone(def->ident->type)),
bd_alpha(env, def->body)
));
}
// convert maindef
def = prog->maindef;
nprog->maindef = bd_nexpr_def(
bd_expr_ident(bd_generate_toplevel_lbl(def->ident->name), bd_type_clone(def->ident->type)),
bd_alpha(env, def->body)
);
// destroy
vec = prog->defs;
for(i = 0; i < vec->length; i++){
def = vector_get(vec, i);
free(env_get(env, def->ident->name));
}
env_destroy(env);
bd_nprogram_destroy(prog);
return nprog;
}
开发者ID:jou4,项目名称:bodhi,代码行数:53,代码来源:alpha.c
示例18: sys_env_destroy
// Destroy a given environment (possibly the currently running environment).
//
// Returns 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
static int
sys_env_destroy(envid_t envid, int retcode)
{
int r;
struct Env *e;
if ((r = envid2env(envid, &e, 1)) < 0)
return r;
e->env_retcode = retcode;
env_destroy(e);
return 0;
}
开发者ID:bdmalab,项目名称:6.828,代码行数:18,代码来源:syscall.c
示例19: trap
void
trap(struct Trapframe *tf)
{
int ret;
// Handle processor exceptions
// Your code here.
switch(tf->tf_trapno)
{
case T_BRKPT:
while(1)
monitor(NULL);
break;
case T_PGFLT:
page_fault_handler(tf);
tf->tf_eflags |= FL_IF;
//env_pop_tf(tf);
memcpy(&curenv->env_tf, tf, sizeof(*tf));
env_run(curenv);
return;
case T_SYSCALL:
ret = syscall(tf->tf_eax, tf->tf_edx, tf->tf_ecx, tf->tf_ebx,
tf->tf_edi, tf->tf_esi);
tf->tf_eax = ret;
tf->tf_eflags |= FL_IF;
// env_pop_tf(tf);
memcpy(&curenv->env_tf, tf, sizeof(*tf));
env_run(curenv);
case IRQ_OFFSET:
sched_yield();
break;
case IRQ_KBD:
kbd_intr();
memcpy(&curenv->env_tf, tf, sizeof(*tf));
env_run(curenv);
break;
default:
break;
}
// the user process or the kernel has a bug.
print_trapframe(tf);
if (tf->tf_cs == GD_KT)
panic("unhandled trap in kernel");
else {
env_destroy(curenv);
return;
}
}
开发者ID:BGCX262,项目名称:zt-jos-svn-to-git,代码行数:49,代码来源:trap.c
示例20: sys_env_destroy
// Destroy a given environment (possibly the currently running environment).
//
// Returns 0 on success, < 0 on error. Errors are:
// -E_BAD_ENV if environment envid doesn't currently exist,
// or the caller doesn't have permission to change envid.
static int
sys_env_destroy(envid_t envid)
{
int r;
struct Env *e;
if ((r = envid2env(envid, &e, 1)) < 0)
return r;
if (e == curenv)
cprintf("[%08x] exiting gracefully\n", curenv->env_id);
else
cprintf("[%08x] destroying %08x\n", curenv->env_id, e->env_id);
env_destroy(e);
return 0;
}
开发者ID:rinascere,项目名称:Jos,代码行数:20,代码来源:syscall.c
注:本文中的env_destroy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论