all build: $(DRIVER)
$(DRIVER): $(OBJ)
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
- install -S 4096 $(DRIVER)
+ install -S 16k $(DRIVER)
# install with other drivers
install: /usr/sbin/$(DRIVER)
continue;
}
case DIAGNOSTICS: /* a server wants to print some */
+ printf("WARNING: old DIAGNOSTICS from %d\n", tty_mess.m_source);
do_diagnostics(&tty_mess, 0);
continue;
case DIAGNOSTICS_S:
_PROTOTYPE( cp_grant_id_t cpf_grant_indirect, (endpoint_t, endpoint_t, cp_grant_id_t));
_PROTOTYPE( cp_grant_id_t cpf_grant_magic, (endpoint_t, endpoint_t, vir_bytes, size_t, int));
_PROTOTYPE( int cpf_revoke, (cp_grant_id_t grant_id));
-_PROTOTYPE( int cpf_preallocate, (cp_grant_t *, int));
_PROTOTYPE( int cpf_lookup, (cp_grant_id_t g, endpoint_t *ep, endpoint_t *ep2));
_PROTOTYPE( int cpf_getgrants, (cp_grant_id_t *grant_ids, int n));
libc_FILES=" \
_brk.c \
+ _sbrk.c \
_devctl.c \
__pm_findproc.c \
_getnpid.c \
return(0);
}
-
-PUBLIC char *sbrk(incr)
-int incr;
-{
- char *newsize, *oldsize;
-
- oldsize = _brksize;
- newsize = _brksize + incr;
- if ((incr > 0 && newsize < oldsize) || (incr < 0 && newsize > oldsize))
- return( (char *) -1);
- if (brk(newsize) == 0)
- return(oldsize);
- else
- return( (char *) -1);
-}
--- /dev/null
+#include <lib.h>
+#define sbrk _sbrk
+#include <unistd.h>
+
+extern char *_brksize;
+
+PUBLIC char *sbrk(incr)
+int incr;
+{
+ char *newsize, *oldsize;
+
+ oldsize = _brksize;
+ newsize = _brksize + incr;
+ if ((incr > 0 && newsize < oldsize) || (incr < 0 && newsize > oldsize))
+ return( (char *) -1);
+ if (brk(newsize) == 0)
+ return(oldsize);
+ else
+ return( (char *) -1);
+}
}
PRIVATE cp_grant_t *grants = NULL;
-PRIVATE int ngrants = 0, dynamic = 1;
-
-PUBLIC int
-cpf_preallocate(cp_grant_t *new_grants, int new_ngrants)
-{
-/* Use a statically allocated block of grants as our grant table.
- * This means we can't grow it dynamically any more.
- *
- * This function is used in processes that can't safely call realloc().
- */
- int s;
-
- /* If any table is already in place, we can't change it. */
- if(ngrants > 0) {
- errno = EBUSY;
- return -1;
- }
-
- /* Update kernel about the table. */
- if((s=sys_setgrant(new_grants, new_ngrants))) {
- return -1;
- }
-
- /* Update internal data. dynamic = 0 means no realloc()ing will be done
- * and we can't grow beyond this size.
- */
- grants = new_grants;
- ngrants = new_ngrants;
- dynamic = 0;
-
- return 0;
-}
+PRIVATE int ngrants = 0;
PRIVATE void
cpf_grow(void)
{
-/* Grow the grants table if possible. If a preallocated block has been
- * submitted ('dynamic' is clear), we can't grow it. Otherwise, realloc().
- * Caller is expected to check 'ngrants' to see if the call was successful.
- */
+/* Grow the grants table if possible. */
cp_grant_t *new_grants;
cp_grant_id_t g;
int new_size;
- /* Can't grow if static block already assigned. */
- if(!dynamic)
- return;
-
new_size = (1+ngrants)*2;
assert(new_size > ngrants);
#define PRINTPROCS (sizeof(procs)/sizeof(procs[0]))
int procs[] = OUTPUT_PROCS_ARRAY;
static int firstprint = 1;
- static cp_grant_t printgrant_buffer[PRINTPROCS];
static cp_grant_id_t printgrants[PRINTPROCS];
int p;
if(firstprint) {
+ for(p = 0; procs[p] != NONE; p++) {
+ printgrants[p] = GRANT_INVALID;
+ }
+
+ firstprint = 0;
+
/* First time? Initialize grant table;
* Grant printing processes read copy access to our
- * print buffer. (So buffer can't be on stack!)
+ * print buffer forever. (So buffer can't be on stack!)
*/
- cpf_preallocate(printgrant_buffer, PRINTPROCS);
for(p = 0; procs[p] != NONE; p++) {
printgrants[p] = cpf_grant_direct(procs[p], print_buf,
sizeof(print_buf), CPF_READ);
}
- firstprint = 0;
}
for(p = 0; procs[p] != NONE; p++) {
install all build: $(SERVER)
$(SERVER): $(OBJ)
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
- install -S 1024w $@
+ install -S 16k $@
# clean up local files
clean:
message mess;
int s;
-/* Maximum number of outstanding grants is one full i/o
- * vector, and all processes hanging on SUSPENDed i/o, and
- * grants for printf() to tty and log.
- *
- * Space is declared for it here, and cpf_preallocate()
- * uses it internally and internally tells the kernel
- * about it. FS then never touches the data again directly,
- * only through the cpf_* library routines.
- */
-#define NGRANTS (NR_PROCS + NR_IOREQS + 10)
- static cp_grant_t grants[NGRANTS];
-
- /* Set data copy grant table, as FS can't allocate it dynamically. */
- if(cpf_preallocate(grants, NGRANTS) != OK)
- panic(__FILE__,"cpf_preallocate failed", NO_NUM);
-
/* Initialize the process table with help of the process manager messages.
* Expect one message for each system process with its slot number and pid.
* When no more processes follow, the magic process number NONE is sent.