/[hurd]/hurd-l4/physmem/container.c
ViewVC logotype

Diff of /hurd-l4/physmem/container.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by marcus, Mon Nov 1 17:06:45 2004 UTC revision 1.11 by marcus, Mon Nov 1 20:54:00 2004 UTC
# Line 33  Line 33 
33    
34    
35    
 struct container  
 {  
   /* The capability object must be the first member of this  
      struct.  */  
   struct hurd_cap_obj obj;  
   
   /* For now, a container is nothing more than a contiguous,  
      page-aligned range of memory.  This is the reason why  
      L4_FPAGE_SPAN_MAX fpages are sufficient.  */  
   l4_fpage_t fpages[L4_FPAGE_SPAN_MAX];  
   
   /* The number of entries in FPAGES.  */  
   l4_word_t nr_fpages;  
 };  
 typedef struct container *container_t;  
   
   
36  static void  static void
37  container_reinit (hurd_cap_class_t cap_class, hurd_cap_obj_t obj)  container_reinit (hurd_cap_class_t cap_class, hurd_cap_obj_t obj)
38  {  {
39    container_t container = (container_t) obj;    container_t container = hurd_cap_obj_to_user (container_t, obj);
40    l4_word_t nr_fpages;    l4_word_t nr_fpages;
41    
42    nr_fpages = container->nr_fpages;    nr_fpages = container->nr_fpages;
# Line 71  container_reinit (hurd_cap_class_t cap_c Line 54  container_reinit (hurd_cap_class_t cap_c
54  error_t  error_t
55  container_map (hurd_cap_rpc_context_t ctx)  container_map (hurd_cap_rpc_context_t ctx)
56  {  {
57    container_t container = (container_t) ctx->obj;    container_t container = hurd_cap_obj_to_user (container_t, ctx->obj);
58    l4_word_t offset = l4_page_trunc (l4_msg_word (ctx->msg, 1));    l4_word_t offset = l4_page_trunc (l4_msg_word (ctx->msg, 1));
59    l4_word_t rights = l4_msg_word (ctx->msg, 1) & 0x7;    l4_word_t rights = l4_msg_word (ctx->msg, 1) & 0x7;
60    l4_word_t size = l4_page_round (l4_msg_word (ctx->msg, 2));    l4_word_t size = l4_page_round (l4_msg_word (ctx->msg, 2));
# Line 142  static struct hurd_cap_class container_c Line 125  static struct hurd_cap_class container_c
125  error_t  error_t
126  container_class_init ()  container_class_init ()
127  {  {
128    return hurd_cap_class_init (&container_class, sizeof (struct container),    return hurd_cap_class_init (&container_class, container_t,
                               __alignof__ (struct container),  
129                                NULL, NULL, container_reinit, NULL,                                NULL, NULL, container_reinit, NULL,
130                                container_demuxer);                                container_demuxer);
131  }  }
# Line 154  container_class_init () Line 136  container_class_init ()
136     reference.  */     reference.  */
137  error_t  error_t
138  container_alloc (l4_word_t nr_fpages, l4_word_t *fpages,  container_alloc (l4_word_t nr_fpages, l4_word_t *fpages,
139                   hurd_cap_obj_t *r_obj)                   container_t *r_container)
140  {  {
141    error_t err;    error_t err;
142      hurd_cap_obj_t obj;
143    container_t container;    container_t container;
144    
145    err = hurd_cap_class_alloc (&container_class, (hurd_cap_obj_t *) &container);    err = hurd_cap_class_alloc (&container_class, &obj);
146    if (err)    if (err)
147      return err;      return err;
148    
149      container = hurd_cap_obj_to_user (container_t, obj);
150    assert (nr_fpages <= L4_FPAGE_SPAN_MAX);    assert (nr_fpages <= L4_FPAGE_SPAN_MAX);
151    container->nr_fpages = nr_fpages;    container->nr_fpages = nr_fpages;
152    memcpy (container->fpages, fpages, sizeof (l4_fpage_t) * nr_fpages);    memcpy (container->fpages, fpages, sizeof (l4_fpage_t) * nr_fpages);
153    
154    *r_obj = &container->obj;    *r_container = container;
155    return 0;    return 0;
156  }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26