Esempio n. 1
0
int
afs_sgidaemon(void)
{
    int s;
    struct dcache *tdc;

    if (afs_sgibklock == NULL) {
	SV_INIT(&afs_sgibksync, "bksync", 0, 0);
	SV_INIT(&afs_sgibkwait, "bkwait", 0, 0);
	SPINLOCK_INIT(&afs_sgibklock, "bklock");
    }
    s = SPLOCK(afs_sgibklock);
    for (;;) {
	/* wait for something to do */
	SP_WAIT(afs_sgibklock, s, &afs_sgibksync, PINOD);
	osi_Assert(afs_sgibklist);

	/* XX will probably need to generalize to real list someday */
	s = SPLOCK(afs_sgibklock);
	while (afs_sgibklist) {
	    tdc = afs_sgibklist;
	    afs_sgibklist = NULL;
	    SPUNLOCK(afs_sgibklock, s);
	    AFS_GLOCK();
	    tdc->dflags &= ~DFEntryMod;
	    osi_Assert(afs_WriteDCache(tdc, 1) == 0);
	    AFS_GUNLOCK();
	    s = SPLOCK(afs_sgibklock);
	}

	/* done all the work - wake everyone up */
	while (SV_SIGNAL(&afs_sgibkwait));
    }
}
Esempio n. 2
0
void init_console(t_console_desc *console_desc,int out_buf_len,int in_buf_len)
{
	int i,j=0;
	SPINLOCK_INIT(console_desc->spinlock);
	console_desc->out_buf=kmalloc(out_buf_len);
	console_desc->out_buf_len=out_buf_len;
	console_desc->out_buf_index=-1;
	console_desc->video_buf=VIDEO_MEM_ADD;
	console_desc->video_buf_index=-1;
	console_desc->first_char=1;
	console_desc->sleeping_process=NULL;
	console_desc->is_empty=1;
	for (i=0;i<SCREEN_AREA;i++)
	{
		console_desc->video_buf[j++]=CHAR_NULL;
		console_desc->video_buf[j++]=SCREEN_FOREGROUND_COLOR;
	}
	return;
}
Esempio n. 3
0
/*
 *  Initialize the system and let everyone wait until we have done so
 *  properly
 */
void
Init_iODBC (void)
{
#if !defined (PTHREAD_MUTEX_INITIALIZER) || defined (WINDOWS)
  SPINLOCK_INIT (iodbcdm_global_lock);
#endif

  SPINLOCK_LOCK (iodbcdm_global_lock);
  if (!_iodbcdm_initialized)
    {
      /*
       *  OK, now flag we are not callable anymore
       */
      _iodbcdm_initialized = 1;

      /*
       *  Other one time initializations can be performed here
       */
    }
  SPINLOCK_UNLOCK (iodbcdm_global_lock);

  return;
}
Esempio n. 4
0
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <kernel/console.h>
#include <kernel/types.h>
#include <kernel/sync/spinlock.h>
#include <kernel/lib/printf.h>

static struct console* s_screen = NULL;
static struct console* s_debug = NULL;

static struct spinlock s_console_lock = SPINLOCK_INIT("console");

// =====================================================================================================================
void console_set_screen(struct console* c)
{
    if (c->clear)
	c->clear();

    s_screen = c;
}

// =====================================================================================================================
void console_set_debug(struct console* c)
{
    if (c->clear)
	c->clear();
Esempio n. 5
0
File: ata.c Progetto: giumaug/g-os
static unsigned int _p_read_write_28_ata(t_io_request* io_request)
{
    int i;
    t_device_desc* device_desc;
    t_io_request* pending_request;
    t_llist_node* node;
    t_spinlock_desc spinlock;
    int k=0;

    SPINLOCK_INIT(spinlock);
    device_desc=io_request->device_desc;

    //Entrypoint mutual exclusion region
    SPINLOCK_LOCK(spinlock);

    device_desc->status=DEVICE_BUSY || POOLING_MODE;
    system.device_desc->serving_request=io_request;

    out(0x2,0x3F6);
    out(0xE0 | (io_request->lba >> 24),0x1F6);
    out((unsigned char)io_request->sector_count,0x1F2);
    out((unsigned char)io_request->lba,0x1F3);
    out((unsigned char)(io_request->lba >> 8),0x1F4);
    out((unsigned char)(io_request->lba >> 16),0x1F5);
    out(io_request->command,0x1F7);
    for (k=0; k<1000; k++);

    //to fix
    if (io_request->command==WRITE_28)
    {
        for (i=0; i<256; i++)
        {
            //out(*(char*)io_request->io_buffer++,0x1F0);
            outw((unsigned short)57,0x1F0);
        }
    }
    while (in(0x1F7)&0x80);

    if ((in(0x1F7)&0x21))
    {
        device_desc->status=DEVICE_IDLE;
        panic();
        return -1;
    }

    device_desc->status=DEVICE_IDLE;

    if (io_request->command==READ_28)
    {
        for (i=0; i<(512*io_request->sector_count); i+=2)
        {
            unsigned short val=inw(0x1F0);
            ((char*)io_request->io_buffer)[i]=(val&0xff);
            ((char*)io_request->io_buffer)[i+1]=(val>>0x8);
        }
    }
    out(0x0,0x3F6);
    //Exitpoint mutual exclusion region
    SPINLOCK_UNLOCK(spinlock);
    return 0;
}
Esempio n. 6
0
#include <protura/kassert.h>
#include <protura/mm/kmalloc.h>
#include <protura/snprintf.h>
#include <protura/list.h>
#include <arch/asm.h>

#include <protura/fs/procfs.h>
#include <protura/drivers/pci.h>
#include <protura/drivers/pci_ids.h>
#include <protura/net/proto.h>
#include <protura/net/linklayer.h>
#include <protura/net.h>

static struct task *packet_process_task;

static spinlock_t packet_queue_lock = SPINLOCK_INIT("packet-queue-lock");
static int packet_queue_length = 0;
static list_head_t packet_queue = LIST_HEAD_INIT(packet_queue);

static int packet_process_thread(void *p)
{
    while (1) {
        using_spinlock(&packet_queue_lock) {
            kp(KP_NORMAL, "packet-queue awake\n");

            while (!list_empty(&packet_queue)) {
                struct packet *packet = list_take_first(&packet_queue, struct packet, packet_entry);

                kp(KP_NORMAL, "Recieved packet! len: %d\n", packet_len(packet));
                kp(KP_NORMAL, "Packets in queue: %d\n", --packet_queue_length);