From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-x22b.google.com (mail-qk0-x22b.google.com [IPv6:2607:f8b0:400d:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F421181A97 for ; Sat, 7 Jan 2017 13:15:00 -0800 (PST) Received: by mail-qk0-x22b.google.com with SMTP id u25so491987303qki.2 for ; Sat, 07 Jan 2017 13:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=CEbzIoLooZbF8aEpB2tWvIVRUZv7E8oEkyhPXneFB/A=; b=qis1fqHY2K/KXvQmcbMOMxAVq6KrKHy9ViZ96aSC1O6bQsL5vgrhkbkQz1Xhwp0DiX dCAfLsZMsfMOtUHdqbG2pp5dg3gZI7nKzW4BLl/SHYgG8QM8vt8tYTDiU04JJzExw2JS u01VLjiekm768ifX6rJAYLrSjfbjqkh6V1QSfBmZRLet0t99gN9mA6mQrOhgtWIu/iSW pqMEfTCvVKuAAIJJvdbE4DJJjamiaohrzJQImMkLwjLUpIgB3hOq5tzTAdVldEViWDCM 9EwrxmWhnDF1fUdaSIIcvhakre3S2p6fHP9e1qkLv1W9iZ2tTqJzrho007a4LKk0PxHu jVaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=CEbzIoLooZbF8aEpB2tWvIVRUZv7E8oEkyhPXneFB/A=; b=GXUOV2/OIQtG4eYsTHjfdAA7uJ2xCjdi/42fL8X3zfosOKpfC5WYz06lPNkF627+PV Sfr+aYDNBPEnmilzc4qrOj7v0PrLnA2KsCwHVSglqFlDbUo/AryPc/nZkgLZlrSKqoZZ ZvCpwGfS8Gdp9m96GCqpVjvVuS9Hafxun++HS8RlNj1x03dl2yWYKZrn9/Gi9x1KvRix HJ6vETqyX9hzkRh9cnyhdY3RuYZQzj/X2FGF1poZojXCwHNm6J/vaODjiDFuq1nd1hWW VoCseHRyHspJgkEG9pkilotwtzLx+/0kOVuciw6DHw9T2hDsNc5gsKQs78le7Eo1ubp/ EmAA== X-Gm-Message-State: AIkVDXLhjqoplxC6MPwPfNQ8RXCmFupJDYsOQ3F3maso4Z0ecVoRiPjNoJdgaQdy+XN50Ai3eXlmivfkyaeksg== X-Received: by 10.55.210.131 with SMTP id f125mr18408179qkj.98.1483823700211; Sat, 07 Jan 2017 13:15:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Rafael Machado Date: Sat, 07 Jan 2017 21:14:49 +0000 Message-ID: To: Laszlo Ersek , "Alcantara, Paulo" , "edk2-devel@lists.01.org" X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: Question about OS initialization at UEFI firmware (x86) X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Jan 2017 21:15:01 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks a lot guys. Now things make sense. Em qui, 5 de jan de 2017 =C3=A0s 11:18, Laszlo Ersek escreveu: > On 01/05/17 13:16, Alcantara, Paulo wrote: > >> -----Original Message----- > >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > >> Rafael Machado > >> Sent: quinta-feira, 5 de janeiro de 2017 10:00 > >> To: edk2-devel@lists.01.org > >> Subject: [edk2] Question about OS initialization at UEFI firmware (x86= ) > >> > >> Hi everyone > >> > >> I was taking a look at how the OS boots after the firmware and > bootloader > >> are done. > >> > >> To understand this I started to take a look at the linux source code, > and the > >> strange is that I saw some bios legacy interrupts being called. > >> > >> The flow I checked is this: > >> > >> void main(void) --> linux/arch/x86/boot/main.c > >> int detect_memory(void) --> linux/arch/x86/boot/memory.c > >> static int detect_memory_e820(void) --> > >> linux/arch/x86/boot/memory.c > >> intcall(0x15, &ireg, &oreg) --> > linux/arch/x86/boot/memory.c > >> > >> > >> At the last call the value of ireg is this one: > >> > >> ireg.ax =3D 0xe820; > >> ireg.cx =3D sizeof buf; > >> ireg.edx =3D SMAP; > >> ireg.di =3D (size_t)&buf; > >> > >> > >> As we can see this is done so the OS knows the memory map, so the OS c= an > >> do all its magic. > >> > >> Finally, my question is: > >> > >> How could linux, or any other OS, boot on a system with UEFI firmware > that > >> does not have CSM (compatibility support module) ? > > > > The code you pasted above seems to be executed when booting Linux on > > PC BIOS firmware. See below. > > > >> I consider that some parts of the hypothetical OS need to be written t= o > call > >> some UEFI protocols. Am I right ? > > > > As far as I know, there are currently two ways of booting Linux on > > UEFI firmware: > > > > 1) The OS loader (bootloader as a PE/COFF image) uses the EFI handover > > protocol to boot the Linux kernel image. What the loader does is > > basically to find the entry point offset (handover_offset) in that > > image and jump to it. The entry point conforms to ABI defined in UEFI > > spec. > > > > 2) The kernel may be built as PE/COFF binary (UEFI image) so the > firmware can > > directly boot it at BDS without any external OS loader. > > > > You might want to look at how OVMF boots up Linux through QEMU's > command-line parameter "-kernel" by using EFI handover protocol. > > See also: > > https://lwn.net/Articles/632528/ > >