L4Re/departure

Annotated libsystypes/lib/src/base.c

645:3047b11cc814
7 months ago Paul Boddie Fixed the file_data_available result to return zero if the populated span has somehow become less than the current position in the memory region.
paul@472 1
/*
paul@472 2
 * Utility functions for base types.
paul@472 3
 *
paul@472 4
 * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk>
paul@472 5
 *
paul@472 6
 * This program is free software; you can redistribute it and/or
paul@472 7
 * modify it under the terms of the GNU General Public License as
paul@472 8
 * published by the Free Software Foundation; either version 2 of
paul@472 9
 * the License, or (at your option) any later version.
paul@472 10
 *
paul@472 11
 * This program is distributed in the hope that it will be useful,
paul@472 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@472 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
paul@472 14
 * GNU General Public License for more details.
paul@472 15
 *
paul@472 16
 * You should have received a copy of the GNU General Public License
paul@472 17
 * along with this program; if not, write to the Free Software
paul@472 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
paul@472 19
 * Boston, MA  02110-1301, USA
paul@472 20
 */
paul@472 21
paul@472 22
#include <l4/re/c/dataspace.h>
paul@472 23
paul@472 24
#include "base.h"
paul@472 25
paul@472 26
paul@472 27
paul@472 28
/* Return mapping flags corresponding to page fault flags. */
paul@472 29
paul@472 30
map_flags_t map_flags_for_fault(l4_umword_t flags)
paul@472 31
{
paul@472 32
  map_flags_t map_flags = (flags & 4 ? L4RE_DS_F_RX : 0) |
paul@472 33
                          (flags & 2 ? L4RE_DS_F_W : 0) |
paul@472 34
                          (flags & 1 ? L4RE_DS_F_R : 0);
paul@472 35
paul@472 36
  if (!map_flags)
paul@472 37
    map_flags = L4RE_DS_F_R;
paul@472 38
paul@472 39
  return map_flags;
paul@472 40
}
paul@472 41
paul@472 42
// vim: tabstop=2 expandtab shiftwidth=2