1.1 --- a/client/client.cc Sun Apr 11 19:34:07 2021 +0200 1.2 +++ b/client/client.cc Mon Apr 12 00:12:51 2021 +0200 1.3 @@ -30,7 +30,7 @@ 1.4 1.5 /* Default size of pipe regions. */ 1.6 1.7 -const offset_t DEFAULT_PIPE_SIZE = 4096; 1.8 +const length_t DEFAULT_PIPE_SIZE = 4096; 1.9 1.10 1.11 1.12 @@ -159,7 +159,7 @@ 1.13 1.14 /* Map a memory region to a file. */ 1.15 1.16 -void *client_mmap(file_t *file, offset_t position, offset_t length) 1.17 +void *client_mmap(file_t *file, offset_t position, length_t length) 1.18 { 1.19 if ((file == NULL) || (file_mmap(file, position, length))) 1.20 return NULL;
2.1 --- a/client/client.h Sun Apr 11 19:34:07 2021 +0200 2.2 +++ b/client/client.h Mon Apr 12 00:12:51 2021 +0200 2.3 @@ -34,7 +34,7 @@ 2.4 /* File and region operations. */ 2.5 2.6 long client_flush(file_t *file); 2.7 -void *client_mmap(file_t *file, offset_t position, offset_t length); 2.8 +void *client_mmap(file_t *file, offset_t position, length_t length); 2.9 2.10 /* Pipe region operations. */ 2.11
3.1 --- a/client/file.cc Sun Apr 11 19:34:07 2021 +0200 3.2 +++ b/client/file.cc Mon Apr 12 00:12:51 2021 +0200 3.3 @@ -124,7 +124,8 @@ 3.4 return -L4_EINVAL; 3.5 3.6 client_Opener opener(server); 3.7 - unsigned long size, flags; 3.8 + length_t size; 3.9 + flags_t flags; 3.10 long err; 3.11 3.12 file_init(file); 3.13 @@ -175,7 +176,7 @@ 3.14 /* Map a region of the given file to a memory region, obtaining an updated file 3.15 size and populated data details. Unmap any previously mapped region. */ 3.16 3.17 -long file_mmap(file_t *file, offset_t position, offset_t length) 3.18 +long file_mmap(file_t *file, offset_t position, length_t length) 3.19 { 3.20 char *memory = file->memory; 3.21 client_MappedFile mapped_file(file->ref); 3.22 @@ -217,15 +218,15 @@ 3.23 3.24 /* Return the amount of data in the mapped region for the given file. */ 3.25 3.26 -offset_t file_populated_span(file_t *file) 3.27 +length_t file_populated_span(file_t *file) 3.28 { 3.29 - offset_t size = file_span(file); 3.30 + length_t size = file_span(file); 3.31 return (file->data_end < size) ? file->data_end : size; 3.32 } 3.33 3.34 /* Return the size of the mapped region for the given file. */ 3.35 3.36 -offset_t file_span(file_t *file) 3.37 +length_t file_span(file_t *file) 3.38 { 3.39 return file->end_pos - file->start_pos; 3.40 } 3.41 @@ -235,9 +236,9 @@ 3.42 /* Get a pointer to any terminated string at the given offset or NULL if the 3.43 data from offset is not terminated. */ 3.44 3.45 -char *file_string_get(file_t *file, offset_t offset) 3.46 +char *file_string_get(file_t *file, length_t offset) 3.47 { 3.48 - offset_t limit = file_span(file) - offset; 3.49 + length_t limit = file_span(file) - offset; 3.50 3.51 if (strnlen(file->memory + offset, limit) < limit) 3.52 return file->memory + offset; 3.53 @@ -250,10 +251,10 @@ 3.54 characters copied, excluding the zero terminator is provided via the written 3.55 parameter if it is not specified as NULL. */ 3.56 3.57 -int file_string_set(file_t *file, const char *data, offset_t offset, 3.58 - offset_t *written) 3.59 +int file_string_set(file_t *file, const char *data, length_t offset, 3.60 + length_t *written) 3.61 { 3.62 - offset_t i, pos, limit = file_span(file); 3.63 + length_t i, pos, limit = file_span(file); 3.64 3.65 /* Do not attempt to copy data with an invalid offset. */ 3.66 3.67 @@ -292,7 +293,7 @@ 3.68 3.69 /* Return the number of remaining populated bytes in the region. */ 3.70 3.71 -offset_t file_data_available(file_t *file) 3.72 +length_t file_data_available(file_t *file) 3.73 { 3.74 return file_populated_span(file) - file->data_current; 3.75 } 3.76 @@ -304,6 +305,15 @@ 3.77 return file->memory + file->data_current; 3.78 } 3.79 3.80 +/* Return the amount of remaining space in the region. */ 3.81 + 3.82 +length_t file_data_space(file_t *file) 3.83 +{ 3.84 + return file_span(file) - file->data_current; 3.85 +} 3.86 + 3.87 + 3.88 + 3.89 /* Return the current access position in the file. */ 3.90 3.91 offset_t file_data_current_position(file_t *file) 3.92 @@ -318,13 +328,6 @@ 3.93 return file->start_pos + file->data_end; 3.94 } 3.95 3.96 -/* Return the amount of remaining space in the region. */ 3.97 - 3.98 -offset_t file_data_space(file_t *file) 3.99 -{ 3.100 - return file_span(file) - file->data_current; 3.101 -} 3.102 - 3.103 3.104 3.105 /* Copy data to the given buffer from the current data position, updating the 3.106 @@ -358,7 +361,7 @@ 3.107 3.108 /* Open two pipe endpoints using the given pipe server. */ 3.109 3.110 -long pipe_open(offset_t size, file_t *reader, file_t *writer, l4_cap_idx_t server) 3.111 +long pipe_open(length_t size, file_t *reader, file_t *writer, l4_cap_idx_t server) 3.112 { 3.113 if (l4_is_invalid_cap(server)) 3.114 return -L4_EINVAL; 3.115 @@ -437,7 +440,7 @@ 3.116 3.117 /* Set the size of the written region. */ 3.118 3.119 -long pipe_written(file_t *pipe, offset_t size) 3.120 +long pipe_written(file_t *pipe, length_t size) 3.121 { 3.122 if (size <= pipe->size) 3.123 {
4.1 --- a/client/file.h Sun Apr 11 19:34:07 2021 +0200 4.2 +++ b/client/file.h Mon Apr 12 00:12:51 2021 +0200 4.3 @@ -42,8 +42,8 @@ 4.4 /* File region parameters. */ 4.5 4.6 offset_t start_pos, end_pos; /* start and end positions of region */ 4.7 - offset_t data_end; /* amount/extent of data in the region */ 4.8 - offset_t data_current; /* client access offset */ 4.9 + length_t data_end; /* amount/extent of data in the region */ 4.10 + length_t data_current; /* client access offset */ 4.11 4.12 /* Total size of file. */ 4.13 4.14 @@ -71,26 +71,29 @@ 4.15 /* File and region operations. */ 4.16 4.17 long file_flush(file_t *file); 4.18 -long file_mmap(file_t *file, offset_t position, offset_t length); 4.19 +long file_mmap(file_t *file, offset_t position, length_t length); 4.20 long file_resize(file_t *file, offset_t size); 4.21 4.22 /* File and region properties. */ 4.23 4.24 -offset_t file_populated_span(file_t *file); 4.25 -offset_t file_span(file_t *file); 4.26 +length_t file_populated_span(file_t *file); 4.27 +length_t file_span(file_t *file); 4.28 4.29 /* Convenience functions. */ 4.30 4.31 -char *file_string_get(file_t *file, offset_t offset); 4.32 -int file_string_set(file_t *file, const char *data, offset_t offset, offset_t *written); 4.33 +char *file_string_get(file_t *file, length_t offset); 4.34 +int file_string_set(file_t *file, const char *data, length_t offset, length_t *written); 4.35 4.36 /* Client data functions. */ 4.37 4.38 -offset_t file_data_available(file_t *file); 4.39 +length_t file_data_available(file_t *file); 4.40 char *file_data_current(file_t *file); 4.41 +length_t file_data_space(file_t *file); 4.42 + 4.43 +/* Client data position functions. */ 4.44 + 4.45 offset_t file_data_current_position(file_t *file); 4.46 offset_t file_data_end_position(file_t *file); 4.47 -offset_t file_data_space(file_t *file); 4.48 4.49 /* Client data transfer functions. */ 4.50 4.51 @@ -101,13 +104,13 @@ 4.52 4.53 /* Pipe operations. */ 4.54 4.55 -long pipe_open(offset_t size, file_t *reader, file_t *writer, l4_cap_idx_t server); 4.56 +long pipe_open(length_t size, file_t *reader, file_t *writer, l4_cap_idx_t server); 4.57 4.58 /* Pipe region operations. */ 4.59 4.60 long pipe_current(file_t *pipe); 4.61 long pipe_next(file_t *pipe); 4.62 -long pipe_written(file_t *pipe, offset_t size); 4.63 +long pipe_written(file_t *pipe, length_t size); 4.64 4.65 EXTERN_C_END 4.66
5.1 --- a/files/block_file_accessor.cc Sun Apr 11 19:34:07 2021 +0200 5.2 +++ b/files/block_file_accessor.cc Mon Apr 12 00:12:51 2021 +0200 5.3 @@ -1,10 +1,9 @@ 5.4 #include <stdio.h> 5.5 +#include <stdlib.h> 5.6 #include <string.h> 5.7 #include <sys/types.h> 5.8 #include <sys/stat.h> 5.9 5.10 -#include <algorithm> 5.11 - 5.12 #include "block_file_accessor.h" 5.13 5.14 5.15 @@ -69,8 +68,11 @@ 5.16 void BlockFileAccessor::fill_populated(Flexpage *flexpage) 5.17 { 5.18 offset_t filepos = flexpage->base_offset; 5.19 - offset_t addr = flexpage->base_addr; 5.20 - offset_t populated_size = std::min(flexpage->size, _size - filepos); 5.21 + address_t addr = flexpage->base_addr; 5.22 + offset_t populated_size = _size - filepos; 5.23 + 5.24 + if (populated_size > flexpage->size) 5.25 + populated_size = flexpage->size; 5.26 5.27 /* Tag the region with file state. */ 5.28 5.29 @@ -91,8 +93,11 @@ 5.30 void BlockFileAccessor::flush_populated(Flexpage *flexpage) 5.31 { 5.32 offset_t filepos = flexpage->base_offset; 5.33 - offset_t addr = flexpage->base_addr; 5.34 - offset_t populated_size = std::min(flexpage->size, _size - filepos); 5.35 + address_t addr = flexpage->base_addr; 5.36 + offset_t populated_size = _size - filepos; 5.37 + 5.38 + if (populated_size > flexpage->size) 5.39 + populated_size = flexpage->size; 5.40 5.41 /* Remove the file state tag from the region. */ 5.42
6.1 --- a/files/file_pager.h Sun Apr 11 19:34:07 2021 +0200 6.2 +++ b/files/file_pager.h Mon Apr 12 00:12:51 2021 +0200 6.3 @@ -36,7 +36,7 @@ 6.4 6.5 /* Pager and mapped file methods. */ 6.6 6.7 - virtual long map(unsigned long offset, l4_addr_t hot_spot, flags_t flags, 6.8 + virtual long map(address_t offset, address_t hot_spot, flags_t flags, 6.9 l4_snd_fpage_t *region); 6.10 6.11 virtual long mmap(offset_t position, offset_t length, offset_t *start_pos,
7.1 --- a/files/opener_context_resource.h Sun Apr 11 19:34:07 2021 +0200 7.2 +++ b/files/opener_context_resource.h Mon Apr 12 00:12:51 2021 +0200 7.3 @@ -36,15 +36,15 @@ 7.4 7.5 /* Opener context interface methods. */ 7.6 7.7 - long open(flags_t flags, size_t *size, l4_cap_idx_t *file); 7.8 + long open(flags_t flags, offset_t *size, l4_cap_idx_t *file); 7.9 7.10 /* Pager/dataspace methods. */ 7.11 7.12 - long map(unsigned long offset, l4_addr_t hot_spot, flags_t flags, 7.13 + long map(address_t offset, address_t hot_spot, flags_t flags, 7.14 l4_snd_fpage_t *region) 7.15 { return SimplePager::map(offset, hot_spot, flags, region); } 7.16 7.17 - long info(unsigned long *size, unsigned long *flags) 7.18 + long info(length_t *size, flags_t *flags) 7.19 { return SimplePager::info(size, flags); } 7.20 }; 7.21
8.1 --- a/generic/pager.cc Sun Apr 11 19:34:07 2021 +0200 8.2 +++ b/generic/pager.cc Mon Apr 12 00:12:51 2021 +0200 8.3 @@ -46,13 +46,13 @@ 8.4 8.5 /* Expose a region of the file. */ 8.6 8.7 -long Pager::mmap(offset_t position, offset_t length, offset_t *start_pos, 8.8 +long Pager::mmap(offset_t position, length_t length, offset_t *start_pos, 8.9 offset_t *end_pos, offset_t *size) 8.10 { 8.11 /* Define region characteristics. */ 8.12 8.13 - _start = trunc(position, PAGE_SIZE); 8.14 - _size = round(position + length, PAGE_SIZE) - _start; 8.15 + _start = trunc_offset(position, PAGE_SIZE); 8.16 + _size = round_offset(position + length, PAGE_SIZE) - _start; 8.17 8.18 /* Return the start and end positions plus populated extent. */ 8.19 8.20 @@ -66,7 +66,7 @@ 8.21 /* Map a flexpage corresponding to the dataspace 'offset' involving a 'hot_spot' 8.22 (flexpage offset). */ 8.23 8.24 -long Pager::map(offset_t offset, l4_addr_t hot_spot, flags_t flags, 8.25 +long Pager::map(address_t offset, address_t hot_spot, flags_t flags, 8.26 l4_snd_fpage_t *region) 8.27 { 8.28 offset_t file_offset = _start + offset;
9.1 --- a/generic/pager.h Sun Apr 11 19:34:07 2021 +0200 9.2 +++ b/generic/pager.h Mon Apr 12 00:12:51 2021 +0200 9.3 @@ -23,7 +23,7 @@ 9.4 9.5 /* Paging methods. */ 9.6 9.7 - virtual long map(offset_t offset, l4_addr_t hot_spot, flags_t flags, 9.8 + virtual long map(address_t offset, address_t hot_spot, flags_t flags, 9.9 l4_snd_fpage_t *region); 9.10 9.11 /* Limit methods. */ 9.12 @@ -38,7 +38,7 @@ 9.13 9.14 /* Mapped file methods. */ 9.15 9.16 - virtual long mmap(offset_t position, offset_t length, offset_t *start_pos, 9.17 + virtual long mmap(offset_t position, length_t length, offset_t *start_pos, 9.18 offset_t *end_pos, offset_t *size); 9.19 }; 9.20
10.1 --- a/generic/simple_pager.cc Sun Apr 11 19:34:07 2021 +0200 10.2 +++ b/generic/simple_pager.cc Mon Apr 12 00:12:51 2021 +0200 10.3 @@ -29,7 +29,7 @@ 10.4 /* Map a flexpage corresponding to the dataspace 'offset' involving a 'hot_spot' 10.5 (flexpage offset). */ 10.6 10.7 -long SimplePager::map(offset_t offset, l4_addr_t hot_spot, flags_t flags, l4_snd_fpage_t *region) 10.8 +long SimplePager::map(address_t offset, address_t hot_spot, flags_t flags, l4_snd_fpage_t *region) 10.9 { 10.10 Flexpage flexpage(_region); 10.11 10.12 @@ -52,7 +52,7 @@ 10.13 return IPC_MESSAGE_SENT; 10.14 } 10.15 10.16 -long SimplePager::info(offset_t *size, flags_t *flags) 10.17 +long SimplePager::info(length_t *size, flags_t *flags) 10.18 { 10.19 *size = _region->size(); 10.20 *flags = L4_FPAGE_RW;
11.1 --- a/generic/simple_pager.h Sun Apr 11 19:34:07 2021 +0200 11.2 +++ b/generic/simple_pager.h Mon Apr 12 00:12:51 2021 +0200 11.3 @@ -22,9 +22,9 @@ 11.4 11.5 /* Paging methods. */ 11.6 11.7 - long map(offset_t offset, l4_addr_t hot_spot, flags_t flags, l4_snd_fpage_t *region); 11.8 + long map(address_t offset, address_t hot_spot, flags_t flags, l4_snd_fpage_t *region); 11.9 11.10 - long info(offset_t *size, flags_t *flags); 11.11 + long info(length_t *size, flags_t *flags); 11.12 }; 11.13 11.14 // vim: tabstop=4 expandtab shiftwidth=4
12.1 --- a/mapping/flexpage.cc Sun Apr 11 19:34:07 2021 +0200 12.2 +++ b/mapping/flexpage.cc Mon Apr 12 00:12:51 2021 +0200 12.3 @@ -30,7 +30,7 @@ 12.4 /* Get the file offset for the base of the flexpage. This will be a 12.5 multiple of the flexpage size for alignment purposes. */ 12.6 12.7 - base_offset = trunc(offset, size); 12.8 + base_offset = trunc_offset(offset, size); 12.9 12.10 /* The page being accessed is relative to the base. 12.11 (This is transient information recording the initialising access 12.12 @@ -86,23 +86,23 @@ 12.13 /* Return a "send" flexpage for an access to 'offset' by positioning it relative 12.14 to 'hot_spot' for the receive flexpage window. */ 12.15 12.16 -SendFlexpage Flexpage::to_send(offset_t offset, offset_t hot_spot, 12.17 +SendFlexpage Flexpage::to_send(offset_t offset, address_t hot_spot, 12.18 flags_t flags, offset_t max_offset) 12.19 { 12.20 /* The dataspace offset of the flexpage base is a multiple of the flexpage 12.21 size. */ 12.22 12.23 - offset_t receive_base_offset = trunc(offset, size); 12.24 + offset_t receive_base_offset = trunc_offset(offset, size); 12.25 12.26 /* The offset of the accessed page within the flexpage is constrained by the 12.27 current flexpage size. */ 12.28 12.29 - offset_t page_offset = trunc(offset - receive_base_offset, PAGE_SIZE); 12.30 + length_t page_offset = trunc(offset - receive_base_offset, PAGE_SIZE); 12.31 12.32 /* The receive flexpage offset (hot spot) must be constrained to the 12.33 flexpage, both the size and the start. */ 12.34 12.35 - offset_t receive_size; 12.36 + length_t receive_size; 12.37 12.38 if (max_offset) 12.39 { 12.40 @@ -115,7 +115,7 @@ 12.41 if (!receive_size) 12.42 return SendFlexpage(base_addr, page_order(0), flags); 12.43 12.44 - offset_t receive_page_offset = hot_spot % receive_size; 12.45 + length_t receive_page_offset = hot_spot % receive_size; 12.46 12.47 while ((receive_size > PAGE_SIZE) && (receive_page_offset != page_offset)) 12.48 { 12.49 @@ -127,7 +127,7 @@ 12.50 offsets. Where the receive flexpage offset is constained further, the 12.51 base address will be raised to become closer to the accessed page. */ 12.52 12.53 - offset_t adjustment = page_offset - receive_page_offset; 12.54 + length_t adjustment = page_offset - receive_page_offset; 12.55 12.56 return SendFlexpage(base_addr + adjustment, page_order(receive_size), flags); 12.57 }
13.1 --- a/mapping/flexpage.h Sun Apr 11 19:34:07 2021 +0200 13.2 +++ b/mapping/flexpage.h Mon Apr 12 00:12:51 2021 +0200 13.3 @@ -19,12 +19,14 @@ 13.4 13.5 /* General flexpage characteristics. */ 13.6 13.7 - offset_t base_addr, size; 13.8 + address_t base_addr; 13.9 + length_t size; 13.10 offset_t base_offset; 13.11 13.12 /* Transient debugging information. */ 13.13 13.14 - offset_t page_addr, page_offset; 13.15 + address_t page_addr; 13.16 + length_t page_offset; 13.17 13.18 /* Associate a flexpage with a memory 'region'. */ 13.19 13.20 @@ -46,7 +48,7 @@ 13.21 13.22 void upgrade(flags_t flags); 13.23 13.24 - SendFlexpage to_send(offset_t offset, offset_t hot_spot, flags_t flags, 13.25 + SendFlexpage to_send(offset_t offset, address_t hot_spot, flags_t flags, 13.26 offset_t max_offset=0); 13.27 13.28 SendFlexpage to_unmap();
14.1 --- a/mapping/ipc.cc Sun Apr 11 19:34:07 2021 +0200 14.2 +++ b/mapping/ipc.cc Mon Apr 12 00:12:51 2021 +0200 14.3 @@ -17,8 +17,8 @@ 14.4 14.5 /* Make a representation of a flexpage for the IPC system. */ 14.6 14.7 -long ipc_prepare_flexpage(Flexpage *flexpage, unsigned long offset, 14.8 - unsigned long max_offset, l4_addr_t hot_spot, 14.9 +long ipc_prepare_flexpage(Flexpage *flexpage, offset_t offset, 14.10 + offset_t max_offset, address_t hot_spot, 14.11 flags_t flags, l4_snd_fpage_t *region) 14.12 { 14.13 SendFlexpage send_flexpage = flexpage->to_send(offset, hot_spot, flags,
15.1 --- a/mapping/ipc.h Sun Apr 11 19:34:07 2021 +0200 15.2 +++ b/mapping/ipc.h Mon Apr 12 00:12:51 2021 +0200 15.3 @@ -6,8 +6,8 @@ 15.4 15.5 15.6 15.7 -long ipc_prepare_flexpage(Flexpage *flexpage, unsigned long offset, 15.8 - unsigned long max_offset, l4_addr_t hot_spot, 15.9 +long ipc_prepare_flexpage(Flexpage *flexpage, offset_t offset, 15.10 + offset_t max_offset, address_t hot_spot, 15.11 flags_t flags, l4_snd_fpage_t *region); 15.12 15.13 void ipc_unmap_flexpage(Flexpage *flexpage);
16.1 --- a/mapping/send_flexpage.h Sun Apr 11 19:34:07 2021 +0200 16.2 +++ b/mapping/send_flexpage.h Mon Apr 12 00:12:51 2021 +0200 16.3 @@ -7,11 +7,11 @@ 16.4 class SendFlexpage 16.5 { 16.6 public: 16.7 - offset_t base_addr; 16.8 + address_t base_addr; 16.9 unsigned int order; 16.10 flags_t flags; 16.11 16.12 - explicit SendFlexpage(offset_t base_addr, unsigned int order, 16.13 + explicit SendFlexpage(address_t base_addr, unsigned int order, 16.14 flags_t flags) 16.15 : base_addr(base_addr), order(order), flags(flags) 16.16 {
17.1 --- a/memory/memory.h Sun Apr 11 19:34:07 2021 +0200 17.2 +++ b/memory/memory.h Mon Apr 12 00:12:51 2021 +0200 17.3 @@ -15,7 +15,7 @@ 17.4 17.5 virtual Region *region() = 0; 17.6 17.7 - virtual offset_t region_size() = 0; 17.8 + virtual length_t region_size() = 0; 17.9 17.10 virtual void release(Region *region) = 0; 17.11 };
18.1 --- a/memory/memory_incremental.cc Sun Apr 11 19:34:07 2021 +0200 18.2 +++ b/memory/memory_incremental.cc Mon Apr 12 00:12:51 2021 +0200 18.3 @@ -5,7 +5,7 @@ 18.4 18.5 /* Initialise the memory pool with an optional 'limit' in pages. */ 18.6 18.7 -MemoryIncremental::MemoryIncremental(unsigned int limit, offset_t region_size) 18.8 +MemoryIncremental::MemoryIncremental(unsigned int limit, length_t region_size) 18.9 : _limit(limit), _region_size(region_size) 18.10 { 18.11 _limited = true; 18.12 @@ -19,7 +19,7 @@ 18.13 18.14 /* Allocate a block of the given 'size'. */ 18.15 18.16 -Region *MemoryIncremental::allocate(offset_t size) 18.17 +Region *MemoryIncremental::allocate(length_t size) 18.18 { 18.19 /* Attempt to allocate aligned memory. */ 18.20 18.21 @@ -32,17 +32,17 @@ 18.22 if (posix_memalign(¤t, size, size)) 18.23 return NULL; 18.24 18.25 - return new Region((offset_t) current, (offset_t) current + size); 18.26 + return new Region((address_t) current, (address_t) current + size); 18.27 } 18.28 18.29 /* Allocate a new region of the given 'size' rounded to the nearest page. */ 18.30 18.31 -Region *MemoryIncremental::region(offset_t size) 18.32 +Region *MemoryIncremental::region(length_t size) 18.33 { 18.34 std::lock_guard<std::mutex> guard(_lock); 18.35 18.36 - offset_t rounded = round(size, PAGE_SIZE); 18.37 - offset_t pages = rounded / PAGE_SIZE; 18.38 + length_t rounded = round(size, PAGE_SIZE); 18.39 + length_t pages = rounded / PAGE_SIZE; 18.40 18.41 /* Check for sufficient pages. */ 18.42 18.43 @@ -78,8 +78,8 @@ 18.44 { 18.45 std::lock_guard<std::mutex> guard(_lock); 18.46 18.47 - offset_t rounded = round(region->size(), PAGE_SIZE); 18.48 - offset_t pages = rounded / PAGE_SIZE; 18.49 + length_t rounded = round(region->size(), PAGE_SIZE); 18.50 + length_t pages = rounded / PAGE_SIZE; 18.51 18.52 if (_limited) 18.53 _limit += pages;
19.1 --- a/memory/memory_incremental.h Sun Apr 11 19:34:07 2021 +0200 19.2 +++ b/memory/memory_incremental.h Mon Apr 12 00:12:51 2021 +0200 19.3 @@ -17,21 +17,21 @@ 19.4 std::mutex _lock; 19.5 19.6 unsigned int _limit; 19.7 - offset_t _region_size; 19.8 + length_t _region_size; 19.9 bool _limited; 19.10 19.11 - Region *allocate(offset_t size); 19.12 + Region *allocate(length_t size); 19.13 19.14 public: 19.15 - explicit MemoryIncremental(unsigned int limit, offset_t region_size=PAGE_SIZE); 19.16 + explicit MemoryIncremental(unsigned int limit, length_t region_size=PAGE_SIZE); 19.17 19.18 explicit MemoryIncremental(); 19.19 19.20 - virtual Region *region(offset_t size); 19.21 + virtual Region *region(length_t size); 19.22 19.23 virtual Region *region(); 19.24 19.25 - virtual offset_t region_size() 19.26 + virtual length_t region_size() 19.27 { return _region_size; } 19.28 19.29 virtual void release(Region *region);
20.1 --- a/memory/memory_preallocated.cc Sun Apr 11 19:34:07 2021 +0200 20.2 +++ b/memory/memory_preallocated.cc Mon Apr 12 00:12:51 2021 +0200 20.3 @@ -4,12 +4,12 @@ 20.4 20.5 /* Initialise the memory pool with the given amount in bytes. */ 20.6 20.7 -MemoryPreallocated::MemoryPreallocated(Memory *memory, offset_t amount) 20.8 +MemoryPreallocated::MemoryPreallocated(Memory *memory, length_t amount) 20.9 : _memory(memory), _amount(amount) 20.10 { 20.11 // NOTE: Handle allocation failure. 20.12 20.13 - offset_t remaining = amount; 20.14 + length_t remaining = amount; 20.15 20.16 while (remaining) 20.17 {
21.1 --- a/memory/memory_preallocated.h Sun Apr 11 19:34:07 2021 +0200 21.2 +++ b/memory/memory_preallocated.h Mon Apr 12 00:12:51 2021 +0200 21.3 @@ -18,10 +18,10 @@ 21.4 std::list<Region *> _regions; 21.5 21.6 Memory *_memory; 21.7 - offset_t _amount; 21.8 + length_t _amount; 21.9 21.10 public: 21.11 - explicit MemoryPreallocated(Memory *memory, offset_t amount); 21.12 + explicit MemoryPreallocated(Memory *memory, length_t amount); 21.13 21.14 explicit MemoryPreallocated(); 21.15 21.16 @@ -29,7 +29,7 @@ 21.17 21.18 virtual Region *region(); 21.19 21.20 - virtual offset_t region_size() 21.21 + virtual length_t region_size() 21.22 { return _memory->region_size(); } 21.23 21.24 virtual void release(Region *region);
22.1 --- a/memory/memory_utils.cc Sun Apr 11 19:34:07 2021 +0200 22.2 +++ b/memory/memory_utils.cc Mon Apr 12 00:12:51 2021 +0200 22.3 @@ -4,14 +4,14 @@ 22.4 22.5 /* Return page 'n' for the configured page size. */ 22.6 22.7 -offset_t page(unsigned int n) 22.8 +length_t page(unsigned int n) 22.9 { 22.10 return PAGE_SIZE * n; 22.11 } 22.12 22.13 /* Return the order of 'size', where 2 ** order yields the size. */ 22.14 22.15 -unsigned int page_order(offset_t size) 22.16 +unsigned int page_order(length_t size) 22.17 { 22.18 /* Count zeros from the left, stopping at the first set bit, using the width 22.19 of the size value (in bits, starting with the width in bytes) to 22.20 @@ -22,16 +22,21 @@ 22.21 22.22 /* Return 'value' rounded up to the nearest 'increment'. */ 22.23 22.24 -offset_t round(offset_t value, offset_t increment) 22.25 +length_t round(length_t value, length_t increment) 22.26 { 22.27 return trunc(value + increment - 1, increment); 22.28 } 22.29 22.30 +offset_t round_offset(offset_t value, length_t increment) 22.31 +{ 22.32 + return trunc_offset(value + increment - 1, increment); 22.33 +} 22.34 + 22.35 /* Return 'value' rounded up to the nearest multiple of 'increment'. */ 22.36 22.37 -offset_t round_multiple(offset_t value, offset_t increment) 22.38 +length_t round_multiple(length_t value, length_t increment) 22.39 { 22.40 - offset_t last = increment; 22.41 + length_t last = increment; 22.42 22.43 while (1) 22.44 { 22.45 @@ -45,7 +50,12 @@ 22.46 22.47 /* Return 'value' rounded down (or truncated) to the nearest 'increment'. */ 22.48 22.49 -offset_t trunc(offset_t value, offset_t increment) 22.50 +length_t trunc(length_t value, length_t increment) 22.51 +{ 22.52 + return (value / increment) * increment; 22.53 +} 22.54 + 22.55 +offset_t trunc_offset(offset_t value, length_t increment) 22.56 { 22.57 return (value / increment) * increment; 22.58 } 22.59 @@ -53,9 +63,9 @@ 22.60 /* Return 'value' rounded down (or truncated) to the nearest multiple of 22.61 'increment'. */ 22.62 22.63 -offset_t trunc_multiple(offset_t value, offset_t increment) 22.64 +length_t trunc_multiple(length_t value, length_t increment) 22.65 { 22.66 - offset_t last = increment; 22.67 + length_t last = increment; 22.68 22.69 while (1) 22.70 { 22.71 @@ -70,15 +80,15 @@ 22.72 /* Find the maximum size aligned region within the region from 'start' to (but 22.73 not including) 'end', with the given initial 'increment'. */ 22.74 22.75 -offset_t max_multiple(offset_t start, offset_t end, offset_t increment) 22.76 +length_t max_multiple(length_t start, length_t end, length_t increment) 22.77 { 22.78 /* The largest possible aligned region is derived from the region size. */ 22.79 22.80 - offset_t size = trunc_multiple(end - start, increment); 22.81 + length_t size = trunc_multiple(end - start, increment); 22.82 22.83 /* Apply the alignment to the start. */ 22.84 22.85 - offset_t aligned = round(start, size); 22.86 + length_t aligned = round(start, size); 22.87 22.88 /* If the region is aligned, return the size. */ 22.89 22.90 @@ -88,7 +98,7 @@ 22.91 /* If the region is not aligned to the current size, recalculate the aligned 22.92 size. */ 22.93 22.94 - offset_t aligned_size; 22.95 + length_t aligned_size; 22.96 22.97 do 22.98 {
23.1 --- a/memory/memory_utils.h Sun Apr 11 19:34:07 2021 +0200 23.2 +++ b/memory/memory_utils.h Mon Apr 12 00:12:51 2021 +0200 23.3 @@ -8,18 +8,22 @@ 23.4 23.5 /* Address arithmetic. */ 23.6 23.7 -offset_t page(unsigned int n); 23.8 +length_t page(unsigned int n); 23.9 + 23.10 +unsigned int page_order(length_t size); 23.11 23.12 -unsigned int page_order(offset_t size); 23.13 +length_t round(length_t value, length_t increment); 23.14 23.15 -offset_t round(offset_t value, offset_t increment); 23.16 +offset_t round_offset(offset_t value, length_t increment); 23.17 23.18 -offset_t round_multiple(offset_t value, offset_t increment); 23.19 +length_t round_multiple(length_t value, length_t increment); 23.20 23.21 -offset_t trunc(offset_t value, offset_t increment); 23.22 +length_t trunc(length_t value, length_t increment); 23.23 23.24 -offset_t trunc_multiple(offset_t value, offset_t increment); 23.25 +offset_t trunc_offset(offset_t value, length_t increment); 23.26 23.27 -offset_t max_multiple(offset_t start, offset_t end, offset_t increment); 23.28 +length_t trunc_multiple(length_t value, length_t increment); 23.29 + 23.30 +length_t max_multiple(length_t start, length_t end, length_t increment); 23.31 23.32 // vim: tabstop=4 expandtab shiftwidth=4
24.1 --- a/memory/region.cc Sun Apr 11 19:34:07 2021 +0200 24.2 +++ b/memory/region.cc Mon Apr 12 00:12:51 2021 +0200 24.3 @@ -23,7 +23,7 @@ 24.4 /* Initialise a region having the given 'start' and 'end' addresses, with the 24.5 'end' being one location beyond the last address in the region. */ 24.6 24.7 -Region::Region(offset_t start, offset_t end) 24.8 +Region::Region(address_t start, address_t end) 24.9 : start(start), end(end), state(end - start) 24.10 { 24.11 /* Content state. */ 24.12 @@ -36,7 +36,7 @@ 24.13 free((void *) start); 24.14 } 24.15 24.16 -offset_t Region::size() 24.17 +length_t Region::size() 24.18 { 24.19 return end - start; 24.20 } 24.21 @@ -64,7 +64,7 @@ 24.22 24.23 /* Simulation methods. */ 24.24 24.25 -char *Region::read(offset_t offset) 24.26 +char *Region::read(length_t offset) 24.27 { 24.28 if (offset < size()) 24.29 return (char *) start + offset; 24.30 @@ -72,7 +72,7 @@ 24.31 return NULL; 24.32 } 24.33 24.34 -void Region::write(const char *data, offset_t offset) 24.35 +void Region::write(const char *data, length_t offset) 24.36 { 24.37 size_t length = strlen(data); 24.38
25.1 --- a/memory/region.h Sun Apr 11 19:34:07 2021 +0200 25.2 +++ b/memory/region.h Mon Apr 12 00:12:51 2021 +0200 25.3 @@ -29,7 +29,7 @@ 25.4 class Region 25.5 { 25.6 public: 25.7 - offset_t start, end; 25.8 + address_t start, end; 25.9 25.10 /* Debugging information. */ 25.11 25.12 @@ -37,11 +37,11 @@ 25.13 25.14 /* Methods. */ 25.15 25.16 - explicit Region(offset_t start, offset_t end); 25.17 + explicit Region(address_t start, address_t end); 25.18 25.19 virtual ~Region(); 25.20 25.21 - offset_t size(); 25.22 + length_t size(); 25.23 25.24 int compare(Region *other); 25.25 25.26 @@ -51,9 +51,9 @@ 25.27 25.28 /* Simulation methods. */ 25.29 25.30 - char *read(offset_t offset=0); 25.31 + char *read(length_t offset=0); 25.32 25.33 - void write(const char *data, offset_t offset=0); 25.34 + void write(const char *data, length_t offset=0); 25.35 }; 25.36 25.37 // vim: tabstop=4 expandtab shiftwidth=4
26.1 --- a/pipes/pipe_pager.cc Sun Apr 11 19:34:07 2021 +0200 26.2 +++ b/pipes/pipe_pager.cc Mon Apr 12 00:12:51 2021 +0200 26.3 @@ -38,7 +38,7 @@ 26.4 26.5 /* Support paging. */ 26.6 26.7 -long PipePager::map(unsigned long offset, l4_addr_t hot_spot, flags_t flags, l4_snd_fpage_t *region) 26.8 +long PipePager::map(address_t offset, address_t hot_spot, flags_t flags, l4_snd_fpage_t *region) 26.9 { 26.10 return Pager::map(offset, hot_spot, flags, region); 26.11 }
27.1 --- a/pipes/pipe_pager.h Sun Apr 11 19:34:07 2021 +0200 27.2 +++ b/pipes/pipe_pager.h Mon Apr 12 00:12:51 2021 +0200 27.3 @@ -35,7 +35,7 @@ 27.4 27.5 /* Pager methods. */ 27.6 27.7 - virtual long map(unsigned long offset, l4_addr_t hot_spot, flags_t flags, l4_snd_fpage_t *region); 27.8 + virtual long map(address_t offset, address_t hot_spot, flags_t flags, l4_snd_fpage_t *region); 27.9 27.10 /* Pipe methods. */ 27.11
28.1 --- a/tests/dstest_pipe_client.cc Sun Apr 11 19:34:07 2021 +0200 28.2 +++ b/tests/dstest_pipe_client.cc Mon Apr 12 00:12:51 2021 +0200 28.3 @@ -31,13 +31,13 @@ 28.4 28.5 28.6 28.7 -static void show(file_t *file, offset_t step, offset_t sample) 28.8 +static void show(file_t *file, length_t step, length_t sample) 28.9 { 28.10 /* Allocate a buffer for sampling from the file. */ 28.11 28.12 char buf[sample + 1]; 28.13 28.14 - for (offset_t offset = 0; offset < file_populated_span(file); offset += step) 28.15 + for (length_t offset = 0; offset < file_populated_span(file); offset += step) 28.16 { 28.17 printf("show %ld of %ld...\n", offset, file_populated_span(file)); 28.18