L 5.16:  Locating the receive fpage in do_long_ipc

(Revision 1 - 29 November 2000)

overview    The next two sections process mappings, i.e., fpage specifications. The first of these locates the receive flexpage or fpage (a specific contiguous VA range in the receiver's VA space, indicated by a value in the receive descriptor or receive message header). That is, it places the receiver's  fpage into a specific slot in a temporary mapping area in the sender's VA space ( in a slot in XKSSEG) and causes a "window fault" which then sets up a TLB mapping from this slot in  the sender's VA space to the actual PA of  the frame that holds the fpage. For definition of an fpage and how the mappings work see Professor Heiser's API slides 21-26 and the L4UM pages 6-9. The L4UM has an error in the 'precise definition' of the mapping - but Gernot's slides define it correctly.

data	L4_IPC_FPAGE_MASK    0x02 (m bit in message descriptor)
        L4_IPC_DECEIT_MASK   0x01 (d bit in message descriptor)
	USER_ADDR_TOP	     0x4000 0000 0000 0000 (base of XKSSEG)
	TID_THREAD_MASK	     0000376000 (7 bit thread number field in tid)
	TID_THREAD_SHIFT     10 (shift to get thread # in lo order bit positions)
	RECV_WINDOW_SIZE     16*1024*1024 (16MB per sender thread window size)
	RECV_WINDOW_BASE     0X4000 0000 0000 0000
	
15 if m bit not set in send descriptor, there's no mapping, goto line 58 L5.17
16-18 set up a variable, rcv_fpage,  to hold the receiver's fpage and initialize it to 0
19-22 if receive descriptor holds receiver's fpage (m-bit is non-zero)
rcv_fpage <-- contents of receiver's descriptor
23,24,34 else if the address part of the receive descriptor is non-zero we need to make a temporary mapping in the sender's VA space of the receiver's message buffer (an fpage could be in the first word of the message header) so sender can access receiver's fpage in the receiver's header directly without a second copy
25-29,33 if the address in the receive descriptor is within the 1TB user space, a receiver window base address in the sender VA space is constructed by adding the sender thread number * 16MB to the base of XKSSEG
27,30 and the receive descriptor address (rounded to a double word boundary) modulo 4MB is placed within that window and window_addr is set to that
Note: there are up to 4 sender fpages per thread
31 the base address of the receiver's window in the receiver's VA space is stored in the sender's tcb
this is assumed to be on a 4MB boundary
32 finally an attempt is made to read the mapped receiver's fpage which causes a page fault called a window fault. This results in a mapping being set up in the tlb so that the receive fpage can be accessed  in the sender's VA space (see listings 4.12 and 4.13)