1.1 --- a/libexec/lib/src/segment.cc Wed May 11 01:23:28 2022 +0200
1.2 +++ b/libexec/lib/src/segment.cc Wed May 11 16:37:05 2022 +0200
1.3 @@ -35,12 +35,27 @@
1.4
1.5 Segment::Segment(l4_addr_t base, offset_t size, l4re_rm_flags_t flags,
1.6 offset_t file_offset, offset_t file_contents)
1.7 -: base(base), size(size), flags(flags), file_offset(file_offset),
1.8 - file_contents(file_contents)
1.9 +
1.10 +: _base(base), _size(size), _flags(flags), _file_offset(file_offset),
1.11 + _file_contents(file_contents)
1.12 {
1.13 - region_base = trunc(base, L4_PAGESIZE);
1.14 - region_offset = base - region_base;
1.15 - region_size = round(size, L4_PAGESIZE);
1.16 + _region_base = trunc(_base, L4_PAGESIZE);
1.17 + _region_offset = _base - _region_base;
1.18 + _region_size = round(_size, L4_PAGESIZE);
1.19 +}
1.20 +
1.21 +/* Return the address of allocated memory. */
1.22 +
1.23 +char *Segment::address()
1.24 +{
1.25 + return _buf;
1.26 +}
1.27 +
1.28 +/* Return the size of the allocated memory. */
1.29 +
1.30 +offset_t Segment::size()
1.31 +{
1.32 + return _size;
1.33 }
1.34
1.35 /* Allocate a region for the segment. */
1.36 @@ -49,27 +64,27 @@
1.37 {
1.38 /* Make regions writable if they need to be filled. */
1.39
1.40 - l4re_rm_flags_t allocation_flags = flags;
1.41 + l4re_rm_flags_t allocation_flags = _flags;
1.42
1.43 - if (file_contents)
1.44 + if (_file_contents)
1.45 allocation_flags |= L4RE_RM_F_W;
1.46
1.47 - return ipc_allocate_align(size, L4RE_RM_F_SEARCH_ADDR | allocation_flags,
1.48 - L4_PAGESHIFT, (void **) &buf, &ds);
1.49 + return ipc_allocate_align(_size, L4RE_RM_F_SEARCH_ADDR | allocation_flags,
1.50 + L4_PAGESHIFT, (void **) &_buf, &_ds);
1.51 }
1.52
1.53 /* Fill a segment region with file content. */
1.54
1.55 long Segment::fill(file_t *file)
1.56 {
1.57 - if (!file_contents)
1.58 + if (!_file_contents)
1.59 return L4_EOK;
1.60
1.61 - memset(buf, 0, region_size);
1.62 - client_seek(file, file_offset, SEEK_SET);
1.63 - offset_t nread = client_read(file, buf + region_offset, file_contents);
1.64 + memset(_buf, 0, _region_size);
1.65 + client_seek(file, _file_offset, SEEK_SET);
1.66 + offset_t nread = client_read(file, _buf + _region_offset, _file_contents);
1.67
1.68 - if (nread < file_contents)
1.69 + if (nread < _file_contents)
1.70 return -L4_EIO;
1.71 else
1.72 return L4_EOK;
1.73 @@ -79,7 +94,7 @@
1.74
1.75 MappedRegion &Segment::region()
1.76 {
1.77 - _region = MappedRegion((l4_addr_t) buf, page_order(region_size), flags, region_base);
1.78 + _region = MappedRegion((l4_addr_t) _buf, page_order(_region_size), _flags, _region_base);
1.79 return _region;
1.80 }
1.81
1.82 @@ -87,12 +102,12 @@
1.83
1.84 l4_addr_t Segment::region_address(char *address)
1.85 {
1.86 - return (l4_addr_t) ((address - buf) + (char *) region_base);
1.87 + return (l4_addr_t) ((address - _buf) + (char *) _region_base);
1.88 }
1.89
1.90 l4_addr_t Segment::region_address(l4_addr_t address)
1.91 {
1.92 - return (address - (l4_addr_t) buf) + region_base;
1.93 + return (address - (l4_addr_t) _buf) + _region_base;
1.94 }
1.95
1.96 /* vim: tabstop=2 expandtab shiftwidth=2