00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <device.h> 00011 #include <tty.h> 00012 00017 struct tty *ttyAlloc(void) 00018 { 00019 irqmask ps; 00020 int i; 00021 00022 ps = disable(); 00023 for (i = 0; i < NTTY; ++i) 00024 { 00025 if (TTY_STATE_FREE == ttytab[i].state) 00026 { 00027 ttytab[i].state = TTY_STATE_ALLOC; 00028 restore(ps); 00029 return &ttytab[i]; 00030 } 00031 } 00032 restore(ps); 00033 return NULL; 00034 }