Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1403 → Rev 1404

/uspace/trunk/fb/fb.c
1,5 → 1,6
/*
* Copyright (C) 2006 Jakub Vana
* Copyright (C) 2006 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
46,6 → 47,11
#include <kernel/errno.h>
#include <async.h>
 
 
#include "font-8x16.h"
#include <string.h>
 
#include "helenos.xbm"
#include "fb.h"
 
#define EFB (-1)
179,44 → 185,8
/* Never reached */
return 0;
}
/*
* Copyright (C) 2006 Ondrej Palkovsky
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
 
#include "font-8x16.h"
#include <string.h>
 
#include "helenos.xbm"
 
 
 
 
 
 
#define GRAPHICS_ITEMS 1024
 
 
/uspace/trunk/libc/generic/async.c
73,6 → 73,8
* msg = get_msg();
* ....
* }
*
* TODO: Detaching/joining dead psthreads? */
*/
#include <futex.h>
#include <async.h>
99,7 → 101,6
link_t msg_queue; /**< Messages that should be delivered to this thread */
pstid_t ptid; /**< Thread associated with this connection */
int active; /**< If this thread is currently active */
int opened; /* If the connection was accepted */
/* Structures for connection opening packet */
ipc_callid_t callid;
ipc_call_t call;
109,12 → 110,12
 
/* Hash table functions */
 
#define ASYNC_HASH_TABLE_CHAINS 32
#define CONN_HASH_TABLE_CHAINS 32
 
static hash_index_t conn_hash(unsigned long *key)
{
assert(key);
return ((*key) >> 4) % ASYNC_HASH_TABLE_CHAINS;
return ((*key) >> 4) % CONN_HASH_TABLE_CHAINS;
}
 
static int conn_compare(unsigned long key[], hash_count_t keys, link_t *item)
174,6 → 175,7
return 1;
}
 
/** Return new incoming message for current(thread-local) connection */
ipc_callid_t async_get_call(ipc_call_t *call)
{
msg_t *msg;
199,23 → 201,44
return callid;
}
 
/** Thread function that gets created on new connection
*
* This function is defined as a weak symbol - to be redefined in
* user code.
*/
void client_connection(ipc_callid_t callid, ipc_call_t *call)
{
printf("Got connection - no handler.\n");
_exit(1);
ipc_answer_fast(callid, ENOENT, 0, 0);
}
 
/** Wrapper for client connection thread
*
* When new connection arrives, thread with this function is created.
* It calls client_connection and does final cleanup.
*
* @parameter arg Connection structure pointer
*/
static int connection_thread(void *arg)
{
unsigned long key;
msg_t *msg;
 
/* Setup thread local connection pointer */
PS_connection = (connection_t *)arg;
client_connection(PS_connection->callid, &PS_connection->call);
 
/* Remove myself from connection hash table */
futex_down(&conn_futex);
/* TODO: remove myself from connection hash table */
key = PS_connection->in_phone_hash;
hash_table_remove(&conn_hash_table, &key, 1);
futex_up(&conn_futex);
/* TODO: answer all unanswered messages in queue with
* EHANGUP */
/* Answer all remaining messages with ehangup */
while (!list_empty(&PS_connection->msg_queue)) {
msg = list_get_instance(PS_connection->msg_queue.next, msg_t, link);
list_remove(&msg->link);
ipc_answer_fast(msg->callid, EHANGUP, 0, 0);
free(msg);
}
}
 
/** Create new thread for a new connection
238,7 → 261,6
}
conn->in_phone_hash = IPC_GET_ARG3(*call);
list_initialize(&conn->msg_queue);
conn->opened = 0;
conn->ptid = psthread_create(connection_thread, conn);
conn->callid = callid;
conn->call = *call;
297,6 → 319,13
}
}
 
/** Function to start async_manager as a standalone thread
*
* When more kernel threads are used, one async manager should
* exist per thread. The particular implementation may change,
* currently one async_manager is started automatically per kernel
* thread except main thread.
*/
static int async_manager_thread(void *arg)
{
futex_up(&conn_futex); /* conn_futex is always locked when entering
322,7 → 351,7
/** Initialize internal structures needed for async manager */
int _async_init(void)
{
if (!hash_table_create(&conn_hash_table, ASYNC_HASH_TABLE_CHAINS, 1, &conn_hash_table_ops)) {
if (!hash_table_create(&conn_hash_table, CONN_HASH_TABLE_CHAINS, 1, &conn_hash_table_ops)) {
printf("%s: cannot create hash table\n", "async");
return ENOMEM;
}