<commit_before>/*
 * Copyright (c) 2021 <NAME>
 *
 * Use of this source code is governed by a MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT
 */
#include "resource.h"

#include <dev/bus/pci.h>
#include <lk/err.h>
#include <lk/trace.h>
#include <stdint.h>

#define LOCAL_TRACE 0

namespace pci {

resource_range &resource_allocator::type_to_range(pci_resource_type type, bool prefetchable) {
    if (prefetchable) {
        switch (type) {
            case PCI_RESOURCE_MMIO_RANGE:
                return ranges_.mmio_prefetchable;
            case PCI_RESOURCE_MMIO64_RANGE:
                return ranges_.mmio64_prefetchable;
            default:
                DEBUG_ASSERT_MSG(0, "uhandled prefetchable pci resource type %d\n", type);
        }
    } else {
        switch (type) {
            case PCI_RESOURCE_IO_RANGE:
                return ranges_.io;
            case PCI_RESOURCE_MMIO_RANGE:
                return ranges_.mmio;
            case PCI_RESOURCE_MMIO64_RANGE:
                return ranges_.mmio64;
            default:
                DEBUG_ASSERT_MSG(0, "uhandled pci resource type %d\n", type);
        }
    }
}<commit_msg>[bus][pci] Make sure there's a fallback range in release mode<commit_after>/*
 * Copyright (c) 2021 <NAME>
 *
 * Use of this source code is governed by a MIT-style
 * license that can be found in the LICENSE file or at
 * https://opensource.org/licenses/MIT
 */
#include "resource.h"

#include <dev/bus/pci.h>
#include <lk/err.h>
#include <lk/trace.h>
#include <stdint.h>

#define LOCAL_TRACE 0

namespace pci {

resource_range &resource_allocator::type_to_range(pci_resource_type type, bool prefetchable) {
    if (prefetchable) {
        switch (type) {
            case PCI_RESOURCE_MMIO_RANGE:
                return ranges_.mmio_prefetchable;
            case PCI_RESOURCE_MMIO64_RANGE:
                return ranges_.mmio64_prefetchable;
            default:
                DEBUG_ASSERT_MSG(0, "uhandled prefetchable pci resource type %d\n", type);
        }
    } else {
        switch (type) {
            case PCI_RESOURCE_IO_RANGE:
                return ranges_.io;
            case PCI_RESOURCE_MMIO_RANGE:
                return ranges_.mmio;
            case PCI_RESOURCE_MMIO64_RANGE:
                return ranges_.mmio64;
            default:
                DEBUG_ASSERT_MSG(0, "uhandled pci resource type %d\n", type);
        }
    }
    static resource_range zero = {};
    return zero;
}
{'fraction_non_alphanumeric': 0.08816521048451152, 'fraction_numerical': 0.011914217633042097, 'mean_word_length': 2.200762388818297, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5302497', 'n_tokens_mistral': 805, 'n_tokens_neox': 789, 'n_words': 196}