[eros-cvs] cvs commit: eros/src/base/tests/func/constructor_test constructor_test.c

shap@eros.cs.jhu.edu shap@eros.cs.jhu.edu
Wed, 29 Aug 2001 23:06:31 -0400


shap        01/08/29 23:06:31

  Modified:    src/base/domain/constructor constructor.c
               src/base/lib/domain/include ConstructorKey.h
               src/base/lib/domain/key constructor_insert.c
               src/base/tests/func/constructor_test constructor_test.c
  Added:       src/base/lib/domain/key constructor_insert_addrspace.c
                        constructor_insert_keeper.c constructor_insert_pc.c
                        constructor_insert_symtab.c
  Log:
  Fixed constructor to support 32 constituents. This change has no
  impact on existing imgmap files, so there should be very little need
  to change anything in response to this.

Revision  Changes    Path
1.37      +68 -28    eros/src/base/domain/constructor/constructor.c

Index: constructor.c
===================================================================
RCS file: /cvs/eros/src/base/domain/constructor/constructor.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- constructor.c	2001/08/30 02:08:07	1.36
+++ constructor.c	2001/08/30 03:06:30	1.37
@@ -19,24 +19,14 @@
  */
 
 /* A constructor is responsible for building program instances.  The
- * constructor holds 19 so-called "constituents":
+ * constructor holds copies of each entry of the constituents node. In
+ * addition, it holds the target process' keeper key, address space
+ * key, symbol table ke, and initial PC.
  *
- * 0..15	Are passed to the created process in a constituents
- * 		capage by way of a fetch capability.
- *
- * 16		The process keeper, or a factory for that keeper.
- *
- * 17		The process address space, or a factory for that
- *              address space.
- *
- * 18		The process symbol table.
- *
- * 19		The process initial PC (as a number key)
- *
  * BOOTSTRAP NOTE 1:
  * 
  * To simplify system image construction, the constructor does some
- * minimal analysis at startup time.  If KC_PROD_CON0 and KC_PROD_CON1
+ * minimal analysis at startup time.  If KC_PROD_CON0 and KC_PROD_XCON
  * are not void, they are accepted as holding the product constituents,
  * and KC_DCC should hold the domain creator for the constituents.
  * 
@@ -76,7 +66,7 @@
 #define KR_NEWDOM   9
 
 #define KR_PROD_CON0 10		/* product's constituents */
-#define KR_PROD_CON1 11		/* product's constituents */
+#define KR_PROD_XCON 11		/* product's extended constituents */
 
 #define KR_ARG0    28
 #define KR_ARG1    29
@@ -90,8 +80,14 @@
 #define KC_PROTOSPC 4
 #define KC_MYDOMCRE 5
 #define KC_PROD_CON0 14
-#define KC_PROD_CON1 15
+#define KC_PROD_XCON 15
 
+/* Extended Constituents: */
+#define XCON_KEEPER     0
+#define XCON_ADDRSPACE  1
+#define XCON_SYMTAB     2
+#define XCON_PC         3
+
 #define DEBUG if (0)
 /* #define DEBUG if (1) */
 
@@ -151,7 +147,7 @@
        domain creator. */
     node_copy(KR_CONSTIT, KC_DCC, KR_DOMCRE);
     node_copy(KR_CONSTIT, KC_PROD_CON0, KR_PROD_CON0);
-    node_copy(KR_CONSTIT, KC_PROD_CON1, KR_PROD_CON1);
+    node_copy(KR_CONSTIT, KC_PROD_XCON, KR_PROD_XCON);
 
     ci->frozen = 1;
   }
@@ -184,7 +180,7 @@
       DEBUG kdprintf(KR_OSTREAM, "GOT DOMCRE Result is 0x%08x\n", result);
     }
   
-    spcbank_buy_nodes(KR_BANK, 2, KR_PROD_CON0, KR_PROD_CON1, KR_VOID);
+    spcbank_buy_nodes(KR_BANK, 2, KR_PROD_CON0, KR_PROD_XCON, KR_VOID);
   }
     
   node_copy(KR_CONSTIT, KC_RETURNER, KR_RETURNER);
@@ -195,12 +191,12 @@
 void
 Sepuku()
 {
-  /* OH SHIT giving up the constituent nodes breaks our products */
+  /* FIX: giving up the constituent nodes breaks our products */
   
   /* Give up the first constituent node. */
   /* Give up the second constituent node */
   spcbank_return_node(KR_BANK, KR_PROD_CON0);
-  spcbank_return_node(KR_BANK, KR_PROD_CON1);
+  spcbank_return_node(KR_BANK, KR_PROD_XCON);
   node_copy(KR_CONSTIT, KC_MYDOMCRE, KR_DOMCRE);
   node_copy(KR_CONSTIT, KC_PROTOSPC, KR_PROD_CON0);
 
@@ -291,19 +287,19 @@
   (void) process_swap_keyreg(KR_NEWDOM, 5, KR_ARG1, KR_VOID);
 
   /* Keeper constructor to KR 6 */
-  (void) node_copy(KR_PROD_CON1, Constructor_Product_Kpr - 16, KR_SCRATCH);
+  (void) node_copy(KR_PROD_XCON, XCON_KEEPER, KR_SCRATCH);
   (void) process_swap_keyreg(KR_NEWDOM, 6, KR_SCRATCH, KR_VOID);
 
   /* Space constructor to KR 7 */
-  (void) node_copy(KR_PROD_CON1, Constructor_Product_Spc - 16, KR_SCRATCH);
+  (void) node_copy(KR_PROD_XCON, XCON_ADDRSPACE, KR_SCRATCH);
   (void) process_swap_keyreg(KR_NEWDOM, 7, KR_SCRATCH, KR_VOID);
 
   /* Symtab to DR 3 */
-  (void) node_copy(KR_PROD_CON1, Constructor_Product_Sym - 16, KR_SCRATCH);
+  (void) node_copy(KR_PROD_XCON, XCON_SYMTAB, KR_SCRATCH);
   (void) process_swap(KR_NEWDOM, ProcSymSpace, KR_SCRATCH, KR_VOID);
 
   /* Initial PC to KR 8 */
-  (void) node_copy(KR_PROD_CON1, Constructor_Product_PC - 16, KR_SCRATCH);
+  (void) node_copy(KR_PROD_XCON, XCON_PC, KR_SCRATCH);
   (void) process_swap_keyreg(KR_NEWDOM, 8, KR_SCRATCH, KR_VOID);
 
   /* User ARG2 to KR 28 */
@@ -376,8 +372,25 @@
 insert_constituent(uint32_t ndx, uint32_t kr, ConstructorInfo *ci)
 {
   DEBUG kdprintf(KR_OSTREAM, "constructor: insert constituent %d\n", ndx);
+
+  if (ndx >= EROS_NODE_SIZE)
+    return RC_RequestError;
+    
+  if ( is_not_discreet(kr, ci) )
+    add_new_hole(kr, ci);
+  
+  /* now insert the constituent in the proper constituents node: */
+  node_swap(KR_PROD_CON0, ndx, kr, KR_VOID);
+	    
+  return RC_OK;
+}
+
+uint32_t
+insert_xconstituent(uint32_t ndx, uint32_t kr, ConstructorInfo *ci)
+{
+  DEBUG kdprintf(KR_OSTREAM, "constructor: insert constituent %d\n", ndx);
 
-  if (ndx == 19) {
+  if (ndx == XCON_PC) {
     uint32_t obClass;
     
     /* This copy IS redundant with the one in is_not_discreet(), but
@@ -389,15 +402,14 @@
       return RC_RequestError;
   }
 
-  if (ndx > 19)
+  if (ndx > XCON_PC)
     return RC_RequestError;
     
   if ( is_not_discreet(kr, ci) )
     add_new_hole(kr, ci);
   
   /* now insert the constituent in the proper constituents node: */
-  node_swap((ndx < 16) ? KR_PROD_CON0 : KR_PROD_CON1,
-	    ndx % 16, kr, KR_VOID);
+  node_swap(KR_PROD_XCON, ndx, kr, KR_VOID);
 	    
   return RC_OK;
 }
@@ -453,6 +465,34 @@
   case OC_Constructor_Insert:
     {
       msg->snd_code = insert_constituent(msg->rcv_w1, KR_ARG0, ci);
+      
+      return 1;
+    }      
+
+  case OC_Constructor_Insert_Keeper:
+    {
+      msg->snd_code = insert_xconstituent(XCON_KEEPER, KR_ARG0, ci);
+      
+      return 1;
+    }      
+
+  case OC_Constructor_Insert_AddrSpace:
+    {
+      msg->snd_code = insert_xconstituent(XCON_ADDRSPACE, KR_ARG0, ci);
+      
+      return 1;
+    }      
+
+  case OC_Constructor_Insert_Symtab:
+    {
+      msg->snd_code = insert_xconstituent(XCON_SYMTAB, KR_ARG0, ci);
+      
+      return 1;
+    }      
+
+  case OC_Constructor_Insert_PC:
+    {
+      msg->snd_code = insert_xconstituent(XCON_PC, KR_ARG0, ci);
       
       return 1;
     }      



1.18      +15 -6     eros/src/base/lib/domain/include/ConstructorKey.h

Index: ConstructorKey.h
===================================================================
RCS file: /cvs/eros/src/base/lib/domain/include/ConstructorKey.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ConstructorKey.h	2001/08/30 02:08:07	1.17
+++ ConstructorKey.h	2001/08/30 03:06:30	1.18
@@ -26,24 +26,33 @@
 #define OC_Constructor_Seal                   3
 #define OC_Constructor_Insert                 4
 
+#define OC_Constructor_Insert_Keeper          5
+#define OC_Constructor_Insert_AddrSpace       6
+#define OC_Constructor_Insert_Symtab          7
+#define OC_Constructor_Insert_PC              8
+
 /* Also add #defines for the error return values... */
 #define RC_Constructor_Indiscreet             1
 #define RC_Constructor_NotSealed              2
 #define RC_Constructor_NotBuilder             3
 
-#define Constructor_Product_Kpr   16
-#define Constructor_Product_Spc   17
-#define Constructor_Product_Sym   18
-#define Constructor_Product_PC    19
-
 #ifndef __ASSEMBLER__
 uint32_t constructor_request(uint32_t krConstructor, uint32_t krBank,
 			     uint32_t krSched, uint32_t krArg0,
 			     uint32_t krProduct /* OUT */);
 uint32_t constructor_is_discreet(uint32_t krConstructor, uint32_t *isDiscreet);
 uint32_t constructor_seal(uint32_t krConstructor, uint32_t krRequestor);
-uint32_t constructor_insert(uint32_t krConstructor, uint32_t ndx,
+uint32_t constructor_xinsert(uint32_t krConstructor, uint32_t ndx,
 			    uint32_t krConstit);
+
+uint32_t constructor_insert_keeper(uint32_t krConstructor, 
+				   uint32_t krKeeper);
+uint32_t constructor_insert_addrspace(uint32_t krConstructor, 
+				      uint32_t krAddrSpace);
+uint32_t constructor_insert_symtab(uint32_t krConstructor, 
+				   uint32_t krSymtab);
+uint32_t constructor_insert_pc(uint32_t krConstructor, 
+			       uint32_t krPC);
 #endif
 
 #endif /* __CONSTRUCTOR_H__ */



1.15      +1 -1      eros/src/base/lib/domain/key/constructor_insert.c

Index: constructor_insert.c
===================================================================
RCS file: /cvs/eros/src/base/lib/domain/key/constructor_insert.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- constructor_insert.c	2001/05/24 04:37:56	1.14
+++ constructor_insert.c	2001/08/30 03:06:30	1.15
@@ -24,7 +24,7 @@
 
 /* Copy key from node slot to key register */
 uint32_t
-constructor_insert(uint32_t krConstructor, uint32_t ndx, uint32_t krConstit)
+constructor_xinsert(uint32_t krConstructor, uint32_t ndx, uint32_t krConstit)
 {
   Message msg;
 



1.1                  eros/src/base/lib/domain/key/constructor_insert_addrspace.c

Index: constructor_insert_addrspace.c
===================================================================
/*
 * Copyright (C) 1998, 1999, Jonathan S. Shapiro.
 *
 * This file is part of the EROS Operating System runtime library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA.
 */

#include <eros/target.h>
#include <eros/Invoke.h>
#include "ConstructorKey.h"

/* Copy key from node slot to key register */
uint32_t
constructor_insert_addrspace(uint32_t krConstructor, uint32_t krSpace)
{
  Message msg;

  msg.snd_w1 = 0;
  msg.snd_w2 = 0;
  msg.snd_w3 = 0;

  msg.snd_key0 = krSpace;
  msg.snd_key1 = KR_VOID;
  msg.snd_key2 = KR_VOID;
  msg.snd_key3 = KR_VOID;
  msg.snd_data = 0;
  msg.snd_len = 0;

  msg.rcv_key0 = KR_VOID;
  msg.rcv_key1 = KR_VOID;
  msg.rcv_key2 = KR_VOID;
  msg.rcv_key3 = KR_VOID;
  msg.rcv_len = 0;		/* no data returned */


  /* No string arg == I'll take anything */
  msg.snd_invKey = krConstructor;
  msg.snd_code = OC_Constructor_Insert_AddrSpace;

  return CALL(&msg);
}




1.1                  eros/src/base/lib/domain/key/constructor_insert_keeper.c

Index: constructor_insert_keeper.c
===================================================================
/*
 * Copyright (C) 1998, 1999, Jonathan S. Shapiro.
 *
 * This file is part of the EROS Operating System runtime library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA.
 */

#include <eros/target.h>
#include <eros/Invoke.h>
#include "ConstructorKey.h"

/* Copy key from node slot to key register */
uint32_t
constructor_insert_keeper(uint32_t krConstructor, uint32_t krKeeper)
{
  Message msg;

  msg.snd_w1 = 0;
  msg.snd_w2 = 0;
  msg.snd_w3 = 0;

  msg.snd_key0 = krKeeper;
  msg.snd_key1 = KR_VOID;
  msg.snd_key2 = KR_VOID;
  msg.snd_key3 = KR_VOID;
  msg.snd_data = 0;
  msg.snd_len = 0;

  msg.rcv_key0 = KR_VOID;
  msg.rcv_key1 = KR_VOID;
  msg.rcv_key2 = KR_VOID;
  msg.rcv_key3 = KR_VOID;
  msg.rcv_len = 0;		/* no data returned */


  /* No string arg == I'll take anything */
  msg.snd_invKey = krConstructor;
  msg.snd_code = OC_Constructor_Insert_Keeper;

  return CALL(&msg);
}




1.1                  eros/src/base/lib/domain/key/constructor_insert_pc.c

Index: constructor_insert_pc.c
===================================================================
/*
 * Copyright (C) 1998, 1999, Jonathan S. Shapiro.
 *
 * This file is part of the EROS Operating System runtime library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA.
 */

#include <eros/target.h>
#include <eros/Invoke.h>
#include "ConstructorKey.h"

/* Copy key from node slot to key register */
uint32_t
constructor_insert_pc(uint32_t krConstructor, uint32_t krPC)
{
  Message msg;

  msg.snd_w1 = 0;
  msg.snd_w2 = 0;
  msg.snd_w3 = 0;

  msg.snd_key0 = krPC;
  msg.snd_key1 = KR_VOID;
  msg.snd_key2 = KR_VOID;
  msg.snd_key3 = KR_VOID;
  msg.snd_data = 0;
  msg.snd_len = 0;

  msg.rcv_key0 = KR_VOID;
  msg.rcv_key1 = KR_VOID;
  msg.rcv_key2 = KR_VOID;
  msg.rcv_key3 = KR_VOID;
  msg.rcv_len = 0;		/* no data returned */


  /* No string arg == I'll take anything */
  msg.snd_invKey = krConstructor;
  msg.snd_code = OC_Constructor_Insert_PC;

  return CALL(&msg);
}




1.1                  eros/src/base/lib/domain/key/constructor_insert_symtab.c

Index: constructor_insert_symtab.c
===================================================================
/*
 * Copyright (C) 1998, 1999, Jonathan S. Shapiro.
 *
 * This file is part of the EROS Operating System runtime library.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA.
 */

#include <eros/target.h>
#include <eros/Invoke.h>
#include "ConstructorKey.h"

/* Copy key from node slot to key register */
uint32_t
constructor_insert_symtab(uint32_t krConstructor, uint32_t krSymtab)
{
  Message msg;

  msg.snd_w1 = 0;
  msg.snd_w2 = 0;
  msg.snd_w3 = 0;

  msg.snd_key0 = krSymtab;
  msg.snd_key1 = KR_VOID;
  msg.snd_key2 = KR_VOID;
  msg.snd_key3 = KR_VOID;
  msg.snd_data = 0;
  msg.snd_len = 0;

  msg.rcv_key0 = KR_VOID;
  msg.rcv_key1 = KR_VOID;
  msg.rcv_key2 = KR_VOID;
  msg.rcv_key3 = KR_VOID;
  msg.rcv_len = 0;		/* no data returned */


  /* No string arg == I'll take anything */
  msg.snd_invKey = krConstructor;
  msg.snd_code = OC_Constructor_Insert_Symtab;

  return CALL(&msg);
}




1.20      +3 -3      eros/src/base/tests/func/constructor_test/constructor_test.c

Index: constructor_test.c
===================================================================
RCS file: /cvs/eros/src/base/tests/func/constructor_test/constructor_test.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- constructor_test.c	2001/05/24 04:38:03	1.19
+++ constructor_test.c	2001/08/30 03:06:30	1.20
@@ -69,10 +69,10 @@
   kdprintf(KR_OSTREAM, "Populate new constructor\n");
 
   /* KR_OSTREAM is constituent 0 */
-  constructor_insert(KR_NEWCON, 0, KR_OSTREAM);
+  constructor_xinsert(KR_NEWCON, 0, KR_OSTREAM);
 
-  constructor_insert(KR_NEWCON, Constructor_Product_Spc, KR_HELLO_SEG);
-  constructor_insert(KR_NEWCON, Constructor_Product_PC, KR_HELLO_PC);
+  constructor_insert_addrspace(KR_NEWCON, KR_HELLO_SEG);
+  constructor_insert_pc(KR_NEWCON, KR_HELLO_PC);
 
   constructor_seal(KR_NEWCON, KR_CONREQ);