\documentclass[twoside,11pt,openany]{book}
\setcounter{tocdepth}{4}
\setcounter{secnumdepth}{4}

\input{preamble}

% All registers are named here. That way when we rename one we'll get errors if
% there are still references to the old name.

\usepackage{makeidx}
\makeindex

\usepackage{xspace}
\newcommand{\defregname}[2]{\providecommand{#1}{{\tt #2}\xspace}}
\newcommand{\deffieldname}[2]{\providecommand{#1}{{$|#2|$}\xspace}}
\deffieldname{\Fmprv}{MPRV}
\deffieldname{\Fmie}{MIE}
\deffieldname{\Fmxl}{MXL}
\defregname{\Rmisa}{misa}
\defregname{\Rmstatus}{mstatus}
\defregname{\Rmcause}{mcause}
\defregname{\Rmie}{mie}

\deffieldname{\Fasid}{ASID}
\defregname{\Rsatp}{satp}

\defregname{\Azero}{a0}
\defregname{\Aone}{a1}

\defregname{\Rzero}{zero}
\defregname{\Szero}{s0}
\defregname{\Sone}{s1}

\defregname{\Tzero}{t0}

\defregname{\Xzero}{x0}
\defregname{\Xone}{x1}
\defregname{\Xeight}{x8}
\defregname{\Xnine}{x9}
\defregname{\Xten}{x10}
\defregname{\Xeleven}{x11}
\defregname{\Xthirtyone}{x31}
\defregname{\Fone}{f1}
\defregname{\Rpc}{pc}
\defregname{\Rmhartid}{mhartid}
\defregname{\Rmepc}{mepc}
\defregname{\Rdataone}{data1}

\input{hwbp_registers.tex.inc}
\input{core_registers.tex.inc}
\input{jtag_registers.tex.inc}
\input{dm_registers.tex.inc}
\input{sample_registers.tex.inc}
\input{abstract_commands.tex.inc}
\input{sw_registers.tex.inc}

\deffieldname{\Fhartsel}{\hyperref[hartsel]{hartsel}}
\deffieldname{\Fsize}{\hyperref[sizelo]{size}}
\deffieldname{\Faction}{action}
\deffieldname{\Fresethaltreq}{\hyperref[resethaltreq]{resethaltreq}}

\input{vc.tex}

\newcommand{\versionnum}{0.13.2\ifrelease\else-DRAFT\fi}

\begin{document}

\title{RISC-V External Debug Support\\
Version \versionnum\\
\GITHash
}
\author{Editors: \\
Tim Newsome \textless tim@sifive.com\textgreater, SiFive, Inc. \\
Megan Wachs \textless megan@sifive.com\textgreater, SiFive, Inc.}
\date{\GITAuthorDate}
\maketitle

Contributors to all versions of the spec in alphabetical order (please contact
editors to suggest corrections):
Bruce Ableidinger,
Krste Asanovi\'{c},
Allen Baum,
Mark Beal,
Alex Bradbury,
Chuanhua Chang,
Zhong-Ho Chen,
Monte Dalrymple,
Vyacheslav Dyachenko,
Peter Egold,
Markus Goehrle,
Robert Golla,
John Hauser,
Richard Herveille,
Yung-ching Hsiao,
Po-wei Huang,
Scott Johnson,
Jean-Luc Nagel,
Aram Nahidipour,
Rishiyur Nikhil,
Gajinder Panesar,
Deepak Panwar,
Antony Pavlov,
Klaus Kruse Pedersen,
Ken Pettit,
Joe Rahmeh,
Gavin Stark,
Wesley Terpstra,
Jan-Willem van de Waerdt,
Stefan Wallentowitz,
Ray Van De Walker,
Andrew Waterman,
Andy Wright,
and Bryan Wyatt.

\markboth{RISC-V External Debug Support Version \versionnum}
{RISC-V External Debug Support Version \versionnum}
\thispagestyle{empty}

\frontmatter

\input{preface.tex}

\tableofcontents
\listoffigures
\listoftables

\mainmatter

\newpage

\input{introduction}
\input{overview}
\input{debug_module}
\input{core_debug}
\input{trigger}
\input{dtm}

\newpage
\appendix

\include{implementations}
\include{debugger_implementation}
\include{bugfixes}

\clearpage
\addcontentsline{toc}{chapter}{Index}
\label{index}
\printindex

\ifrelease
\else
    \chapter{Change Log}

    \begin{versionhistory}
        \input{changelog.tex}
    \end{versionhistory}
\fi

\end{document}
