From owner-freebsd-hackers@freebsd.org Sat Jun 17 02:46:14 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 36902D909B1 for ; Sat, 17 Jun 2017 02:46:14 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C842F7A55E for ; Sat, 17 Jun 2017 02:46:13 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-wm0-f51.google.com with SMTP id u195so23852099wmd.1 for ; Fri, 16 Jun 2017 19:46:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=ZbBCGPHFU/GzUeEC0dXyuJhGXtkR/jHYDb3e1vqw1dg=; b=OATq9YCiMEJuf8UJgAvWtGnBhj3Pd9xH/lwXd0kyrfjP25nv8Qi+t/L2rAwKhH4ITU xFhOq3hO/csl3NMC4vEKnHGzUzKEWhLC6pYSlsF3b/9dyafWSvYJLWAPjK/WDppeQLqO Z+HV8E+Ini9CyIwZguTQy6vWdXkUrF5F6EcyZoCccywDTur7MoGl2FN0JqU1ThtKjWPo kmwj9Cqvo9D/b3ZJf4g+Yno78VJnImlnAMx07t57WtZkDCvzXVswR48QcbM+oz/E186U rR1bO918wiCJx6xmGVLl7sDSl726dQfnKB0B524xZgIvZkqFKyX/ccudPZINEnVj4qx7 4u7Q== X-Gm-Message-State: AKS2vOz8XryPq6sCCUrqBs972WUR3rbCucU+BT7rX/GqOx0XXnoiNSmE S7GxJNDVUPg8T2eLfMQ= X-Received: by 10.28.143.149 with SMTP id r143mr8271156wmd.61.1497636483831; Fri, 16 Jun 2017 11:08:03 -0700 (PDT) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com. [74.125.82.48]) by smtp.gmail.com with ESMTPSA id e77sm2039554wma.32.2017.06.16.11.08.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 11:08:03 -0700 (PDT) Received: by mail-wm0-f48.google.com with SMTP id d73so29885632wma.0 for ; Fri, 16 Jun 2017 11:08:03 -0700 (PDT) X-Received: by 10.80.184.129 with SMTP id l1mr8208440ede.88.1497636483498; Fri, 16 Jun 2017 11:08:03 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.80.164.154 with HTTP; Fri, 16 Jun 2017 11:08:03 -0700 (PDT) In-Reply-To: References: From: Conrad Meyer Date: Fri, 16 Jun 2017 11:08:03 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: efifb framebuffer info for NVIDIA driver console restore To: Aaron Plattner Cc: "freebsd-hackers@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jun 2017 02:46:14 -0000 Hi Aaron, I'm not sure it's the best way, but you could find EFI framebuffer information in the same way the efifb vt(4) driver (sys/dev/vt/hw/efifb/efifb.c) does, by inspecting the struct efi_fb preload data (which is passed from the loader to the kernel). Something like: caddr_t kmdp; struct efi_fb *efifb; kmdp = preload_search_by_type("elf kernel"); if (kmdp == NULL) kmdp = preload_search_by_type("elf64 kernel"); efifb = (struct efi_fb *)preload_search_info(kmdp, MODINFO_METADATA | MODINFOMD_EFI_FB); if (efifb != NULL) /* Found framebuffer information */; Hope that helps, Conrad On Fri, Jun 16, 2017 at 9:51 AM, Aaron Plattner wrote: > Hi FreeBSD hackers, > > My name is Aaron Plattner. I'm a driver developer at NVIDIA working on > the FreeBSD driver, among other things. I was hoping you could help me > out regarding some changes I've been making to the driver. > > Recently, we've revamped how our driver handles switching from > graphical modes to the console mode. For framebuffer consoles, the new > nvidia_modeset module tries to take care of it without having to fall > back to old-school VESA VBE modesets. However, in order for this to > work, the driver needs to know where the framebuffer console is in > physical memory, and its layout. > > On Linux, we get this information from the global 'screen_info' > structure: > > void NV_API_CALL os_get_screen_info( > NvU64 *pPhysicalAddress, > NvU16 *pFbWidth, > NvU16 *pFbHeight, > NvU16 *pFbDepth, > NvU16 *pFbPitch > ) > { > // > // If there is not a framebuffer console, return 0 size. > // > // orig_video_isVGA is set to 1 during early Linux kernel > // initialization, and then will be set to a value, such as > // VIDEO_TYPE_VLFB or VIDEO_TYPE_EFI if an fbdev console is used. > // > if (screen_info.orig_video_isVGA <= 1) > { > *pPhysicalAddress = 0; > *pFbWidth = *pFbHeight = *pFbDepth = *pFbPitch = 0; > return; > } > > *pPhysicalAddress = screen_info.lfb_base; > #if defined(VIDEO_CAPABILITY_64BIT_BASE) > *pPhysicalAddress |= (NvU64)screen_info.ext_lfb_base << 32; > #endif > *pFbWidth = screen_info.lfb_width; > *pFbHeight = screen_info.lfb_height; > *pFbDepth = screen_info.lfb_depth; > *pFbPitch = screen_info.lfb_linelength; > } > > This works for both legacy boot systems with vesafb as well as UEFI > systems that use Linux's efifb. > > On FreeBSD, I was able to find this information on my legacy system: > > void NV_API_CALL os_get_screen_info( > NvU64 *pPhysicalAddress, > NvU16 *pFbWidth, > NvU16 *pFbHeight, > NvU16 *pFbDepth, > NvU16 *pFbPitch > ) > { > const sc_softc_t *sc = sc_get_softc(0, SC_KERNEL_CONSOLE); > > if (sc) > { > const video_adapter_t *adp = sc->adp; > > if (adp) > { > const struct video_info *vi = &adp->va_info; > > if (vi && (vi->vi_flags & V_INFO_LINEAR)) > { > *pPhysicalAddress = vi->vi_buffer; > *pFbWidth = vi->vi_width; > *pFbHeight = vi->vi_height; > *pFbDepth = vi->vi_depth; > *pFbPitch = adp->va_line_width; > return; > } > } > } > > *pPhysicalAddress = 0; > *pFbWidth = *pFbHeight = *pFbDepth = *pFbPitch = 0; > } > > However, this doesn't work on UEFI systems because efifb doesn't go > through the video_adapter_t stuff. Does anyone know how I can get that > information from efifb, or who to talk to about adding an interface > the driver can use to find it? > > Sincerely, > Aaron > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"