\hypertarget{smccc_8c_source}{}\doxysection{smccc.\+c}
\label{smccc_8c_source}\index{dev/psci/smccc.c@{dev/psci/smccc.c}}
\mbox{\hyperlink{smccc_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2018 Andrew Turner}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00005}00005 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00006}00006 \textcolor{comment}{ * This software was developed by SRI International and the University of}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00007}00007 \textcolor{comment}{ * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-\/10-\/C-\/0237}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00008}00008 \textcolor{comment}{ * ("{}CTSRD"{}), as part of the DARPA CRASH research programme.}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00009}00009 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00010}00010 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00011}00011 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00012}00012 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00013}00013 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00014}00014 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00015}00015 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00016}00016 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00017}00017 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00018}00018 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00019}00019 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00020}00020 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00021}00021 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00022}00022 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00023}00023 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00024}00024 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00025}00025 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00026}00026 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00027}00027 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00028}00028 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00029}00029 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00030}00030 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00032}00032 \textcolor{preprocessor}{\#include "{}opt\_acpi.h"{}}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00033}00033 \textcolor{preprocessor}{\#include "{}opt\_platform.h"{}}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00034}00034 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00036}\mbox{\hyperlink{smccc_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00036}} \mbox{\hyperlink{smccc_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00037}00037 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00041}00041 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{psci_8h}{dev/psci/psci.h}}>}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <\mbox{\hyperlink{smccc_8h}{dev/psci/smccc.h}}>}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00044}00044 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00045}\mbox{\hyperlink{smccc_8c_ad8194a9940950453c6e71e75a349d0b0}{00045}} \textcolor{preprocessor}{\#define SMCCC\_VERSION\_1\_0       0x10000}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00046}00046 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00047}00047 \textcolor{comment}{/* Assume 1.0 until we detect a later version */}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00048}\mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{00048}} \textcolor{keyword}{static} uint32\_t \mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{smccc\_version}} = \mbox{\hyperlink{smccc_8c_ad8194a9940950453c6e71e75a349d0b0}{SMCCC\_VERSION\_1\_0}};}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00049}00049 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00050}00050 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00051}\mbox{\hyperlink{smccc_8c_a5a2f7a69737526dd36be352b10223988}{00051}} \mbox{\hyperlink{smccc_8c_a5a2f7a69737526dd36be352b10223988}{smccc\_init}}(\textcolor{keywordtype}{void} *dummy)}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00052}00052 \{}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00053}00053         int32\_t features;}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00054}00054         uint32\_t ret;}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00055}00055 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00056}00056         features = \mbox{\hyperlink{psci_8c_ac19baf3809c2e1cb0af57e29aa9f74c9}{psci\_features}}(\mbox{\hyperlink{smccc_8h_adfdd7c12888ec75656906624f89fe305}{SMCCC\_VERSION}});}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00057}00057         \textcolor{keywordflow}{if} (features != \mbox{\hyperlink{psci_8h_a7b5d6153e1dcf5f3f25ecf3a3d165434}{PSCI\_RETVAL\_NOT\_SUPPORTED}}) \{}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00058}00058                 ret = \mbox{\hyperlink{psci_8h_a6c24155fd6c168843938b6b742714a60}{psci\_call}}(\mbox{\hyperlink{smccc_8h_adfdd7c12888ec75656906624f89fe305}{SMCCC\_VERSION}}, 0, 0, 0);}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00059}00059                 \textcolor{comment}{/* This should always be the case as we checked it above */}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00060}00060                 \textcolor{keywordflow}{if} (ret > 0)}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00061}00061                         \mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{smccc\_version}} = ret;}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00062}00062         \}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00063}00063 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00064}00064         \textcolor{keywordflow}{if} (bootverbose) \{}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00065}00065                 printf(\textcolor{stringliteral}{"{}Found SMCCC version \%u.\%u\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00066}00066                     \mbox{\hyperlink{smccc_8h_a9fff92534ab3d44cd9a6077a209f54b8}{SMCCC\_VERSION\_MAJOR}}(\mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{smccc\_version}}),}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00067}00067                     \mbox{\hyperlink{smccc_8h_adf32fce2c1d1c800d745a455bd2a922a}{SMCCC\_VERSION\_MINOR}}(\mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{smccc\_version}}));}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00068}00068         \}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00069}00069 \}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00070}\mbox{\hyperlink{smccc_8c_a9d30648b1999bc17d0294829e1b879f9}{00070}} \mbox{\hyperlink{smccc_8c_a9d30648b1999bc17d0294829e1b879f9}{SYSINIT}}(smccc\_start, SI\_SUB\_CONFIGURE, SI\_ORDER\_ANY, \mbox{\hyperlink{smccc_8c_a5a2f7a69737526dd36be352b10223988}{smccc\_init}}, NULL);}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00071}00071 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00072}00072 int32\_t}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00073}\mbox{\hyperlink{smccc_8c_a1d98dd2c8b9ad38174feb32bae2f3912}{00073}} \mbox{\hyperlink{smccc_8c_a1d98dd2c8b9ad38174feb32bae2f3912}{smccc\_arch\_features}}(uint32\_t smccc\_func\_id)}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00074}00074 \{}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00075}00075 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00076}00076         \textcolor{keywordflow}{if} (\mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{smccc\_version}} == \mbox{\hyperlink{smccc_8c_ad8194a9940950453c6e71e75a349d0b0}{SMCCC\_VERSION\_1\_0}})}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00077}00077                 \textcolor{keywordflow}{return} (\mbox{\hyperlink{psci_8h_a7b5d6153e1dcf5f3f25ecf3a3d165434}{PSCI\_RETVAL\_NOT\_SUPPORTED}});}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00078}00078 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00079}00079         \textcolor{keywordflow}{return} (\mbox{\hyperlink{psci_8h_a6c24155fd6c168843938b6b742714a60}{psci\_call}}(\mbox{\hyperlink{smccc_8h_af2b95c0e15bdb8bfd7188bf9a42caa13}{SMCCC\_ARCH\_FEATURES}}, smccc\_func\_id, 0, 0));}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00080}00080 \}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00081}00081 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00082}00082 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00083}00083 \textcolor{comment}{ * The SMCCC handler for Spectre variant 2: Branch target injection.}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00084}00084 \textcolor{comment}{ * (CVE-\/2017-\/5715)}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00085}00085 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00086}00086 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00087}\mbox{\hyperlink{smccc_8c_ab9e7b66332b9b5d11742c8e071fb9adb}{00087}} \mbox{\hyperlink{smccc_8c_ab9e7b66332b9b5d11742c8e071fb9adb}{smccc\_arch\_workaround\_1}}(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00088}00088 \{}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00089}00089 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00090}00090         KASSERT(\mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{smccc\_version}} != \mbox{\hyperlink{smccc_8c_ad8194a9940950453c6e71e75a349d0b0}{SMCCC\_VERSION\_1\_0}},}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00091}00091             (\textcolor{stringliteral}{"{}SMCCC arch workaround 1 called with an invalid SMCCC interface"{}}));}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00092}00092         \textcolor{keywordflow}{return} (\mbox{\hyperlink{psci_8h_a6c24155fd6c168843938b6b742714a60}{psci\_call}}(\mbox{\hyperlink{smccc_8h_a4bb95e12efd1145688871b3c7f0cfa9a}{SMCCC\_ARCH\_WORKAROUND\_1}}, 0, 0, 0));}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00093}00093 \}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00094}00094 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00095}00095 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00096}\mbox{\hyperlink{smccc_8c_a604c75ad10c1a7ca563a811195e24576}{00096}} \mbox{\hyperlink{smccc_8c_a604c75ad10c1a7ca563a811195e24576}{smccc\_arch\_workaround\_2}}(\textcolor{keywordtype}{int} enable)}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00097}00097 \{}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00099}00099         KASSERT(\mbox{\hyperlink{smccc_8c_ad95ed0b2bbbc6fa8060310201cacadd7}{smccc\_version}} != \mbox{\hyperlink{smccc_8c_ad8194a9940950453c6e71e75a349d0b0}{SMCCC\_VERSION\_1\_0}},}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00100}00100             (\textcolor{stringliteral}{"{}SMCCC arch workaround 2 called with an invalid SMCCC interface"{}}));}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00101}00101         \textcolor{keywordflow}{return} (\mbox{\hyperlink{psci_8h_a6c24155fd6c168843938b6b742714a60}{psci\_call}}(\mbox{\hyperlink{smccc_8h_adddc53e4004def9febc51b16d9a46bd5}{SMCCC\_ARCH\_WORKAROUND\_2}}, enable, 0, 0));}
\DoxyCodeLine{\Hypertarget{smccc_8c_source_l00102}00102 \}}

\end{DoxyCode}
