From 5b20b615f2355a06fa1191a5eb55efa9bfe2ebfc Mon Sep 17 00:00:00 2001 From: NicJA Date: Fri, 19 Apr 2019 16:34:45 +0000 Subject: [PATCH] use the gfx hidd attribute(s) for accessing the gfx drivers memory details. move some more strings to the catalogs. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@56310 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- workbench/system/SysMon/catalogs/czech.ct | 26 +++- workbench/system/SysMon/catalogs/french.ct | 24 +++- workbench/system/SysMon/catalogs/sysmon.cd | 23 ++- workbench/system/SysMon/main.c | 36 ++--- workbench/system/SysMon/mmakefile.src | 1 + workbench/system/SysMon/sysmon_intern.h | 12 +- workbench/system/SysMon/video.c | 221 +++++++++++++---------------- 7 files changed, 187 insertions(+), 156 deletions(-) rewrite workbench/system/SysMon/video.c (71%) diff --git a/workbench/system/SysMon/catalogs/czech.ct b/workbench/system/SysMon/catalogs/czech.ct index ce9108bc3b..e0be2feed2 100644 --- a/workbench/system/SysMon/catalogs/czech.ct +++ b/workbench/system/SysMon/catalogs/czech.ct @@ -1,4 +1,4 @@ -## version $VER: SysMon.catalog 1.1 (25.01.2017) +## version $VER: SysMon.catalog 1.2 (19.04.2019) ## language czech ## codeset 5 ; @@ -104,9 +104,9 @@ MSG_VIDEO_RAM Video pamì» ; Video Memory ; -MSG_GART_APER -GART Aperture -; GART Aperture +MSG_VIDEO_WINDOW_TMPL +%s +; %s Window ; MSG_CANT_OPEN_TASK_RESOURCE Nelze otevøít soubor task.resource\n @@ -140,3 +140,21 @@ MSG_TASK_UNKNOWN ; ; +MSG_WINDOW_GART +GART +; +MSG_DISPLAY_MODE +Display Mode +; +MSG_LOAD +Processor Load +; +MSG_GUAGE +Gauge +; +MSG_GRAPH +Graph +; +MSG_GRAPH_PER_PROC +Graph Per Processor +; diff --git a/workbench/system/SysMon/catalogs/french.ct b/workbench/system/SysMon/catalogs/french.ct index 21bd3947c2..a679076cf9 100644 --- a/workbench/system/SysMon/catalogs/french.ct +++ b/workbench/system/SysMon/catalogs/french.ct @@ -1,4 +1,4 @@ -## version $VER: SysMon.catalog 1.2 (25.01.2017) +## version $VER: SysMon.catalog 1.2 (19.04.2019) ## language français ## codeset 0 ; @@ -79,8 +79,8 @@ M MSG_VIDEO_RAM Mémoire Video ; -MSG_GART_APER -Ouverture GART +MSG_VIDEO_WINDOW_TMPL +%s ; MSG_CANT_OPEN_TASK_RESOURCE Ne peut pas ouvrir task.resource\n @@ -106,3 +106,21 @@ MSG_TASK_TOMBSTONE MSG_TASK_UNKNOWN ; +MSG_WINDOW_GART +GART +; +MSG_DISPLAY_MODE +Display Mode +; +MSG_LOAD +Processor Load +; +MSG_GUAGE +Gauge +; +MSG_GRAPH +Graph +; +MSG_GRAPH_PER_PROC +Graph Per Processor +; diff --git a/workbench/system/SysMon/catalogs/sysmon.cd b/workbench/system/SysMon/catalogs/sysmon.cd index 820965fa86..3c023f609d 100644 --- a/workbench/system/SysMon/catalogs/sysmon.cd +++ b/workbench/system/SysMon/catalogs/sysmon.cd @@ -1,3 +1,4 @@ +; $VER: sysmon.cd 1.2 (19.04.2019) ; MSG_APP_NAME (//) SysMon @@ -74,8 +75,8 @@ Fast Memory MSG_VIDEO_RAM (//) Video Memory ; -MSG_GART_APER (//) -GART Aperture +MSG_VIDEO_WINDOW_TMPL (//) +%s Window ; MSG_CANT_OPEN_TASK_RESOURCE (//) Can't open task.resource\n @@ -101,3 +102,21 @@ MSG_TASK_TOMBSTONE (//) MSG_TASK_UNKNOWN (//) ; +MSG_WINDOW_GART (//) +GART +; +MSG_DISPLAY_MODE (//) +Display Mode +; +MSG_LOAD (//) +Processor Load +; +MSG_GUAGE (//) +Gauge +; +MSG_GRAPH (//) +Graph +; +MSG_GRAPH_PER_PROC (//) +Graph Per Processor +; diff --git a/workbench/system/SysMon/main.c b/workbench/system/SysMon/main.c index ec7b67ce47..75df68fe0c 100644 --- a/workbench/system/SysMon/main.c +++ b/workbench/system/SysMon/main.c @@ -1,5 +1,5 @@ /* - Copyright 2010-2017, The AROS Development Team. All rights reserved. + Copyright 2010-2019, The AROS Development Team. All rights reserved. $Id$ */ @@ -13,11 +13,13 @@ #include +#include + #include "sysmon_intern.h" #include "locale.h" -#define VERSION "$VER: SysMon 1.9 (26.02.2017) ©2011-2017 The AROS Development Team" +#define VERSION "$VER: SysMon 1.10 (19.04.2019) ©2011-2019 The AROS Development Team" CONST_STRPTR CPU_DEFSTR = "CPU --\n--.- %"; @@ -79,9 +81,9 @@ BOOL CreateApplication(struct SysMonData * smdata) Object * cpufreqgroup, * cpufreqcntnr; - - IPTR i; + char videowinstr[100]; ULONG processorcount; + IPTR i; processorcount = GetProcessorCount(); @@ -132,11 +134,13 @@ BOOL CreateApplication(struct SysMonData * smdata) End; } + sprintf(videowinstr, _(MSG_VIDEO_WINDOW_TMPL), _(MSG_WINDOW_GART)); + smdata->application = ApplicationObject, MUIA_Application_Title, __(MSG_APP_NAME), MUIA_Application_Version, (IPTR) VERSION, MUIA_Application_Author, (IPTR) "Krzysztof Smiechowicz", - MUIA_Application_Copyright, (IPTR)"©2011-2017, The AROS Development Team", + MUIA_Application_Copyright, (IPTR)"©2011-2019, The AROS Development Team", MUIA_Application_Base, (IPTR)"SYSMON", MUIA_Application_Description, __(MSG_APP_TITLE), SubWindow, @@ -176,13 +180,13 @@ BOOL CreateApplication(struct SysMonData * smdata) GroupFrameT(_(MSG_USAGE)), MUIA_ContextMenu, (MenustripObject, MUIA_Family_Child, (MenuObject, - MUIA_Menu_Title, (IPTR)"Processor Load", + MUIA_Menu_Title, __(MSG_LOAD), MUIA_Family_Child, (MenuitemObject, - MUIA_Menuitem_Title, (IPTR)"Display Mode", - MUIA_Family_Child, (cmenucpugauge = MenuitemObject, MUIA_Menuitem_Title, (IPTR)"Gauge", MUIA_Menuitem_Shortcut, (IPTR)"G",End), - MUIA_Family_Child, (cmenucpugraph = MenuitemObject, MUIA_Menuitem_Title, (IPTR)"Graph", MUIA_Menuitem_Shortcut, (IPTR)"S",End), + MUIA_Menuitem_Title, __(MSG_DISPLAY_MODE), + MUIA_Family_Child, (cmenucpugauge = MenuitemObject, MUIA_Menuitem_Title, __(MSG_GUAGE), MUIA_Menuitem_Shortcut, (IPTR)"G",End), + MUIA_Family_Child, (cmenucpugraph = MenuitemObject, MUIA_Menuitem_Title, __(MSG_GRAPH), MUIA_Menuitem_Shortcut, (IPTR)"S",End), (processorcount > 1) ? MUIA_Family_Child : TAG_IGNORE, - (cmenucpugraphpcpu = MenuitemObject, MUIA_Menuitem_Title, (IPTR)"Graph Per Processor", MUIA_Menuitem_Shortcut, (IPTR)"P",End), + (cmenucpugraphpcpu = MenuitemObject, MUIA_Menuitem_Title, __(MSG_GRAPH_PER_PROC), MUIA_Menuitem_Shortcut, (IPTR)"P",End), End), End), End), @@ -230,11 +234,11 @@ BOOL CreateApplication(struct SysMonData * smdata) Child, VGroup, GroupFrameT(_(MSG_VIDEO_SIZE)), Child, ColGroup(2), Child, Label(_(MSG_VIDEO_RAM)), - Child, smdata->memorysize[MEMORY_VRAM] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, + Child, smdata->memorysize[MEMORY_VMEM] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_PreParse, (IPTR)"\33r", MUIA_Text_Contents, (IPTR)"", End, - Child, Label(_(MSG_GART_APER)), - Child, smdata->memorysize[MEMORY_GART] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, + Child, Label(videowinstr), + Child, smdata->memorysize[MEMORY_VMEMWINDOW] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_PreParse, (IPTR)"\33r", MUIA_Text_Contents, (IPTR)"", End, End, @@ -242,11 +246,11 @@ BOOL CreateApplication(struct SysMonData * smdata) Child, VGroup, GroupFrameT(_(MSG_VIDEO_FREE)), Child, ColGroup(2), Child, Label(_(MSG_VIDEO_RAM)), - Child, smdata->memoryfree[MEMORY_VRAM] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, + Child, smdata->memoryfree[MEMORY_VMEM] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_PreParse, (IPTR)"\33r", MUIA_Text_Contents, (IPTR)"", End, - Child, Label(_(MSG_GART_APER)), - Child, smdata->memoryfree[MEMORY_GART] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, + Child, Label(videowinstr), + Child, smdata->memoryfree[MEMORY_VMEMWINDOW] = TextObject, TextFrame, MUIA_Background, MUII_TextBack, MUIA_Text_PreParse, (IPTR)"\33r", MUIA_Text_Contents, (IPTR)"", End, End, diff --git a/workbench/system/SysMon/mmakefile.src b/workbench/system/SysMon/mmakefile.src index 34e13336f6..5963b96f4e 100644 --- a/workbench/system/SysMon/mmakefile.src +++ b/workbench/system/SysMon/mmakefile.src @@ -7,6 +7,7 @@ FILES := main locale memory video processor processor_gauge processor_graph task EXEDIR := $(AROSDIR)/System #MM- workbench-system : workbench-system-sysmon +#MM workbench-system-sysmon-quick : workbench-system-sysmon-catalogs #MM workbench-system-sysmon : includes kernel-task-includes linklibs \ #MM workbench-system-sysmon-catalogs diff --git a/workbench/system/SysMon/sysmon_intern.h b/workbench/system/SysMon/sysmon_intern.h index 0a1019fd27..d94bb10ec3 100644 --- a/workbench/system/SysMon/sysmon_intern.h +++ b/workbench/system/SysMon/sysmon_intern.h @@ -1,5 +1,5 @@ /* - Copyright 2010-2017, The AROS Development Team. All rights reserved. + Copyright 2010-2019, The AROS Development Team. All rights reserved. $Id$ */ @@ -16,11 +16,11 @@ //#define PROCDISPLAY_USEGAUGE //#define PROCDISPLAY_SINGLEGRAPH -#define MEMORY_RAM 0 -#define MEMORY_CHIP 1 -#define MEMORY_FAST 2 -#define MEMORY_VRAM 3 -#define MEMORY_GART 4 +#define MEMORY_RAM 0 +#define MEMORY_CHIP 1 +#define MEMORY_FAST 2 +#define MEMORY_VMEM 3 +#define MEMORY_VMEMWINDOW 4 #define SYSMON_TABCOUNT 3 diff --git a/workbench/system/SysMon/video.c b/workbench/system/SysMon/video.c dissimilarity index 71% index d6ca41dacb..81e458ae48 100644 --- a/workbench/system/SysMon/video.c +++ b/workbench/system/SysMon/video.c @@ -1,125 +1,96 @@ -/* - Copyright © 1995-2017, The AROS Development Team. All rights reserved. - $Id$ -*/ - -#include "sysmon_intern.h" - -#include - -/* Video information */ -#if defined(VRAM_HACK) - -/* This code is a HACK which uses private nouveau.hidd API to get the VRAM/GART - information. This will work only on nVidia cards running nouveau driver. - The reason for this hack is that there is no public API that would return - the needed values. */ - -#include -#include -#include -struct BitMap * bm = NULL; -#undef HiddGfxNouveauAttrBase -#undef HiddBitMapAttrBase -OOP_AttrBase HiddGfxNouveauAttrBase; -OOP_AttrBase HiddBitMapAttrBase; -#define IID_Hidd_Gfx_Nouveau "hidd.gfx.nouveau" -enum -{ - aoHidd_Gfx_Nouveau_VRAMSize, /* [G..] The amount of total VRAM in bytes */ - aoHidd_Gfx_Nouveau_GARTSize, /* [G..] The amount of total GART in bytes */ - aoHidd_Gfx_Nouveau_VRAMFree, /* [G..] The amount of free VRAM in bytes */ - aoHidd_Gfx_Nouveau_GARTFree, /* [G..] The amount of free GART in bytes */ - - num_Hidd_Gfx_Nouveau_Attrs -}; - -#define aHidd_Gfx_Nouveau_VRAMSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMSize) -#define aHidd_Gfx_Nouveau_GARTSize (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTSize) -#define aHidd_Gfx_Nouveau_VRAMFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_VRAMFree) -#define aHidd_Gfx_Nouveau_GARTFree (HiddGfxNouveauAttrBase + aoHidd_Gfx_Nouveau_GARTFree) -struct Library * OOPBase = NULL; - -#endif - -/* Videofunctions */ -static BOOL InitVideo(struct SysMonData *smdata) -{ -#if defined(VRAM_HACK) - struct OOP_ABDescr attrbases[] = - { - { IID_Hidd_BitMap, &HiddBitMapAttrBase }, - { IID_Hidd_Gfx_Nouveau, &HiddGfxNouveauAttrBase }, - { NULL, NULL } - }; - struct Screen * wbscreen; - - OOPBase = OpenLibrary("oop.library", 0L); - - if (!OOPBase) - return FALSE; - - if (!OOP_ObtainAttrBases(attrbases)) - return FALSE; - - wbscreen = LockPubScreen(NULL); - bm = AllocBitMap(32, 32, 0, BMF_DISPLAYABLE, wbscreen->RastPort.BitMap); - UnlockPubScreen(NULL, wbscreen); -#endif - return TRUE; -} - -static VOID DeInitVideo(struct SysMonData *smdata) -{ -#if defined(VRAM_HACK) - FreeBitMap(bm); - - OOP_ReleaseAttrBase(IID_Hidd_BitMap); - OOP_ReleaseAttrBase(IID_Hidd_Gfx_Nouveau); - - CloseLibrary(OOPBase); -#endif -} - -VOID UpdateVideoStaticInformation(struct SysMonData * smdata) -{ -#if defined(VRAM_HACK) - TEXT buffer[64] = {0}; - IPTR vram_size, gart_size; - OOP_Object * gfxhidd; - OOP_Object * oopbm = HIDD_BM_OBJ(bm); - - OOP_GetAttr(oopbm, aHidd_BitMap_GfxHidd, (APTR)&gfxhidd); - OOP_GetAttr(gfxhidd, aHidd_Gfx_Nouveau_VRAMSize, &vram_size); - OOP_GetAttr(gfxhidd, aHidd_Gfx_Nouveau_GARTSize, &gart_size); - __sprintf(buffer, "%ld kB", (ULONG)(vram_size / 1024)); - set(smdata->memorysize[MEMORY_VRAM], MUIA_Text_Contents, buffer); - __sprintf(buffer, "%ld kB", (ULONG)(gart_size / 1024)); - set(smdata->memorysize[MEMORY_GART], MUIA_Text_Contents, buffer); -#endif -} - -VOID UpdateVideoInformation(struct SysMonData * smdata) -{ -#if defined(VRAM_HACK) - TEXT buffer[64] = {0}; - IPTR vram_free, gart_free; - OOP_Object * gfxhidd; - OOP_Object * oopbm = HIDD_BM_OBJ(bm); - - OOP_GetAttr(oopbm, aHidd_BitMap_GfxHidd, (APTR)&gfxhidd); - OOP_GetAttr(gfxhidd, aHidd_Gfx_Nouveau_VRAMFree, &vram_free); - OOP_GetAttr(gfxhidd, aHidd_Gfx_Nouveau_GARTFree, &gart_free); - __sprintf(buffer, "%ld kB", (ULONG)(vram_free / 1024)); - set(smdata->memoryfree[MEMORY_VRAM], MUIA_Text_Contents, buffer); - __sprintf(buffer, "%ld kB", (ULONG)(gart_free / 1024)); - set(smdata->memoryfree[MEMORY_GART], MUIA_Text_Contents, buffer); -#endif -} - -struct SysMonModule videomodule = -{ - .Init = InitVideo, - .DeInit = DeInitVideo, -}; - +/* + Copyright © 1995-2019, The AROS Development Team. All rights reserved. + $Id$ +*/ + +#include "sysmon_intern.h" + +#include + +/* Video information */ +#include +#include +#include +OOP_Object * gfxhidd; +#undef HiddBitMapAttrBase +OOP_AttrBase HiddGfxAttrBase; +OOP_AttrBase HiddBitMapAttrBase; +struct Library * OOPBase = NULL; + +/* Videofunctions */ +static BOOL InitVideo(struct SysMonData *smdata) +{ + struct OOP_ABDescr attrbases[] = + { + { IID_Hidd_Gfx, &HiddGfxAttrBase }, + { IID_Hidd_BitMap, &HiddBitMapAttrBase }, + { NULL, NULL } + }; + struct Screen * wbscreen; + + OOPBase = OpenLibrary("oop.library", 0L); + + if (!OOPBase) + return FALSE; + + if (!OOP_ObtainAttrBases(attrbases)) + return FALSE; + + wbscreen = LockPubScreen(NULL); + OOP_GetAttr(HIDD_BM_OBJ(wbscreen->RastPort.BitMap), aHidd_BitMap_GfxHidd, (APTR)&gfxhidd); + bug("[SysMon:Video] %s: gfxhidd @ 0x%p\n", __func__, gfxhidd); + UnlockPubScreen(NULL, wbscreen); + + return TRUE; +} + +static VOID DeInitVideo(struct SysMonData *smdata) +{ + OOP_ReleaseAttrBase(IID_Hidd_BitMap); + + CloseLibrary(OOPBase); +} + +VOID UpdateVideoStaticInformation(struct SysMonData * smdata) +{ + TEXT buffer[64] = {0}; + struct TagItem memTags[] = + { + {vHidd_Gfx_MemTotal, 0 }, + {vHidd_Gfx_MemAddressableTotal, 0 }, + {TAG_DONE, 0 } + }; + + bug("[SysMon:Video] %s: memTags @ 0x%p\n", __func__, memTags); + OOP_GetAttr(gfxhidd, aHidd_Gfx_MemoryAttribs, (IPTR *)memTags); + + __sprintf(buffer, "%ld kB", (ULONG)(memTags[0].ti_Data / 1024)); + set(smdata->memorysize[MEMORY_VMEM], MUIA_Text_Contents, buffer); + __sprintf(buffer, "%ld kB", (ULONG)(memTags[1].ti_Data / 1024)); + set(smdata->memorysize[MEMORY_VMEMWINDOW], MUIA_Text_Contents, buffer); +} + +VOID UpdateVideoInformation(struct SysMonData * smdata) +{ + TEXT buffer[64] = {0}; + struct TagItem memTags[] = + { + {vHidd_Gfx_MemFree, 0 }, + {vHidd_Gfx_MemAddressableFree, 0 }, + {TAG_DONE, 0 } + }; + + bug("[SysMon:Video] %s: memTags @ 0x%p\n", __func__, memTags); + OOP_GetAttr(gfxhidd, aHidd_Gfx_MemoryAttribs, (IPTR *)memTags); + + __sprintf(buffer, "%ld kB", (ULONG)(memTags[0].ti_Data / 1024)); + set(smdata->memoryfree[MEMORY_VMEM], MUIA_Text_Contents, buffer); + __sprintf(buffer, "%ld kB", (ULONG)(memTags[1].ti_Data / 1024)); + set(smdata->memoryfree[MEMORY_VMEMWINDOW], MUIA_Text_Contents, buffer); +} + +struct SysMonModule videomodule = +{ + .Init = InitVideo, + .DeInit = DeInitVideo, +}; -- 2.11.4.GIT