def FindMicrocode(microcodes, model):
    """Find all the microcode chunks which match the given model.

    This model is something like 306a9 (the value returned in eax from
    cpuid(1) when running on Intel CPUs). But we allow a partial match,
    omitting the last 1 or two characters to allow many families to have the
    same microcode.

    If the model name is ambiguous we return a list of matches.

    Args:
        microcodes: Dict of Microcode objects indexed by name
        model:      String containing model name to find
    Returns:
        Tuple:
            List of matching Microcode objects
            List of abbreviations we tried
    """
    # Allow a full name to be used
    mcode = microcodes.get(model)
    if mcode:
        return [mcode], []

    tried = []
    found = []
    for i in range(3):
        abbrev = model[:-i] if i else model
        tried.append(abbrev)
        for mcode in microcodes.values():
            if mcode.model.startswith(abbrev):
                found.append(mcode)
        if found:
            break
    return found, tried